Jump to content

Jennifer2010

New Members
  • Posts

    6
  • Joined

  • Last visited

Everything posted by Jennifer2010

  1. Hi everyone! I'm using a small PHP plugin for WordPress for social sharing. The problem is, the links open up in a new tab instead of a new, small pop-up window. Here's the Facebook code example for the pop-out I'm desiring: <a href="#" onclick=" window.open( 'https://www.facebook.com/sharer/sharer.php?u='+encodeURIComponent(location.href), 'facebook-share-dialog', 'width=626,height=436'); return false;"> Share On Facebook </a> And here is the plugin code: <?php /* Plugin Name: Boon's Simple Social Sharing Plugin URI: https://github.com/mattberridge/Simple-Social-Sharing-Buttons Description: Super lightweight social sharing buttons (without counters) Author: built by Boon Author URI: http://builtbyboon.com */ function simple_social_sharing( $attr_twitter = null, $attr_items = null ) { // parse variables $twitter_account = $attr_twitter; $item_toggles = $attr_items; // get post content and urlencode it global $post; $browser_title_encoded = urlencode( trim( wp_title( '', false, 'right' ) ) ); $page_title_encoded = urlencode( get_the_title() ); $page_url_encoded = urlencode( get_permalink($post->ID) ); // create share items array $share_items = array (); // set each item $item_facebook = array( "class" => "facebook", "href" => "http://www.facebook.com/sharer.php?u={$page_url_encoded}&t={$browser_title_encoded}", "text" => "Share On Facebook" ); $item_twitter = array( "class" => "twitter", "href" => "http://twitter.com/share?text={$page_title_encoded}&url={$page_url_encoded}&via={$twitter_account}", "text" => "Twitter" ); $item_google = array( "class" => "google", "href" => "http://plus.google.com/share?url={$page_url_encoded}", "text" => "G+" ); // test whether to display each item if($item_toggles) { // explode into array $item_toggles_array = explode( ",", $item_toggles ); // set each item on or off $show_facebook = $item_toggles_array['0']; $show_twitter = $item_toggles_array['1']; $show_google = $item_toggles_array['2']; } else { $display_all_items = 1; } // form array of items set to 1 if( $show_facebook==1 || $display_all_items ) { array_push( $share_items, $item_facebook ); } if( $show_twitter==1 || $display_all_items) { array_push( $share_items, $item_twitter ); } if( $show_google==1 || $display_all_items) { array_push( $share_items, $item_google ); } // if one or more items if ( ! empty( $share_items ) ) { // create output $share_output = "<ul class=\"ss-share\">\n"; foreach ( $share_items as $share_item ) { $share_output .= "<li class=\"ss-share-item\">\n"; $share_output .= "<a class=\"ss-share-link ico-{$share_item['class']}\" href=\"{$share_item["href"]}\" rel=\"nofollow\" target=\"_blank\">{$share_item['text']}</a>\n"; $share_output .= "</li>\n"; } $share_output .= "</ul>"; // echo output echo $share_output; } } // add shortcode to output buttons function simple_social_sharing_shortcode( $atts, $content = null ) { // parse variables / set defaults extract( shortcode_atts( array( 'twitter' => '', 'display' => '1,1,1', ), $atts ) ); // output buttons ob_start(); simple_social_sharing( $twitter, $display ); $output_string = ob_get_contents(); ob_end_clean(); return force_balance_tags( $output_string ); } add_shortcode( 'simple-social-sharing', 'simple_social_sharing_shortcode' ); ?> Any help is greatly appreciated -- I've been trying for a week to figure this out! Thank you!
  2. Thank you for the response. I had already tried that before coming here and it did not work. I ended up finding out the change of directory not working was due to a folder permission error so now uploads are stored in the right location and are working. Thank you!
  3. If anyone can recommend a solution I would greatly appreciate it!
  4. I'm using "Roots" theme for WordPress and it rewrites assets files like mysite.com/wp-content/themes/theme/assets/img/img.jpeg into mysite.com/assets/img/img.jpeg However, I'm trying to get WordPress to rewrite the wp-content/uploads folder to just media ( mysite.com/wp-content/uploads vs mysite.com/media ) Can anyone tell me how to do it, provided the following rewrite file? Thank you! <?php /** * URL rewriting * * Rewrites do not happen for multisite installations or child themes * * Rewrite: * /wp-content/themes/themename/assets/css/ to /assets/css/ * /wp-content/themes/themename/assets/js/ to /assets/js/ * /wp-content/themes/themename/assets/img/ to /assets/img/ * /wp-content/plugins/ to /plugins/ * * If you aren't using Apache, alternate configuration settings can be found in the docs. * * @link https://github.com/retlehs/roots/blob/master/doc/rewrites.md */ function roots_add_rewrites($content) { global $wp_rewrite; $roots_new_non_wp_rules = array( 'assets/(.*)' => THEME_PATH . '/assets/$1', 'plugins/(.*)' => RELATIVE_PLUGIN_PATH . '/$1' ); $wp_rewrite->non_wp_rules = array_merge($wp_rewrite->non_wp_rules, $roots_new_non_wp_rules); return $content; } function roots_clean_urls($content) { if (strpos($content, RELATIVE_PLUGIN_PATH) > 0) { return str_replace('/' . RELATIVE_PLUGIN_PATH, '/plugins', $content); } else { return str_replace('/' . THEME_PATH, '', $content); } } if (!is_multisite() && !is_child_theme()) { if (current_theme_supports('rewrites')) { add_action('generate_rewrite_rules', 'roots_add_rewrites'); } if (!is_admin() && current_theme_supports('rewrites')) { $tags = array( 'plugins_url', 'bloginfo', 'stylesheet_directory_uri', 'template_directory_uri', 'script_loader_src', 'style_loader_src' ); add_filters($tags, 'roots_clean_urls'); } }
  5. Sorry about that! Here it is... <?php /* Plugin Name: Boon's Simple Social Sharing Plugin URI: https://github.com/mattberridge/Simple-Social-Sharing-Buttons Description: Super lightweight social sharing buttons (without counters) Author: built by Boon Author URI: http://builtbyboon.com */ function simple_social_sharing( $attr_twitter = null, $attr_items = null ) { // parse variables $twitter_account = $attr_twitter; $item_toggles = $attr_items; // get post content and urlencode it global $post; $browser_title_encoded = urlencode( trim( wp_title( '', false, 'right' ) ) ); $page_title_encoded = urlencode( get_the_title() ); $page_url_encoded = urlencode( get_permalink($post->ID) ); // create share items array $share_items = array (); // set each item $item_facebook = array( "class" => "facebook", "href" => "http://www.facebook.com/sharer.php?u={$page_url_encoded}&t={$browser_title_encoded}", "text" => "Share On Facebook" ); $item_twitter = array( "class" => "twitter", "href" => "http://twitter.com/share?text={$page_title_encoded}&url={$page_url_encoded}&via={$twitter_account}", "text" => "Twitter" ); $item_google = array( "class" => "google", "href" => "http://plus.google.com/share?url={$page_url_encoded}", "text" => "G+" ); // test whether to display each item if($item_toggles) { // explode into array $item_toggles_array = explode( ",", $item_toggles ); // set each item on or off $show_facebook = $item_toggles_array['0']; $show_twitter = $item_toggles_array['1']; $show_google = $item_toggles_array['2']; } else { $display_all_items = 1; } // form array of items set to 1 if( $show_facebook==1 || $display_all_items ) { array_push( $share_items, $item_facebook ); } if( $show_twitter==1 || $display_all_items) { array_push( $share_items, $item_twitter ); } if( $show_google==1 || $display_all_items) { array_push( $share_items, $item_google ); } // if one or more items if ( ! empty( $share_items ) ) { // create output $share_output = "<ul class=\"ss-share\">\n"; foreach ( $share_items as $share_item ) { $share_output .= "<li class=\"ss-share-item\">\n"; $share_output .= "<a class=\"ss-share-link ico-{$share_item['class']}\" href=\"{$share_item["href"]}\" rel=\"nofollow\" target=\"_blank\">{$share_item['text']}</a>\n"; $share_output .= "</li>\n"; } $share_output .= "</ul>"; // echo output echo $share_output; } } // add shortcode to output buttons function simple_social_sharing_shortcode( $atts, $content = null ) { // parse variables / set defaults extract( shortcode_atts( array( 'twitter' => '', 'display' => '1,1,1', ), $atts ) ); // output buttons ob_start(); simple_social_sharing( $twitter, $display ); $output_string = ob_get_contents(); ob_end_clean(); return force_balance_tags( $output_string ); } add_shortcode( 'simple-social-sharing', 'simple_social_sharing_shortcode' ); ?>
  6. Hi everyone! I have social network sharing buttons on my WordPress website. The problem is: When you click on them, they open in a window instead of a little pop-up box. With the original & modified code below, can you please tell me how to fix this? CURRENT CODE: (plugin code) // set each item $item_facebook = array( "class" => "facebook", "href" => "http://www.facebook.com/sharer.php?u={$page_url_encoded}&t={$browser_title_encoded}", "text" => "Share On Facebook" ); $item_twitter = array( "class" => "twitter", "href" => "http://twitter.com/share?text={$page_title_encoded}&url={$page_url_encoded}&via={$twitter_account}", "text" => "Twitter" ); $item_google = array( "class" => "google", "href" => "http://plus.google.com/share?url={$page_url_encoded}", "text" => "G+" ); FaceBook's Pop-Out Code, That I Don't Know How To Implement Into The Above! <a href="#" onclick=" window.open( 'https://www.facebook.com/sharer/sharer.php?u='+encodeURIComponent(location.href), 'facebook-share-dialog', 'width=626,height=436'); return false;"> Share On Facebook </a> Thank you for the help! - Jennifer
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.