plugin_file = $plugin_file; $this->slug = basename($plugin_file); $this->plugin_path = dirname($plugin_file) . '/'; $this->plugin_url =plugin_dir_url($plugin_file); $this->hook_general_functions(); if($this->get_plugin_slug()=='' || $this->in_option_page()) { $this->hook_styles_and_scripts(); } } /* Set the object's parent cf to access all objects ------------- */ public function set_cf($cf) { $this->cf=$cf; $this->request= call_user_func(array($cf, 'get_request')); $this->options= call_user_func(array($cf, 'get_options')); //$this->request = $cf::get_request(); //$this->options = $cf::get_options(); } /* there_is_cache --------------------------------------------- */ public function there_is_cache() { $plugins=get_site_option( 'active_plugins' ); if(is_array($plugins)){ foreach($plugins as $the_plugin) { if (stripos($the_plugin,'cache')!==false) { return $the_plugin; } } } return ''; } /* search_plugins --------------------------------------------- */ public function search_plugins($keyword,$skip='') { $plugins=get_site_option( 'active_plugins' ); if(is_array($plugins)){ foreach($plugins as $the_plugin) { $phpfile = substr( $the_plugin, strrpos( $the_plugin, '/' )+1 ); $phpfile = explode(".", $phpfile); $phpfile = $phpfile[0]; if (stripos($phpfile,$keyword)!==false && $phpfile!=$skip) { return $phpfile; } }} return ''; } /* there_is_plugin --------------------------------------------- */ public function there_is_plugin($plugin) { $plugins=get_site_option( 'active_plugins' ); if(is_array($plugins)){ foreach($plugins as $the_plugin){ $phpfile = substr( $the_plugin, strrpos( $the_plugin, '/' )+1 ); $phpfile = explode(".", $phpfile); $plugin_name = $phpfile[0]; if ($plugin_name==$plugin) { return true; } } } return false; } /* get_plugin_path --------------------------------------------- */ public function get_plugin_path() { return $this->plugin_path; } /* get plugin slug -------------------------------------------- */ public function get_plugin_slug() { return $this->slug; } /* in_option_page -------------------------------------------- */ public function in_option_page() { return ($this->get_plugin_slug()!='' && $this->request->get('page')==$this->get_plugin_slug()); } /* get plugin slug -------------------------------------------- */ public function get_plugin_file() { return $this->plugin_file; } /* get_plugin_url --------------------------------------------- */ public function get_plugin_url() { return $this->plugin_url; } /* get home path ---------------------------------------------- */ public function get_home_path() { $home = set_url_scheme( get_site_option( 'home' ), 'http' ); $siteurl = set_url_scheme( get_site_option( 'siteurl' ), 'http' ); if ( ! empty( $home ) && 0 !== strcasecmp( $home, $siteurl ) ) { $wp_path_rel_to_home = str_ireplace( $home, '', $siteurl ); /* $siteurl - $home */ $pos = strripos( str_replace( '\\', '/', $_SERVER['SCRIPT_FILENAME'] ), trailingslashit( $wp_path_rel_to_home ) ); $home_path = substr( $_SERVER['SCRIPT_FILENAME'], 0, $pos ); $home_path = trailingslashit( $home_path ); } else { $home_path = ABSPATH; } return str_replace( '\\', '/', $home_path ); } /* show_message ------------------------------------------------------ */ public function hook_message($msgtxt,$type='') { $msg = $msgtxt; if($type=='error' || $type=='danger') { $msg = '
' . $msgtxt . '
' . $msgtxt . '
' . $msgtxt . '
' . $msgtxt . '
' . $msgtxt . '