How to execute add_action() function from custom plugin to Crontrol plugin or do_action()?

I didn’t call the class yet, this code is now working class Scheduler { public $setup; public static $instance; public function __construct() { self::$instance =& $this; add_action(‘scheduler’, [$this, ‘etf_scheduler_func’]); } public function etf_scheduler_func() { $this->setup = new Setup(); $this->setup->set_table(); } public static function &get_instance() { if ( ! isset( self::$instance ) ) self::$instance = new … Read more

Retrieve IDs from custom field, count and display results differently according to count

I answer to myself, since this code is working better (previous had an issue) and also I removed a useless “for”: echo ‘<ul class=”related-content”>’; $count = 0; foreach(get_field(‘related_content’) as $post_object) : $count++; if ($count > 0 && $count < 4 ) { printf(‘<li class=”large”><a target=”_blank” title=”‘.get_the_title($post_object->ID).'” href=”‘.get_permalink($post_object->ID).'”><span style=”display: block” title=”‘.get_the_title($post_object->ID).'”>’.get_the_post_thumbnail($post_object->ID, ‘small’).'</span><span class=”thumb-title”>’.get_the_title($post_object->ID).'</span></a></li>’); } elseif ($count … Read more

How do I create Widget within plugin that uses its own class?

There’s no need to nest classes (and you can’t anyway), you just create a new instance of the class. The code below would automatically call the My_Widget class to create a widget based on your existing code. Class plugin_name { // Call the widget class public function __construct(){ $this->widget = new My_Widget(); $this->widget->getWidget(); } } … Read more

private functions in plugins

Well, it is not possible, I guess. If you define function in global scope, then it is visible for all code. The only way to make it private for plugin is to use OOP (and it’s recommended way of writing plugins). You can rename this function, but it won’t solve your problem in the long … Read more

Using Geo Data Store Plugin Code

I deleted the Geo Data Store plugin and reinstalled, in which my code worked upon refresh. I was able to use the functions from the plugin and so on. I casted as an array so as to use the output in my wp_query arguments $sc_gds = new sc_GeoDataStore(); $ids = (array) $sc_gds->getPostIDsOfInRange( $type, $radius, $lat, … Read more