コード例 #1
0
/**
 * Begins execution of the plugin.
 *
 * Since everything within the plugin is registered via hooks,
 * then kicking off the plugin from this point in the file does
 * not affect the page life cycle.
 *
 * @since    1.0.0
 */
function run_auto_menu_from_pages()
{
    // Pass main plugin file through to plugin class for later use.
    $args = array('plugin_file' => __FILE__);
    $plugin = Auto_Menu_From_Pages::get_instance($args);
    $plugin->run();
}
 /**
  * Run plugin deactivation actions.
  *
  * @since    1.0.0
  */
 public static function deactivate()
 {
     // Get plugin and admin instances.
     $plugin = Auto_Menu_From_Pages::get_instance();
     $plugin_admin = Auto_Menu_From_Pages_Admin::get_instance($plugin);
     // Force destruction of auto menu on deactivation.
     // $plugin_admin->destroy_auto_menu();
 }
 /**
  * Get the ID of the auto menu object.
  *
  * @since     1.0.0
  *
  * @return    int    ID of the auto menu.
  */
 public function get_auto_menu_id()
 {
     $auto_menu_name = $menu_name = $this->plugin->get('menu_name');
     $auto_menu = get_term_by('name', $auto_menu_name, 'nav_menu');
     // Exit if the menu doesn't exist (edge case after deactivation)
     if (empty($auto_menu->term_id)) {
         return false;
     }
     return $auto_menu->term_id;
 }
 /**
  * Run plugin activation actions.
  *
  * @since    1.0.0
  */
 public static function activate()
 {
     // Get plugin and admin instances.
     $plugin = Auto_Menu_From_Pages::get_instance();
     $plugin_admin = Auto_Menu_From_Pages_Admin::get_instance($plugin);
     // Force initial menu creation/update run.
     $plugin_admin->create_auto_menu();
     $plugin_admin->maybe_sync_auto_menu(true);
     // Add plugin activation option for redirect.
     add_option($plugin->get('slug') . '_activated', true);
 }
 /**
  * Filter widget instance.
  *
  * For use with Simple Section Nav plugin to incorporate excluded pages.
  *
  * @since    1.2.0
  *
  * @param    array        $instance    The current widget instance's settings.
  * @param    WP_Widget    $widget      The current widget instance.
  * @param    array        $args        An array of default widget arguments.
  */
 public function filter_widget_instance($instance, $widget, $args)
 {
     // Setup array of ID's of widgets to filter.
     $widgets_to_filter = array('simple-section-nav');
     // Only proceed if we're filtering intended widgets.
     if (!in_array($widget->id_base, $widgets_to_filter)) {
         return $instance;
     }
     // Get comma-separated list of excluded page ID's.
     $exclude_ids_array = $this->plugin->get_excluded_page_ids();
     $exclude_ids = implode(',', $exclude_ids_array);
     // Filter in excluded page ID's.
     $instance['exclude'] = $exclude_ids;
     return $instance;
 }
コード例 #6
0
 /**
  * Creates or returns an instance of this class.
  *
  * @return    Auto_Menu_From_Pages    A single instance of this class.
  */
 public static function get_instance($args = array())
 {
     if (null == self::$instance) {
         self::$instance = new self($args);
     }
     return self::$instance;
 }