184 private $_wpxPluginClassLoadingPath;
224 parent::__construct(
$file );
232 $this->_wpxPluginsClassesLoadingPath = array();
233 spl_autoload_extensions(
'.php' );
234 spl_autoload_register( array( $this,
'autoloadEnvironment' ) );
237 $this->path = trailingslashit( plugin_dir_path(
$file ) );
238 $this->classesPath = $this->path .
'classes/';
239 $this->databasePath = $this->path .
'database/';
242 $this->url = trailingslashit( plugin_dir_url(
$file ) );
243 $this->assetsURL = $this->url .
'assets/';
244 $this->cssURL = $this->assetsURL .
'css/';
245 $this->imagesURL = $this->cssURL .
'images/';
246 $this->javascriptURL = $this->assetsURL .
'js/';
249 $this->folderName = trailingslashit( basename( dirname(
$file ) ) );
252 $this->pluginBasename = plugin_basename(
$file );
255 $this->slug = sanitize_title( $this->name );
259 $this->
urlAjax = self::urlAjax();
262 $this->log =
new WPDKWatchDog( $this->path );
265 add_action(
'init', array( $this,
'_init' ) );
268 add_action(
'admin_init', array( $this,
'admin_init' ) );
271 register_activation_hook(
$file, array( $this,
'activation' ) );
272 register_deactivation_hook(
$file, array( $this,
'deactivation' ) );
288 add_action(
'widgets_init', array( $this,
'widgets' ) );
300 return ( isset( $_SERVER[
'HTTPS'] ) &&
'on' == $_SERVER[
'HTTPS'] ) ?
'https://' :
'http://';
312 return admin_url(
'admin-ajax.php', self::protocol() );
325 $port = (
'80' != $_SERVER[
'SERVER_PORT'] ) ?
':' . $_SERVER[
'SERVER_PORT'] :
'';
328 if ( isset( $_SERVER[
'HTTP_X_FORWARDED_HOST'] ) ) {
329 $host = $_SERVER[
'HTTP_X_FORWARDED_HOST'];
330 if ( !empty( $host ) ) {
331 $elements = explode(
',', $host );
332 $host = trim( end( $elements ) );
336 $host = $_SERVER[
'HTTP_HOST'];
337 if ( empty( $host ) ) {
338 $host = $_SERVER[
'SERVER_NAME'];
339 if ( empty( $host ) ) {
340 $host = !empty( $_SERVER[
'SERVER_ADDR'] ) ? $_SERVER[
'SERVER_ADDR'] :
'';
345 return sprintf(
'%s%s%s%s',
$protocol, $host, $port, $_SERVER[
'REQUEST_URI'] );
370 if ( is_string( $sLoadingPath ) && is_string( $mClassName ) && !empty( $mClassName ) ) {
371 $sClassNameLowerCased = strtolower( $mClassName );
372 $this->_wpxPluginClassLoadingPath[$sClassNameLowerCased] = $sLoadingPath;
376 elseif ( is_array( $sLoadingPath ) ) {
377 foreach ( $sLoadingPath as
$path => $classes ) {
378 if ( is_string( $classes ) ) {
379 $class_name = strtolower( $classes );
380 $this->_wpxPluginClassLoadingPath[$class_name] =
$path;
384 elseif ( is_array( $classes ) ) {
385 foreach ( $classes as $class_name ) {
386 $class_name = strtolower( $class_name );
387 $this->_wpxPluginClassLoadingPath[$class_name] =
$path;
411 $sClassNameLowerCased = strtolower( $sClassName );
412 if ( isset( $this->_wpxPluginClassLoadingPath[$sClassNameLowerCased] ) ) {
413 require_once( $this->_wpxPluginClassLoadingPath[$sClassNameLowerCased] );
425 load_plugin_textDomain( $this->textDomain,
false, $this->textDomainPath );
441 load_plugin_textDomain( $this->textDomain,
false, $this->textDomainPath );
458 elseif( !in_array( $GLOBALS[
'pagenow'], array(
'wp-login.php',
'wp-register.php' ) ) ) {
565 _deprecated_function( __CLASS__ .
'::' . __FUNCTION__,
'1.2.0',
'preferences()' );
573 _deprecated_function( __CLASS__ .
'::' . __FUNCTION__,
'1.4.20' );
744 if ( !is_null( $this->file ) ) {
747 if ( !function_exists(
'get_plugin_data' ) ) {
748 require_once( ABSPATH .
'wp-admin/includes/plugin.php' );
750 $result = get_plugin_data( $this->file,
false );
752 $this->
id = plugin_basename( $this->file );
753 $this->author = $result[
'Author'];
754 $this->authorURI = $result[
'AuthorURI'];
755 $this->authorName = $result[
'AuthorName'];
756 $this->description = $result[
'Description'];
757 $this->icon = sprintf(
'%s%s%s',
WPDKWordPressPaths::pluginsURL(), trailingslashit( basename( dirname( $this->file ) ) ),
'assets/css/images/logo-64x64.png' );
758 $this->name = $result[
'Name'];
759 $this->network = $result[
'Network'];
760 $this->pluginURI = $result[
'PluginURI'];
761 $this->textDomain = $result[
'TextDomain'];
762 $this->textDomainPath = trailingslashit( basename( dirname( $this->file ) ) ) . $result[
'DomainPath'];
763 $this->title = $result[
'Title'];
764 $this->version = $result[
'Version'];
765 $this->
active = is_plugin_active( $this->
id );
799 _deprecated_function( __CLASS__ .
'::' . __FUNCTION__,
'1.1.4',
'get_file_data()' );
802 if( empty( $aWPXHeaders )) {
807 $sContent = file_get_contents( $this->file, FALSE, NULL, 0, 8192);
808 if( FALSE === $sContent ) {
813 $sContent = str_replace(
"\r",
"\n", $sContent );
816 foreach ( $aWPXHeaders as $sKey => $sValue ) {
817 if ( preg_match(
'/^[ \t\/*#@]*' . preg_quote( $sKey,
'/' ) .
':(.*)$/mi', $sContent, $aMatch ) && $aMatch[1] ) {
818 $aWPXHeaders[ $sKey ] = _cleanup_header_comment( $aMatch[1] );
821 $aWPXHeaders[ $sKey ] =
'';
870 private $_activePlugins;
879 private function __construct()
882 $this->_initPluginsLists();
890 private function _init()
892 $this->_activePlugins = array();
893 $this->plugins = array();
894 $this->wpxPlugins = array();
902 private function _initPluginsLists()
905 if ( empty( $this->plugins ) ) {
908 $all_plugins = get_plugins();
911 $this->_activePlugins = get_option(
'active_plugins' );
913 foreach ( $all_plugins as $key => $value ) {
914 $file = sprintf(
'%s%s', trailingslashit( WP_PLUGIN_DIR ), $key );
918 if (
'https://wpxtre.me' == $value[
'PluginURI'] ) {
919 $this->wpxPlugins[$key] = $plugin;
924 $this->plugins[$key] = $plugin;
937 static $instance = null;
938 if ( is_null( $instance ) ) {
976 public static function homeURL( $blog_id = null, $path =
'', $scheme = null )
978 return trailingslashit( get_home_url( $blog_id, $path, $scheme ) );
992 public static function adminURL( $blog_id = null, $path =
'', $scheme =
'admin' )
994 return trailingslashit( get_admin_url( $blog_id, $path, $scheme ) );
1008 return trailingslashit( includes_url( $path ) );
1024 return trailingslashit( plugins_url( $path, $plugin ) );