Conditionally loading Facebook PHP SDK in shortcode

You can try to use the_posts filter to search for you shortcode and require the sdk, something like this: function has_my_FB_shortcode($posts) { if ( empty($posts) ) return $posts; $found = false; foreach ($posts as $post) { if ( stripos($post->post_content, ‘[my_shortcode’) ){ $found = true; break; } } if ($found) require(‘path/to/facebook_sdk.php’); return $posts; } add_action(‘the_posts’, ‘has_my_FB_shortcode’);

Check if page/post has any anchors that link to an image jpg/gif/png

This method has worked in the past for checking if a shortcode exists on a page. You will have to test it and see if it fires in time to enqueue the javascript> add_filter(‘the_posts’, ‘c3_image_check’); function c3_image_check($posts){ if (empty($posts)) return $posts; $img_found = false; foreach ($posts as $post) { if (stripos($post->post_content, ‘<img src=”https://wordpress.stackexchange.com/questions/53585/)) { $img_found … Read more

Second Navigation inside header

Best is always subjective, however, I’d put it in the following manner to have better control and better arrangement of my templates: A structure to have granular control: First, I’d create a new folder, e.g. template-parts in my theme and then inside that, another folder e.g. navigation (to have separate template parts in different folders). … Read more

Closest thing to an is_widget() tag?

Well, if you insist using get_template_part, the only solution I see is to define a global variable in your widget’s widget() function, and set it to true or something. After you call get_template_part in your widget, set this variable to false. Within your template check for that variable, and if it’s true, it means you … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)