Check if a class exists within a method
You should use is_plugin_active() method to check if a certain plugin is activated. The class Facebook_WP will still exists even you deactivate the plugin.
You should use is_plugin_active() method to check if a certain plugin is activated. The class Facebook_WP will still exists even you deactivate the plugin.
Ajax Request not coming back to class
The root of your problem is not object oriented programming, but a fundamental misunderstanding about how PHP handles requests. If this were a Java or a Node application for example, you would start the application on the server, and it would recieve requests, and respond. It’s a continuous active program. As a result, you can … Read more
I question the wisdom of extending a class from another plugin. You have no idea what will happen next time that other plugin gets updated. However, generally speaking you can control when in a hook “queue” a function runs by passing a third parameter– a priority. So pass a priority high enough and your function … Read more
Once you said is you first time using OOP, I want to say: stop using & before $this: PHP4 died long time ago. Second tip, don’t use global variables, if you can. I know that function like wp_get_current_user use global variable internally, but I hope that in future it will not be so anymore, however … Read more
You need to create a new instance of the class so that your constructor is called and your actions are registered. e.g. you need to add something like $test = new PR_Test; below the definition of PR_Test.
Your proposal is OK – you can see this in action even in the WordPress itself. See admin-ajax.php where you can find this piece of code: // Register core Ajax calls. if ( ! empty( $_GET[‘action’] ) && in_array( $_GET[‘action’], $core_actions_get ) ) add_action( ‘wp_ajax_’ . $_GET[‘action’], ‘wp_ajax_’ . str_replace( ‘-‘, ‘_’, $_GET[‘action’] ), 1 … Read more
The issue is you are overriding the entire tax_query. When you go to the UK category archive, tax query is set to have the same thing you have for International, but you are nuking the current query. Here is the solution: … $tax_query = $query->get(‘tax_query’); $tax_query[‘relation’] = ‘OR’; // puts the item at the beginning … Read more
You don’t have to declare the constructor public, just the action hook function. Example: <?php /* Plugin Name: Singleton Action */ class Singleton_Demo { /** * @static $instance Objekt * @access private; */ private static $_instance = NULL; protected function __construct() {} private final function __clone() {} public static function getInstance() { if ( self::$_instance … Read more
Try this function: url_to_postid( $url ); The WordPress codex is your friend. A quick Google search could have provided the answer.