In the code below, shouldn't the hooks under the bottom two functions be placed inside the constructor?
class The_Class {
private static $instance = null;
public static function get_instance() {
return null == self::$instance ? self::$instance = new self : self::$instance;
}
function __construct() {
if ( is_admin() ) {
add_filter( 'wp_edit_nav_menu_walker', array( &$this, 'edit_nav_menu_walker' ) );
add_filter( 'wp_nav_menu_item_custom_fields', array( &$this, 'option' ), 12, 2 );
add_action( 'wp_update_nav_menu_item', array( &$this, 'update_option_text' ), 10, 3 );
add_action( 'wp_update_nav_menu_item', array( &$this, 'update_option_hide_show' ), 10, 3 );
add_action( 'delete_post', array( &$this, 'remove_visibility_meta' ), 1, 3 );
} else {
add_filter( 'wp_get_nav_menu_items', array( &$this, 'set_visibility' ), 10, 3 );
add_action( 'init', array( &$this, 'clear_gantry_menu_cache' ) );
}
}
function deactivate_other_lsmi() {
if ( is_plugin_active( 'lsmi-by-city/LSMI_City.php' ) ) {
deactivate_plugins( 'lsmi-by-city/LSMI_City.php' );
}
}
add_action( 'admin_init', array( &$this, 'deactivate_other_lsmi' ) );
function lsmi_load_admin_script() {
wp_register_style( 'chosencss', plugins_url( 'assets/chosen.css', __FILE__ ), true, '', 'all' );
wp_register_script( 'chosenjs', plugins_url( 'assets/chosen.jquery.js', __FILE__ ), array( 'jquery' ), '', true );
wp_enqueue_style( 'chosencss' );
wp_enqueue_script( 'chosenjs' );
}
add_action( 'admin_enqueue_scripts', array( &$this, 'lsmi_load_admin_script' ) );
}
_construct
of aClass
. Having them strewn throughout the object is acceptable, but just a bit messier from anOOP
viewpoint.