run_on_activation(); if ( function_exists( 'is_multisite' ) && is_multisite() ) { // check if it is a network activation - if so, run the activation function for each blog id if ( $network_wide ) { // Get all blog ids $blogids = $wpdb->get_col( "SELECT blog_id FROM {$wpdb->base_prefix}blogs" ); foreach ( $blogids as $blog_id ) { switch_to_blog( $blog_id ); $this->run_for_site(); restore_current_blog(); } return; } } $this->run_for_site(); } /** * deactivate the plugin * @since 1.5 */ public function dewplayer_deactivate( $network_wide ) { global $wpdb; if ( function_exists( 'is_multisite' ) && is_multisite() ) { // check if it is a network activation - if so, run the activation function for each blog id if ( $network_wide ) { // Get all blog ids $blogids = $wpdb->get_col( "SELECT blog_id FROM {$wpdb->base_prefix}blogs" ); foreach ( $blogids as $blog_id ) { switch_to_blog( $blog_id ); $this->run_on_deactivation(); restore_current_blog(); } return; } } // for non-network sites only $this->run_on_deactivation(); } /** * Runs on plugin uninstall. * a static class method or function can be used in an uninstall hook * @since 1.5 */ public static function dewplayer_uninstall() { global $wpdb; DWP_Plugin_Init::run_on_uninstall(); if ( function_exists( 'is_multisite' ) && is_multisite() ) { //Get all blog ids; foreach them and call the uninstall procedure on each of them $blog_ids = $wpdb->get_col( "SELECT blog_id FROM {$wpdb->base_prefix}blogs" ); //Get all blog ids; foreach them and call the install procedure on each of them if the plugin table is found foreach ( $blog_ids as $blog_id ) { switch_to_blog( $blog_id ); DWP_Plugin_Init::delete_for_site(); restore_current_blog(); } return; } DWP_Plugin_Init::delete_for_site(); } /** * Called on activation. * Creates the site_options (required for all the sites in a multi-site setup) * If the current version doesn't match the new version, runs the upgrade * @since 1.5 */ private function run_on_activation() { $plugin_options = get_site_option( 'dwp_info' ); if ( false === $plugin_options ) { $dwp_info = array( 'version' => DWP_VERSION, 'db_version' => DWP_DB_VERSION ); update_site_option( 'dwp_info', $dwp_info ); } elseif ( DWP_VERSION != $plugin_options['version'] ) { $this->run_on_upgrade(); } } /** * Run on deactivation * @since 1.5 */ private function run_on_deactivation() { } /** * Called on activation. * Creates the options and DB (required by per site) * @since 1.5 */ private function run_for_site() { $default_option = array( 'max_rows' => '', 'table_width' => '', 'header_height' => '', 'row_height' => '', 'table_header_color' => '', 'primary_row_color' => '', 'alt_row_color' => '', 'show_no_column' => '1', 'show_size_column' => '1', 'show_duration_column' => '1', 'header_name_for_no' => 'No', 'header_name_for_name' => 'Name', 'header_name_for_player' => 'Play', 'header_name_for_size' => 'Size', 'header_name_for_duration' => 'Length', 'header_name_for_download' => 'Download', 'download_img' => DWP_URL . 'img/download.png', 'img_preview' => '', ); if ( has_filter( 'dew_default_display_options') ) { $default_option = apply_filters( 'dew_default_display_options', $default_option ); } if ( ! get_option( 'dew_display_options' ) ) { update_option( "dew_display_options", $default_option ); } } /** * Called on uninstall - deletes site_options * @since 1.5 */ private static function run_on_uninstall() { if ( ! defined( 'ABSPATH' ) && ! defined( 'WP_UNINSTALL_PLUGIN' ) ) exit(); delete_site_option( 'dwp_info' ); } /** * Called on uninstall - deletes site specific options * @since 1.5 */ private static function delete_for_site() { delete_option( 'dew_display_options' ); } /** * called on upgrade. checks the current version and applies the necessary upgrades from that version onwards * @since 1.5 */ public function run_on_upgrade() { $plugin_options = get_site_option( 'dwp_info' ); $dwp_info = array( 'version' => DWP_VERSION, 'db_version' => DWP_DB_VERSION ); update_site_option( 'dwp_info', $dwp_info ); } /** * Create/Register menu items for the plugin. * @since 1.5 */ public function register_menu_pages() { // top level menu for Workflows add_menu_page( __( 'Advanced Dewplayer', 'oasisworkflow' ), __( 'Advanced Dewplayer', 'oasisworkflow' ), 'manage_options', 'dew_player_options', array( $this, 'dwp_setting_page' ) ); } /* * Dewplayer Settings page * @since 1.5 */ public function dwp_setting_page() { $dwp_settings = new dwp_Settings(); $dwp_settings->dew_admin_settings(); } /** * Load all the classes - as part of init action hook * @since 1.5 */ public function load_all_classes() { /* * Settings classes */ if ( ! class_exists( 'dwp_Settings' ) ) { include( DWP_PATH . 'includes/class-dwp-settings.php' ); } /* * Service classes */ if ( ! class_exists( 'DWP_Service' ) ) { include( DWP_PATH . 'includes/class-dwp-service.php' ); } } /** * Enqueue css and js files * @since 1.5 */ public function dew_options_enqueue_scripts( $page ) { wp_register_script( 'dew-upload', DWP_URL . 'js/upload.js', array('jquery','media-upload','thickbox'), DWP_VERSION ); wp_enqueue_script('jquery'); wp_enqueue_script('thickbox'); wp_enqueue_style('thickbox'); wp_enqueue_script('media-upload'); wp_enqueue_script('dew-upload'); if ( function_exists('get_current_screen') ) { if ( $this->is_dew_screen() ) { wp_enqueue_style( 'dew-css', DWP_URL . 'css/dew-design.css', false, DWP_VERSION, 'screen' ); } } else if ( isset( $_GET['page'] ) && ( $_GET['page'] == 'dew_player_options' ) ) { wp_enqueue_style( 'dew-css', DWP_URL . 'css/dew-design.css', false, DWP_VERSION, 'screen' ); } else {} } /** * @return boolean * @since 1.5 */ public function is_dew_screen() { $screen = get_current_screen(); if (is_object($screen) && $screen->id == 'toplevel_page_dew_player_options') { return true; } else { return false; } } } // initialize the plugin $dwp_plugin_init = new DWP_Plugin_Init(); ?>