Title: RobReg's Replies | WordPress.org

---

# RobReg

  [  ](https://wordpress.org/support/users/robreg/)

 *   [Profile](https://wordpress.org/support/users/robreg/)
 *   [Topics Started](https://wordpress.org/support/users/robreg/topics/)
 *   [Replies Created](https://wordpress.org/support/users/robreg/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/robreg/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/robreg/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/robreg/engagements/)
 *   [Favorites](https://wordpress.org/support/users/robreg/favorites/)

 Search replies:

## Forum Replies Created

Viewing 15 replies - 1 through 15 (of 29 total)

1 [2](https://wordpress.org/support/users/robreg/replies/page/2/?output_format=md)
[→](https://wordpress.org/support/users/robreg/replies/page/2/?output_format=md)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[MC4WP: Mailchimp for WordPress] Text Style Different for Phone Number](https://wordpress.org/support/topic/text-style-different-for-phone-number/)
 *  Thread Starter [RobReg](https://wordpress.org/support/users/robreg/)
 * (@robreg)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/text-style-different-for-phone-number/#post-10095206)
 * Hi Harish,
 * That’s worked perfectly, thanks a lot.
 * Cheers,
    Rob
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[ShareThis: Free Sharing Buttons and Tools] google speedtest has problems with share-this](https://wordpress.org/support/topic/google-speedtest-has-problems-with-share-this/)
 *  [RobReg](https://wordpress.org/support/users/robreg/)
 * (@robreg)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/google-speedtest-has-problems-with-share-this/#post-3035535)
 * Hi, looks correct to me. I made sure that it was inline with the rest of the 
   script tags. You could just add that charset in too but I don’t think it will
   make much different. I could be wrong, no harm in trying it.
 * I would look at the Google page insights tool and see what the critical path 
   is and what suggestions it comes up with. Maybe that will help you with some 
   suggestions on how to improve performance.
 * Rob
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[ShareThis: Free Sharing Buttons and Tools] google speedtest has problems with share-this](https://wordpress.org/support/topic/google-speedtest-has-problems-with-share-this/)
 *  [RobReg](https://wordpress.org/support/users/robreg/)
 * (@robreg)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/google-speedtest-has-problems-with-share-this/#post-3035533)
 * Hi Petra,
 * The way I did it was to go to Setting -> ShareThis from the control panel in 
   your WordPress dashboard. Scroll down the page to where it says “Click to modify
   other widget options”. Then add the following to it:
 * <script type=”text/javascript”>var __st_loadLate=true;</script>
 * I added that in between some of the other <script> tags.
 * How have you put the code in to your site? I have added it manually to mine, 
   in the single.php file so I could put it exactly where I wanted it.
 * Hope that helps,
    Rob
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[ShareThis: Free Sharing Buttons and Tools] google speedtest has problems with share-this](https://wordpress.org/support/topic/google-speedtest-has-problems-with-share-this/)
 *  [RobReg](https://wordpress.org/support/users/robreg/)
 * (@robreg)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/google-speedtest-has-problems-with-share-this/#post-3035530)
 * Hi,
 * It is a little disappointing because I think this plugin is really great. Clean,
   simple and pretty professional looking. Pity about the performance factors.
 * I added the bit of code they said to add above in the options for the plugin 
   from the options page and it seemed to help in my performance tests.
 * Would be great if this was sorted in an update though.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[ShareThis: Free Sharing Buttons and Tools] google speedtest has problems with share-this](https://wordpress.org/support/topic/google-speedtest-has-problems-with-share-this/)
 *  [RobReg](https://wordpress.org/support/users/robreg/)
 * (@robreg)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/google-speedtest-has-problems-with-share-this/#post-3035527)
 * Hello,
 * Has this been dealt with yet do you know? I’m seeing the same warnings as medium
   priority in my page site speed and I really want to optimize it. I will look 
   at the details provided here if there isn’t a fix yet.
 * Cheers,
    Rob
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[User Frontend: AI Powered Frontend Posting, User Directory, Profile, Membership & User Registration] [Plugin: WP User Frontend] Theme Altered by this string](https://wordpress.org/support/topic/plugin-wp-user-frontend-theme-altered-by-this-string/)
 *  [RobReg](https://wordpress.org/support/users/robreg/)
 * (@robreg)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/plugin-wp-user-frontend-theme-altered-by-this-string/#post-3128835)
 * An update on this is that I had a look at the wpuf.js file around line 108 which
   appears to be where the issue is and it seems to be in this piece of code:
 *     ```
       featImgUploader: function() {
                   if(typeof plupload === 'undefined') {
                       return;
                   }
   
                   if(wpuf.featEnabled !== '1') {
                       return;
                   }
   
                   var uploader = new plupload.Uploader(wpuf.plupload);
   
                   uploader.bind('Init', function(up, params) {
                       //$('#cpm-upload-filelist').html("<div>Current runtime: " + params.runtime + "</div>");
                       });
   
                   $('#wpuf-ft-upload-pickfiles').click(function(e) {
                       uploader.start();
                       e.preventDefault();
                   });
   
                   uploader.init();
       ```
   
 * Is there a problem with this piece of code?
 * Thanks,
    Rob
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[User Frontend: AI Powered Frontend Posting, User Directory, Profile, Membership & User Registration] [Plugin: WP User Frontend] Theme Altered by this string](https://wordpress.org/support/topic/plugin-wp-user-frontend-theme-altered-by-this-string/)
 *  [RobReg](https://wordpress.org/support/users/robreg/)
 * (@robreg)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/plugin-wp-user-frontend-theme-altered-by-this-string/#post-3128834)
 * Hello,
 * Did you find out a solution to this? I am getting a Javascript error on one of
   my pages:
 *     ```
       Uncaught TypeError: Cannot read property 'currentStyle' of null plupload.js:2
       g.getStyle plupload.js:2
       (anonymous function) plupload.html5.js:1
       g.extend.trigger plupload.js:2
       (anonymous function) plupload.js:2
       j.runtimes.Html5.j.addRuntime.init plupload.html5.js:1
       v plupload.js:2
       g.extend.init plupload.js:2
       WPUF_Obj.featImgUploader wpuf.js:108
       WPUF_Obj.init wpuf.js:14
       (anonymous function) wpuf.js:213
       l jquery.js:2
       c.fireWith jquery.js:2
       v.extend.ready jquery.js:2
       A
       ```
   
 * Anyone seen this?
 *   Forum: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
   
   In reply to: [Add Custom Field & Update it when FB like button clicked](https://wordpress.org/support/topic/add-custom-field-update-on-fb-like-click/)
 *  Thread Starter [RobReg](https://wordpress.org/support/users/robreg/)
 * (@robreg)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/add-custom-field-update-on-fb-like-click/#post-3375436)
 * Hello [@nathanssimpson](https://wordpress.org/support/users/nathanssimpson/),
 * Haha! I know how you feel, it can take a long time to get these things working.
   I’ll try to help you get it working. Here are some instructions:
 * Notes:
    1. I am using the WP-Clear theme (3.2)
    2. I wanted to order all category posts by the number of Facebook likes I have 
       the following two plugins: Ultimate Facebook (premium plugin [http://premium.wpmudev.org/project/ultimate-facebook/](http://premium.wpmudev.org/project/ultimate-facebook/)).
       I’m very sure that you can do it without this to be honest, but you’ll need 
       some way of getting all the Facebook stuff working. If you look on the Facebook
       developers site and use the set-up there it should work. Or, if you get a free
       Facebook plugin just so that the shortcodes for it to work that should be enough.
       And WP User Frontend ([http://wordpress.org/extend/plugins/wp-user-frontend/](http://wordpress.org/extend/plugins/wp-user-frontend/))
    3. On my website I allow logged in users (they can only log in with Facebook) to
       add posts – this is what Wp user front end does.
 * **Actions**
 * Get above two plugins installed and working. In order to get the Facebook likes
   part working I added a custom field to every new post. Because I didn’t want 
   to have to do it manually (because people can post any time of day or night),
   I modified the WP User Frontend plugin to add a new custom field when a new post
   was added. To do that, edit the wpuf-add-post.php file from within the plugin’s
   directory and add a new line just below the if ($post_id) { line, as below:
 *     ```
       if ( $post_id ) {
   
       	    //add mandatory FB likes custom field. Added by RJ
       	    add_post_meta( $post_id, 'fb_likes', '0', true );
       ```
   
 * That will add a new custom field called fb_likes every time a post is added but
   ONLY through the Wp User Frontend plugin. If you add new posts manually, you 
   should probably add it as well.
 * Next, add the code for a like button to your post (single.php). I think you can
   probably just use the Ultimate Facebook plugin but I haven’t tested that yet.
   Here is the Facebook button code and the code to capture when you get a click
   on the like button:
 * Put this at the top of single.php
 *     ```
       <html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://ogp.me/ns/fb#" >
   
       <div id="fb-root"></div>
       ```
   
 * Then you need to find a way of getting the post id. I used this:
 *     ```
       $vpostid = $post->ID; ?>
       ```
   
 * Next, add the Ajax code, the event capture and the FB like button code:
 *     ```
       <script>
       FB.Event.subscribe('edge.create',
   
       function(response) {
       jQuery.post("http://www.my-domain.com/fbtest.php", { category: <?php echo $vpostid; ?> } );
       }
       );
       </script>
   
       <fb:like send="true" width="450" show_faces="true" font="verdana"></fb:like>
       ```
   
 * You’ll notice in the above that there is a fbtest.php file. You will need to 
   create that, too. Here is the code I used:
 *     ```
       <?php
       require( './wp-load.php' );
       global $wpdb;
       $vcatid = $_POST['category'];
       $meta_val = get_post_meta($vcatid, 'fb_likes', true);
       $fbmetval = intval($meta_val);
       $fbmetval = $fbmetval + 1;
       update_post_meta($vcatid, 'fb_likes', $fbmetval);
       die();
       ?>
       ```
   
 * Finally, and this works if you want the posts to be ordered by the fb_likes custom
   field on the category sub-pages (not sure of the technical term for this…), add
   this code to index1.php:
 *     ```
       // Added by RJ for ordering by FB links custom field
       if (is_category()) {
   
       global $wp_query;
       $args = array_merge( $wp_query->query_vars, array( 'meta_key' => 'fb_likes', 'orderby' => 'meta_value' ) );
       query_posts( $args );
       }
       ```
   
 * You should add the above code just below this piece of existing code in index1.
   php:
 *     ```
       if (is_home() || is_page()) {
       	query_posts(array(
       		'post__not_in' =>  $do_not_duplicate,
       		'paged' => $paged
       	));
       }
       ```
   
 * Bear in mind that some of this might be specific to my theme. I am use WP-Clear
   by Solostream. I’ve not looked at any other themes before so I don;t know if 
   single.php, etc are common names and layouts for the files.
 * Let me know how you get on. Good luck!
    Rob
 *   Forum: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
   
   In reply to: [Add Custom Field & Update it when FB like button clicked](https://wordpress.org/support/topic/add-custom-field-update-on-fb-like-click/)
 *  Thread Starter [RobReg](https://wordpress.org/support/users/robreg/)
 * (@robreg)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/add-custom-field-update-on-fb-like-click/#post-3375397)
 * Evening BC,
    Thanks for replying. I like what you are saying there about not 
   having to have the separate php file, it’s a much more elegant way of dealing
   with it.
 * However, I have it all working now 🙂 After 10+ hours of trying! The problem 
   with my original code for the Ajax part was that I was using $.post. When I changed
   it to jquery.post it started posting through. I was so happy to spot that…
 * So, I now have my final, albeit slightly hacky, way of doing it:
 * 1. Add custom field automatically with the post when it’s added by a user
    2.
   Capture the FB like button click and use Ajax to send the information to the 
   php page which updates the custom field and adds 1 to it. 3. Order my posts in
   WordPress by the number of FB likes.
 * Job done! Well, one of them…On to the next one.
 * Thanks again for all your help, bc, I have learned a few things from what you
   have said and your guidance helped me a lot.
 * Cheers,
    Rob
 *   Forum: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
   
   In reply to: [Add Custom Field & Update it when FB like button clicked](https://wordpress.org/support/topic/add-custom-field-update-on-fb-like-click/)
 *  Thread Starter [RobReg](https://wordpress.org/support/users/robreg/)
 * (@robreg)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/add-custom-field-update-on-fb-like-click/#post-3375380)
 * Cheers bc, thank you for the information. I totally get the keeping the javascript
   code separate from the php. I imagine that it helps a lot when you have a large
   scale project with a lot of code to manage, then you can just reference code 
   snippets and it will look a lot cleaner.
 * I assumed that I needed the number in quotes because that’s the only way I could
   get it to work but I think I found another issue…I’m pretty sure that something
   is wrong with my fbtest.php because it won’t use the hard-coded value. I’ve looked
   around all last night but it still looks correct to me. Is there something obviously
   wrong with it:
 *     ```
       <?php
       /** Set up WordPress environment */
       require_once( './wp-load.php' );
       require_once( './wp-admin/admin-ajax.php' );
   
       $vcatid = $_POST["category"];
       $meta_val = get_post_meta($vcatid, 'fb_likes', true);
   
       $fbmetval = intval($meta_val);
       $fbmetval = $fbmetval + 1;
   
       update_post_meta($vcatid, 'fb_likes', $fbmetval);
       ?>
       ```
   
 * Thanks again for all your help. I feel like I’m making progress and I’m almost
   there with this!
 * Thanks,
    Rob
 *   Forum: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
   
   In reply to: [Add Custom Field & Update it when FB like button clicked](https://wordpress.org/support/topic/add-custom-field-update-on-fb-like-click/)
 *  Thread Starter [RobReg](https://wordpress.org/support/users/robreg/)
 * (@robreg)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/add-custom-field-update-on-fb-like-click/#post-3375366)
 * Bit stuck again. I can get it working if I hard code the values but now when 
   passing a variable to it. I think I must be specifying it incorrectly:
 *     ```
       <script type="text/javascript">
       FB.Event.subscribe('edge.create',
           function(response) {
               $.post("http://www.my_domain.com/fbtest.php", { category: ".$vpostid.$" } );
           }
       );
       ```
   
 * I’ve tried quite a few different combinations for the category part, such as:
 * `$.post("http://www.my_domain.com/fbtest.php", { category: $vpostid } );`
 * But the only one which works is when I hard code the category and have it like
   this:
 * `$.post("http://www.my_domain.com/fbtest.php", { category: "845"} );`
 * So I guess the question is how to I wrap my variable in double quotes.
 *   Forum: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
   
   In reply to: [Add Custom Field & Update it when FB like button clicked](https://wordpress.org/support/topic/add-custom-field-update-on-fb-like-click/)
 *  Thread Starter [RobReg](https://wordpress.org/support/users/robreg/)
 * (@robreg)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/add-custom-field-update-on-fb-like-click/#post-3375364)
 * I’ve got it working now 😀
 * I had to add a call to this to get it working:
 * require_once(‘./wp-load.php’);
 * Happy with that!
    Thanks again, Rob
 *   Forum: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
   
   In reply to: [Add Custom Field & Update it when FB like button clicked](https://wordpress.org/support/topic/add-custom-field-update-on-fb-like-click/)
 *  Thread Starter [RobReg](https://wordpress.org/support/users/robreg/)
 * (@robreg)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/add-custom-field-update-on-fb-like-click/#post-3375363)
 * P.S. The get_post_meta call in fbtest.php doesn’t work, it errors with:
 * `Fatal error: Call to undefined function get_post_meta()`
 * But it works when I use it on an existing page. I assume it’s because I need 
   to do some kind of include at the top of the page but I’m not sure what to include
   as none of the other php files in my theme have any calls like that.
 *   Forum: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
   
   In reply to: [Add Custom Field & Update it when FB like button clicked](https://wordpress.org/support/topic/add-custom-field-update-on-fb-like-click/)
 *  Thread Starter [RobReg](https://wordpress.org/support/users/robreg/)
 * (@robreg)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/add-custom-field-update-on-fb-like-click/#post-3375362)
 * Hi bcworkz,
 * Thanks for the information. I’ve been looking at this for about 4 hours today
   and I’m making progress. So far I have managed to get the custom field added 
   to each post automatically, which is good. Now I have this code on a page in 
   my site:
 *     ```
       <fb:like send="true" width="450" show_faces="true"></fb:like>
   
       <script type="text/javascript">
       FB.Event.subscribe('edge.create',
           function(response) {
               $.post("fbtest.php", category: 845 );
           }
       );
       </script>
       ```
   
 * And this is the contents of fbtest.php:
 *     ```
       <?php
   
       $vcatid = $_POST["category"];
   
       $meta_val = get_post_meta(845, 'fb_likes', true);
   
       $fbmetval = intval($meta_val);
       $fbmetval = fbmetval + 1;
   
       update_post_meta(845, 'fb_likes', $fbmetval);
   
       ?>
       ```
   
 * I’ve hard coded the post ids just to see if I can get it working first, then 
   I’ll switch them to variables later. This doesn’t work though. I’m trying to 
   see if it’s even being called from the Ajax call but I’m still trying to work
   out how to do that…
 * Am I heading down the correct route?
 * Thanks for your help,
    Rob
 *   Forum: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
   
   In reply to: [Add Custom Field & Update it when FB like button clicked](https://wordpress.org/support/topic/add-custom-field-update-on-fb-like-click/)
 *  Thread Starter [RobReg](https://wordpress.org/support/users/robreg/)
 * (@robreg)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/add-custom-field-update-on-fb-like-click/#post-3375359)
 * Thank you for your response, bcworkz.
 * I will attempt to have a look at the source code but I’m no programmer. To be
   a little more specific, this is what I am trying to get to work at the moment:
   I want to update the custom field in the database when a user clicks the like
   button. It seems that this is how to do it:
 * FB.Event.subscribe(‘edge.create’,
    function(response) { alert(‘You liked the 
   URL: ‘ + response); } );
 * Is there a way I can keep the user on the same page and make that “alert” part
   update the custom field? Doing it this way I assume is not the most scale-able
   solution because every like will cause a database update, and I don’t even know
   if this is possible because it’s javascript which is creating the event (client
   side) and I want to issue some php execution to the DB?
 * Thanks,
    Rob

Viewing 15 replies - 1 through 15 (of 29 total)

1 [2](https://wordpress.org/support/users/robreg/replies/page/2/?output_format=md)
[→](https://wordpress.org/support/users/robreg/replies/page/2/?output_format=md)