public static function getScriptData($sPathOrContent, $sType = 'plugin', $aDefaultHeaderKeys = array())
 {
     $_aHeaderKeys = $aDefaultHeaderKeys + array('sName' => 'Name', 'sURI' => 'URI', 'sScriptName' => 'Script Name', 'sLibraryName' => 'Library Name', 'sLibraryURI' => 'Library URI', 'sPluginName' => 'Plugin Name', 'sPluginURI' => 'Plugin URI', 'sThemeName' => 'Theme Name', 'sThemeURI' => 'Theme URI', 'sVersion' => 'Version', 'sDescription' => 'Description', 'sAuthor' => 'Author', 'sAuthorURI' => 'Author URI', 'sTextDomain' => 'Text Domain', 'sDomainPath' => 'Domain Path', 'sNetwork' => 'Network', '_sitewide' => 'Site Wide Only');
     $aData = file_exists($sPathOrContent) ? get_file_data($sPathOrContent, $_aHeaderKeys, $sType) : self::getScriptDataFromContents($sPathOrContent, $sType, $_aHeaderKeys);
     switch (trim($sType)) {
         case 'theme':
             $aData['sName'] = $aData['sThemeName'];
             $aData['sURI'] = $aData['sThemeURI'];
             break;
         case 'library':
             $aData['sName'] = $aData['sLibraryName'];
             $aData['sURI'] = $aData['sLibraryURI'];
             break;
         case 'script':
             $aData['sName'] = $aData['sScriptName'];
             break;
         case 'plugin':
             $aData['sName'] = $aData['sPluginName'];
             $aData['sURI'] = $aData['sPluginURI'];
             break;
         default:
             break;
     }
     return $aData;
 }
Example #2
0
 /**
  * Constructor for Licence Validator in each plugin
  *
  * @param string $file          - full server path to the main plugin file
  * @param string $identifier    - selling Shop Product ID
  * @param string $home_shop_url - selling Shop URL of this plugin (product)
  */
 public function __construct($file, $identifier, $home_shop_url)
 {
     $info = get_file_data($file, array('Title' => 'Plugin Name', 'Version' => 'Version', 'Url' => 'Plugin URI'), 'plugin');
     $this->identifier = $identifier;
     $this->file = $file;
     $this->path = plugin_dir_path($this->file);
     $this->plugin_slug = plugin_basename($this->file);
     list($a, $b) = explode('/', $this->plugin_slug);
     $this->file_slug = str_replace('.php', '', $b);
     $this->title = $info['Title'];
     $this->version = $info['Version'];
     $this->plugin_url = $info['Url'];
     $this->home_shop_url = $home_shop_url;
     //		if (is_ssl()) { // TODO: It should be enabled with proper options (i.e. require secure connection).
     $this->home_shop_url = str_replace('http://', 'https://', $this->home_shop_url);
     //		}
     if ($this->home_shop_url[strlen($this->home_shop_url) - 1] !== '/') {
         $this->home_shop_url .= '/';
     }
     self::$plugins[$this->identifier] = array('version' => $this->version, 'plugin_slug' => $this->plugin_slug, 'file_slug' => $this->file_slug, 'path' => $this->path, 'title' => $this->title);
     if (self::$instance === null) {
         self::$instance = $this;
         // Define the alternative response for information checking
         add_filter('plugins_api', array($this, 'getUpdateData'), 20, 3);
     }
     // define the alternative API for updating checking
     add_filter('pre_set_site_transient_update_plugins', array($this, 'checkUpdates'));
     add_action('in_plugin_update_message-' . $this->plugin_slug, array($this, 'updateMessage'), 10, 2);
     add_action('admin_init', '\\Jigoshop\\Licence::activateKeys');
 }
 /**
  * fetch module info from file
  * /utilities/modules.php
  * @param $file
  */
 public static function get_module_info($file)
 {
     $header = array('name' => 'Module Name', 'description' => 'Description', 'version' => 'Version', 'author' => 'Author', 'uri' => 'Author URI');
     if (file_exists($file)) {
         return get_file_data($file, $header);
     }
 }
Example #4
0
function create_model($table_name)
{
    $file = fopen("{$table_name}.php", "w");
    $file_data = get_file_data($table_name);
    fwrite($file, $file_data);
    fclose($file);
}
 /**
  * Init
  */
 function init()
 {
     // Running this here rather than the constructor since get_file_data is a bit expensive
     $info = get_file_data($this->file, array('Title' => 'Plugin Name', 'Version' => 'Version'), 'plugin');
     $this->plugin_title = $info['Title'];
     $this->plugin_version = $info['Version'];
     // Store the plugin to a static variable
     self::$plugins[$this->api_key] = array('version' => $this->plugin_version, 'slug' => $this->plugin_slug, 'url' => $this->plugin_url, 'path' => $this->plugin_path, 'title' => $this->plugin_title);
     // Check For Plugin Information
     add_filter('plugins_api', array($this, 'plugin_information'), 10, 3);
     // Check For Updates
     add_filter('pre_set_site_transient_update_plugins', array($this, 'update_check'));
     add_filter('upgrader_post_install', array($this, 'upgrader_post_install'), 10, 3);
     if (!self::$instance) {
         self::$instance = true;
         // Register Navigation Menu Link
         add_action('admin_menu', array($this, 'register_nav_menu_link'), 10);
         add_filter('http_request_args', array($this, 'http_request_sslverify'), 10, 2);
         if (!$this->instance_exists()) {
             // Setup Admin Notices
             add_action('admin_notices', array($this, 'admin_notice'));
             add_action('admin_init', array($this, 'hide_admin_notice'));
         }
     }
 }
 /**
  * Returns an array string plugin information.
  * 
  * @see the get_plugin_data() function defined in ABSPATH . 'wp-admin/includes/plugin.php'
  */
 protected function GetPluginInfo($sFilePath)
 {
     $_aDefault = array('PluginName' => 'Plugin Name', 'PluginURI' => 'Plugin URI', 'Version' => 'Version', 'Description' => 'Description', 'Author' => 'Author', 'AuthorURI' => 'AuthorURI', 'TextDomain' => 'TextDomain', 'DomainPath' => 'DomainPath', 'Network' => 'Network', '_sitewide' => 'Site Wide Only');
     // There are cases that the path is not passed; there are various reasons for it
     // such as allowing the redirecting parameter value of the caller function to be null for backward compatibility etc.
     return $sFilePath ? get_file_data($sFilePath, $_aDefault, '') : $_aDefault;
 }
 /**
  * @param Theme_Upgrader $upgrader
  * @param array $extra
  */
 public function hooks_theme_install_or_update($upgrader, $extra)
 {
     if (!isset($extra['type']) || 'theme' !== $extra['type']) {
         return;
     }
     if ('install' === $extra['action']) {
         $slug = $upgrader->theme_info();
         if (!$slug) {
             return;
         }
         wp_clean_themes_cache();
         $theme = wp_get_theme($slug);
         $name = $theme->name;
         $version = $theme->version;
         aal_insert_log(array('action' => 'installed', 'object_type' => 'Theme', 'object_name' => $name, 'object_subtype' => $version));
     }
     if ('update' === $extra['action']) {
         if (isset($extra['bulk']) && true == $extra['bulk']) {
             $slugs = $extra['themes'];
         } else {
             $slugs = array($upgrader->skin->theme);
         }
         foreach ($slugs as $slug) {
             $theme = wp_get_theme($slug);
             $stylesheet = $theme['Stylesheet Dir'] . '/style.css';
             $theme_data = get_file_data($stylesheet, array('Version' => 'Version'));
             $name = $theme['Name'];
             $version = $theme_data['Version'];
             aal_insert_log(array('action' => 'updated', 'object_type' => 'Theme', 'object_name' => $name, 'object_subtype' => $version));
         }
     }
 }
Example #8
0
 /**
  * Get plugins and optionally filter out WP plugins
  */
 static function pl_get_plugins($filter = false, $pro = false)
 {
     $default_headers = array('Version' => 'Version', 'PageLines' => 'PageLines', 'Plugin Name' => 'Plugin Name', 'Description' => 'Description', 'Version' => 'Version', 'Category' => 'Category');
     include_once ABSPATH . 'wp-admin/includes/plugin.php';
     $plugins = get_plugins();
     if (!$filter) {
         return $plugins;
     }
     // get the headers for each plugin file
     foreach ($plugins as $path => $data) {
         $fullpath = sprintf('%s%s', trailingslashit(WP_PLUGIN_DIR), $path);
         $plugins[$path] = get_file_data($fullpath, $default_headers);
     }
     // if the headers do not contain 'PageLines' then unset from the array and let WP handle them
     foreach ($plugins as $path => $data) {
         if (!$data['PageLines']) {
             unset($plugins[$path]);
         }
     }
     // only look for pro plugins
     if ($pro) {
         foreach ($plugins as $path => $data) {
             $cats = array_map('trim', explode(',', $data['Category']));
             if (!array_search('pro', $cats)) {
                 unset($plugins[$path]);
             }
         }
         return $plugins;
     }
     return $plugins;
 }
 public static function register_workflows_callback($arguments)
 {
     global $pagenow;
     extract($arguments);
     $data = get_file_data($path . '/parts/' . $folder . '/' . $part, apply_filters('piklist_get_file_data', array('name' => 'Title', 'description' => 'Description', 'capability' => 'Capability', 'order' => 'Order', 'flow' => 'Flow', 'page' => 'Page', 'post_type' => 'Post Type', 'taxonomy' => 'Taxonomy', 'role' => 'Role', 'redirect' => 'Redirect', 'header' => 'Header', 'disable' => 'Disable', 'position' => 'Position', 'default' => 'Default'), 'workflows'));
     $data = apply_filters('piklist_add_part', $data, 'workflows');
     if (!isset($data['flow'])) {
         return null;
     }
     if ((!isset($data['capability']) || empty($data['capability']) || $data['capability'] && current_user_can(strtolower($data['capability']))) && (!isset($data['role']) || empty($data['role']) || piklist_user::current_user_role($data['role']))) {
         if (!empty($data['page'])) {
             $data['page'] = strstr($data['page'], ',') ? piklist::explode(',', $data['page']) : array($data['page']);
         }
         $data['page_slug'] = piklist::slug($data['name']);
         $data['flow_slug'] = piklist::slug($data['flow']);
         if (!$data['header']) {
             $data = self::is_active($data);
         }
         if (in_array($pagenow, array('admin.php', 'users.php', 'plugins.php', 'options-general.php')) && $data['position'] == 'title') {
             $data['position'] = 'header';
         }
         $workflow = array('config' => $data, 'part' => $path . '/parts/' . $folder . '/' . $part);
         if (!isset(self::$workflows[$data['flow']])) {
             self::$workflows[$data['flow']] = array();
         }
         if ($data['header'] == 'true') {
             array_unshift(self::$workflows[$data['flow']], $workflow);
         } elseif (!empty($data['order'])) {
             self::$workflows[$data['flow']][$data['order']] = $workflow;
         } else {
             array_push(self::$workflows[$data['flow']], $workflow);
         }
     }
 }
function Fac_PHPVersion_AdminNotice()
{
    $name = get_file_data(__FILE__, array('Plugin Name'), 'plugin');
    printf('<div class="error">
            <p><strong>%s</strong> plugin can\'t work properly. Your current PHP version is <strong>%s</strong>. Minimum required PHP version is <strong>%s</strong>.</p>
        </div>', $name[0], FAC_CUR_PHP_VERSION, FAC_MIN_PHP_VERSION);
}
 /**
  * Initializes the plugin by setting filters and administration functions.
  */
 private function __construct()
 {
     $this->templates = array();
     // Add a filter to the attributes metabox to inject template into the cache.
     add_filter('page_attributes_dropdown_pages_args', array($this, 'register_project_templates'));
     // Add a filter to the save post to inject out template into the page cache
     add_filter('wp_insert_post_data', array($this, 'register_project_templates'));
     // Add a filter to the template include to determine if the page has our
     // template assigned and return it's path
     add_filter('template_include', array($this, 'view_project_template'));
     // Get array of page templates
     $templates = scandir(plugin_dir_path(__FILE__) . 'templates/');
     if (is_array($templates)) {
         foreach ($templates as $template) {
             if ($template == '.' || $template == '..' || strpos($template, '.')) {
                 continue;
             }
             $template_meta = get_file_data(plugin_dir_path(__FILE__) . 'templates/' . $template . '/' . $template . '.php', array('name' => 'Template Name', 'description' => 'Description'));
             $this->templates[$template . '/' . $template . '.php'] = isset($template_meta['name']) ? $template_meta['name'] : 'ProGo Page Template';
         }
     }
     // Add action to register template functions.php
     add_action('init', array($this, 'register_template_functions'));
     // Admin Menu
     add_action('admin_menu', array($this, 'progo_page_templater_menu'));
 }
 public static function register_notices_callback($arguments)
 {
     $screen = get_current_screen();
     extract($arguments);
     $file = $path . '/parts/' . $folder . '/' . $part;
     $data = get_file_data($file, apply_filters('piklist_get_file_data', array('notice_id' => 'Notice ID', 'notice_type' => 'Notice Type', 'capability' => 'Capability', 'role' => 'Role', 'page' => 'Page'), 'notice'));
     $data = apply_filters('piklist_add_part', $data, 'notice');
     $dismissed = explode(',', (string) get_user_meta(get_current_user_id(), 'dismissed_piklist_notices', true));
     if (!empty($dismissed[0]) && in_array($data['notice_id'], $dismissed)) {
         return;
     }
     $page = str_replace(' ', '', $data['page']);
     $pages = $page ? explode(',', $page) : false;
     if ($screen->id == $page || empty($page) || in_array($screen->id, $pages)) {
         if ($data['capability'] && !current_user_can($data['capability']) || $data['role'] && !piklist_user::current_user_role($data['role'])) {
             return false;
         } else {
             $content = array('content' => trim(piklist::render($file, null, true)));
             if (isset($data)) {
                 $data = array_merge($data, $content);
                 self::$notices[] = $data;
             }
         }
     }
 }
/**
 * Parses the plugin contents to retrieve plugin's metadata.
 *
 * The metadata of the plugin's data searches for the following in the plugin's
 * header. All plugin data must be on its own line. For plugin description, it
 * must not have any newlines or only parts of the description will be displayed
 * and the same goes for the plugin data. The below is formatted for printing.
 *
 *     /*
 *     Plugin Name: Name of Plugin
 *     Plugin URI: Link to plugin information
 *     Description: Plugin Description
 *     Author: Plugin author's name
 *     Author URI: Link to the author's web site
 *     Version: Must be set in the plugin for WordPress 2.3+
 *     Text Domain: Optional. Unique identifier, should be same as the one used in
 *    		load_plugin_textdomain()
 *     Domain Path: Optional. Only useful if the translations are located in a
 *    		folder above the plugin's base path. For example, if .mo files are
 *    		located in the locale folder then Domain Path will be "/locale/" and
 *    		must have the first slash. Defaults to the base folder the plugin is
 *    		located in.
 *     Network: Optional. Specify "Network: true" to require that a plugin is activated
 *    		across all sites in an installation. This will prevent a plugin from being
 *    		activated on a single site when Multisite is enabled.
 *      * / # Remove the space to close comment
 *
 * Some users have issues with opening large files and manipulating the contents
 * for want is usually the first 1kiB or 2kiB. This function stops pulling in
 * the plugin contents when it has all of the required plugin data.
 *
 * The first 8kiB of the file will be pulled in and if the plugin data is not
 * within that first 8kiB, then the plugin author should correct their plugin
 * and move the plugin data headers to the top.
 *
 * The plugin file is assumed to have permissions to allow for scripts to read
 * the file. This is not checked however and the file is only opened for
 * reading.
 *
 * @since 1.5.0
 *
 * @param string $plugin_file Path to the plugin file
 * @param bool   $markup      Optional. If the returned data should have HTML markup applied.
 *                            Default true.
 * @param bool   $translate   Optional. If the returned data should be translated. Default true.
 * @return array {
 *     Plugin data. Values will be empty if not supplied by the plugin.
 *
 *     @type string $Name        Name of the plugin. Should be unique.
 *     @type string $Title       Title of the plugin and link to the plugin's site (if set).
 *     @type string $Description Plugin description.
 *     @type string $Author      Author's name.
 *     @type string $AuthorURI   Author's website address (if set).
 *     @type string $Version     Plugin version.
 *     @type string $TextDomain  Plugin textdomain.
 *     @type string $DomainPath  Plugins relative directory path to .mo files.
 *     @type bool   $Network     Whether the plugin can only be activated network-wide.
 * }
 */
function get_plugin_data($plugin_file, $markup = true, $translate = true)
{
    $default_headers = array('Name' => 'Plugin Name', 'PluginURI' => 'Plugin URI', 'Version' => 'Version', 'Description' => 'Description', 'Author' => 'Author', 'AuthorURI' => 'Author URI', 'TextDomain' => 'Text Domain', 'DomainPath' => 'Domain Path', 'Network' => 'Network', '_sitewide' => 'Site Wide Only');
    $plugin_data = get_file_data($plugin_file, $default_headers, 'plugin');
    // Site Wide Only is the old header for Network
    if (!$plugin_data['Network'] && $plugin_data['_sitewide']) {
        /* translators: 1: Site Wide Only: true, 2: Network: true */
        _deprecated_argument(__FUNCTION__, '3.0.0', sprintf(__('The %1$s plugin header is deprecated. Use %2$s instead.'), '<code>Site Wide Only: true</code>', '<code>Network: true</code>'));
        $plugin_data['Network'] = $plugin_data['_sitewide'];
    }
    $plugin_data['Network'] = 'true' == strtolower($plugin_data['Network']);
    unset($plugin_data['_sitewide']);
    // If no text domain is defined fall back to the plugin slug.
    if (!$plugin_data['TextDomain']) {
        $plugin_slug = dirname(plugin_basename($plugin_file));
        if ('.' !== $plugin_slug && false === strpos($plugin_slug, '/')) {
            $plugin_data['TextDomain'] = $plugin_slug;
        }
    }
    if ($markup || $translate) {
        $plugin_data = _get_plugin_data_markup_translate($plugin_file, $plugin_data, $markup, $translate);
    } else {
        $plugin_data['Title'] = $plugin_data['Name'];
        $plugin_data['AuthorName'] = $plugin_data['Author'];
    }
    return $plugin_data;
}
Example #14
0
/**
 * Constructs the inner form to allow the user to choose a template for a
 * unit.
 */
function WPCW_metabox_showTemplateSelectionTool()
{
    printf('<p>%s</p>', __('Here you can choose which template to use for this unit.', 'wp_courseware'));
    // Get a list of all templates
    $theme = wp_get_theme();
    // N.B. No caching, even though core Page Templates has that.
    // Nacin advises:
    // "ultimately, "caching" for page templates is not very helpful"
    // "by default, the themes bucket is non-persistent. also, calling
    //  get_page_templates() no longer requires us to load up all theme
    //  data for all themes so overall, it's much quicker already."
    $postTemplates = array('' => '--- ' . __('Use default template', 'wp_courseware') . ' ---');
    // Get a list of all PHP files in the theme, so that we can check for theme headers.
    // Allow the search to go into 1 level of folders.
    $fileList = (array) $theme->get_files('php', 2);
    foreach ($fileList as $fileName => $fullFilePath) {
        // Progressively check the headers for each file. The header is called 'Unit Template Name'.
        // e.g.
        //
        // Unit Template Name: Your Custom Template
        //
        $headers = get_file_data($fullFilePath, array('unit_template_name' => 'Unit Template Name'));
        // No header found
        if (empty($headers['unit_template_name'])) {
            continue;
        }
        // We got one!
        $postTemplates[$fileName] = $headers['unit_template_name'];
    }
    // Show form with selected template that the user can choose from.
    global $post;
    $selectedTemplate = get_post_meta($post->ID, WPCW_TEMPLATE_META_ID, true);
    echo WPCW_forms_createDropdown('wpcw_units_choose_template_list', $postTemplates, $selectedTemplate);
}
function xtreme_get_template_data($template_file)
{
    $default_headers = array('Name' => 'Xtreme Name');
    //using the WP 2.9 introduce function for us too.
    $template_data = get_file_data($template_file, $default_headers, '');
    return $template_data;
}
/**
 * Initialize the plugin.
 *
 * @wp-hook plugins_loaded
 *
 * @return void
 */
function mlp_init()
{
    global $pagenow, $wp_version, $wpdb;
    $plugin_path = plugin_dir_path(__FILE__);
    $plugin_url = plugins_url('/', __FILE__);
    $assets_base = 'assets';
    if (!class_exists('Mlp_Load_Controller')) {
        require $plugin_path . 'inc/autoload/Mlp_Load_Controller.php';
    }
    $loader = new Mlp_Load_Controller($plugin_path . 'inc');
    $data = new Mlp_Plugin_Properties();
    $data->set('loader', $loader->get_loader());
    $locations = new Mlp_Internal_Locations();
    $locations->add_dir($plugin_path, $plugin_url, 'plugin');
    $assets_locations = array('css' => 'css', 'js' => 'js', 'images' => 'images', 'flags' => 'images/flags');
    foreach ($assets_locations as $type => $dir) {
        $locations->add_dir($plugin_path . $assets_base . '/' . $dir, $plugin_url . $assets_base . '/' . $dir, $type);
    }
    $data->set('locations', $locations);
    $data->set('plugin_file_path', __FILE__);
    $data->set('plugin_base_name', plugin_basename(__FILE__));
    $headers = get_file_data(__FILE__, array('text_domain_path' => 'Domain Path', 'plugin_uri' => 'Plugin URI', 'plugin_name' => 'Plugin Name', 'version' => 'Version'));
    foreach ($headers as $name => $value) {
        $data->set($name, $value);
    }
    if (!mlp_pre_run_test($pagenow, $data, $wp_version, $wpdb)) {
        return;
    }
    $mlp = new Multilingual_Press($data, $wpdb);
    $mlp->setup();
}
 protected function GetPluginData($pluginFile, $license)
 {
     // A hack since get_plugin_data() is not available now
     $pluginData = get_file_data($pluginFile, array('Name' => 'Plugin Name', 'PluginURI' => 'Plugin URI', 'Version' => 'Version', 'Description' => 'Description', 'Author' => 'Author', 'TextDomain' => 'Text Domain', 'DomainPath' => 'Domain Path'), 'plugin');
     $pluginUpdater = is_null($license) ? null : new EDD_SL_Plugin_Updater($this->GetStoreUrl(), $pluginFile, array('license' => $license, 'item_name' => $pluginData['Name'], 'author' => $pluginData['Author'], 'version' => $pluginData['Version']));
     return array('PluginData' => $pluginData, 'EddUpdater' => $pluginUpdater);
 }
Example #18
0
 function define_vars()
 {
     // Taken from wp-admin/includes/plugin.php to imitate get_plugin_data(). Can not make use of get_plugin_data since it's only available after admin_init
     $plugin_headers = (require 'skeleteon/inc/plugin_headers.php');
     if (!is_array($plugin_headers) || empty($plugin_headers)) {
         die("Missing Plugin Headers #0 - eop");
     }
     $plug_base_arr = explode('/', plugin_basename(__FILE__), 2);
     $plug_base_folder = $plug_base_arr[0];
     $plug_mainfile = WP_PLUGIN_DIR . '/' . plugin_basename(__FILE__);
     $plug_data = get_file_data($plug_mainfile, $plugin_headers);
     // Ensure we have the basic info.
     if (!is_array($plug_base_arr) || empty($plug_base_arr) || empty($plug_base_folder) || !is_array($plug_base_arr) || empty($plug_base_arr)) {
         die("Empty Plugin Headers#100 - skeleteon");
     }
     // This is very important. This slug is a unique identifier for both our plugin object and the lang domain.
     $this->plug_slug = $this->lang_slug = sanitize_key(str_replace(' ', '_', $plug_data['TextDomain']));
     $this->plug_opt = $this->plug_slug . '_plugin_settings';
     $this->plug_name = $plug_data['Name'];
     $this->plug_basename = $plug_base_folder;
     $this->plug_basemainfile = plugin_basename(__FILE__);
     $this->plug_sanit = sanitize_title($plug_data['Name']);
     $this->plug_dir = WP_PLUGIN_DIR . '/' . $plug_base_folder . '/';
     $this->plug_uri = WP_PLUGIN_URL . '/' . $plug_base_folder . '/';
     $this->plug_mainfile = $plug_mainfile;
     $this->errors = new WP_Error();
     $this->reg_transients = array('setting_messages' => $this->plug_slug . '_setting_msgs', 'google_fonts' => $this->plug_slug . '_gwf_trans');
 }
 /**
  * Constructor for Licence Validator in each plugin
  *
  * @param string $file - full server path to the main plugin file
  * @param string $identifier - selling Shop Product ID
  * @param string $home_shop_url - selling Shop URL of this plugin (product)
  */
 public function __construct($file, $identifier, $home_shop_url)
 {
     $info = get_file_data($file, array('Title' => 'Plugin Name', 'Version' => 'Version', 'Url' => 'Plugin URI'), 'plugin');
     $this->identifier = $identifier;
     $this->file = $file;
     $this->path = plugin_dir_path($this->file);
     $this->plugin_slug = plugin_basename($this->file);
     list($a, $b) = explode('/', $this->plugin_slug);
     $this->file_slug = str_replace('.php', '', $b);
     $this->title = $info['Title'];
     $this->version = $info['Version'];
     $this->plugin_url = $info['Url'];
     $this->home_shop_url = $home_shop_url;
     $this->override_validation_url = get_option('jigoshop_license_override_validation_url', false);
     $this->custom_validation_url = get_option('jigoshop_license_custom_validation_url', '');
     if ($this->override_validation_url) {
         $this->home_shop_url = $this->custom_validation_url;
     }
     self::$plugins[$this->identifier] = array('version' => $this->version, 'plugin_slug' => $this->plugin_slug, 'file_slug' => $this->file_slug, 'path' => $this->path, 'title' => $this->title);
     if (!self::$instance) {
         self::$instance = true;
         add_action('admin_menu', array($this, 'register_nav_menu_link'));
         // Define the alternative response for information checking
         add_filter('plugins_api', array($this, 'get_update_info'), 20, 3);
     }
     // define the alternative API for updating checking
     add_filter('pre_set_site_transient_update_plugins', array($this, 'check_for_update'));
     add_action('in_plugin_update_message-' . $this->plugin_slug, array($this, 'in_plugin_update_message'), 10, 2);
 }
Example #20
0
 /**
  * Parses passed directory for shortcodes files
  * includes and adds shortcodes if they exist
  * 
  * @param string $path
  * @param boolean $cache
  * @author peshkov@UD
  */
 public static function maybe_load_shortcodes($path, $cache = true)
 {
     if (!is_dir($path)) {
         return null;
     }
     $_shortcodes = wp_cache_get('shortcodes', 'usabilitydynamics');
     if (!is_array($_shortcodes)) {
         $_shortcodes = array();
     }
     if ($cache && !empty($_shortcodes[$path]) && is_array($_shortcodes[$path])) {
         foreach ($_shortcodes[$path] as $_shortcode) {
             include_once $path . "/" . $_shortcode['file'];
             new $_shortcode['headers']['class']();
         }
         return null;
     }
     $_shortcodes[$path] = array();
     if ($dir = @opendir($path)) {
         $headers = array('name' => 'Name', 'id' => 'ID', 'type' => 'Type', 'group' => 'Group', 'class' => 'Class', 'version' => 'Version', 'description' => 'Description');
         while (false !== ($file = readdir($dir))) {
             $data = @get_file_data($path . "/" . $file, $headers, 'shortcode');
             if ($data['type'] == 'shortcode' && !empty($data['class'])) {
                 include_once $path . "/" . $file;
                 if (class_exists($data['class'])) {
                     array_push($_shortcodes[$path], array('file' => $file, 'headers' => $data));
                     new $data['class']();
                 }
             }
         }
     }
     wp_cache_set('shortcodes', $_shortcodes, 'usabilitydynamics');
 }
Example #21
0
 protected function __construct()
 {
     if (false !== get_transient('_my-wp-backup-activated')) {
         delete_transient('_my-wp-backup-activated');
         wp_redirect(Admin::get_page_url(''));
     }
     self::$info = get_file_data(__FILE__, array('name' => 'Plugin Name', 'pluginUri' => 'Plugin URI', 'supportUri' => 'Support URI', 'version' => 'Version', 'description' => 'Description', 'author' => 'Author', 'authorUri' => 'Author URI', 'textDomain' => 'Text Domain', 'domainPath' => 'Domain Path', 'slug' => 'Slug', 'license' => 'License', 'licenseUri' => 'License URI'));
     Admin::get_instance();
     $options = get_site_option('my-wp-backup-options', Admin::$options);
     self::$info['baseDir'] = plugin_dir_path(__FILE__);
     self::$info['baseDirUrl'] = plugin_dir_url(__FILE__);
     self::$info['backup_dir'] = trailingslashit(ABSPATH) . trailingslashit(ltrim($options['backup_dir'], '/'));
     self::$info['root_dir'] = trailingslashit(ABSPATH);
     if (defined('WP_CLI') && WP_CLI) {
         \WP_CLI::add_command('job', new Cli\Job());
         \WP_CLI::add_command('backup', new Cli\Backup());
     }
     add_action('wp_backup_run_job', array(Job::get_instance(), 'cron_run'));
     add_action('wp_backup_restore_backup', array(Backup::get_instance(), 'cron_run'));
     $version = get_site_option(self::KEY_VERSION);
     if (!$version || self::$info['version'] !== $version) {
         if ($this->update_options()) {
             update_site_option(self::KEY_VERSION, self::$info['version']);
         }
     }
 }
 function register_settings()
 {
     $plugin_datas = get_file_data(BOXERSANDSWIPERS_PLUGIN_BASE_DIR . '/boxersandswipers.php', array('version' => 'Version'));
     $plugin_version = floatval($plugin_datas['version']);
     if (!get_option('boxersandswipers_apply')) {
         $posttypes = BoxersAndSwipersAdmin::search_posttype();
         $apply_tbl = array();
         foreach ($posttypes as $key => $value) {
             $apply_tbl[$key]['pc'] = 'true';
             $apply_tbl[$key]['tb'] = 'true';
             $apply_tbl[$key]['sp'] = 'true';
             unset($posttypes[$key]);
         }
         update_option('boxersandswipers_apply', $apply_tbl);
     }
     if (!get_option('boxersandswipers_effect')) {
         $effect_tbl = array('pc' => 'colorbox', 'tb' => 'nivolightbox', 'sp' => 'photoswipe');
         update_option('boxersandswipers_effect', $effect_tbl);
     }
     if (!get_option('boxersandswipers_useragent')) {
         $useragent_tbl = array('tb' => 'iPad|^.*Android.*Nexus(((?:(?!Mobile))|(?:(\\s(7|10).+))).)*$|Kindle|Silk.*Accelerated|Sony.*Tablet|Xperia Tablet|Sony Tablet S|SAMSUNG.*Tablet|Galaxy.*Tab|SC-01C|SC-01D|SC-01E|SC-02D', 'sp' => 'iPhone|iPod|Android.*Mobile|BlackBerry|IEMobile');
         update_option('boxersandswipers_useragent', $useragent_tbl);
     }
     if (!get_option('boxersandswipers_colorbox')) {
         $colorbox_tbl = array('rel' => 'boxersandswipers', 'transition' => 'elastic', 'speed' => 350, 'title' => 'false', 'scalePhotos' => 'true', 'scrolling' => 'true', 'opacity' => 0.85, 'open' => 'false', 'returnFocus' => 'true', 'trapFocus' => 'true', 'fastIframe' => 'true', 'preloading' => 'true', 'overlayClose' => 'true', 'escKey' => 'true', 'arrowKey' => 'true', 'loop' => 'true', 'fadeOut' => 300, 'closeButton' => 'true', 'current' => 'image {current} of {total}', 'previous' => 'previous', 'next' => 'next', 'close' => 'close', 'width' => 'false', 'height' => 'false', 'innerWidth' => 'false', 'innerHeight' => 'false', 'initialWidth' => 300, 'initialHeight' => 100, 'maxWidth' => 'false', 'maxHeight' => 'false', 'slideshow' => 'true', 'slideshowSpeed' => 2500, 'slideshowAuto' => 'false', 'slideshowStart' => 'start slideshow', 'slideshowStop' => 'stop slideshow', 'fixed' => 'false', 'top' => 'false', 'bottom' => 'false', 'left' => 'false', 'right' => 'false', 'reposition' => 'true', 'retinaImage' => 'false');
         update_option('boxersandswipers_colorbox', $colorbox_tbl);
     }
     if (!get_option('boxersandswipers_slimbox')) {
         $slimbox_tbl = array('loop' => 'false', 'overlayOpacity' => 0.8, 'overlayFadeDuration' => 400, 'resizeDuration' => 400, 'resizeEasing' => 'swing', 'initialWidth' => 250, 'initialHeight' => 250, 'imageFadeDuration' => 400, 'captionAnimationDuration' => 400, 'counterText' => 'Image {x} of {y}', 'closeKeys' => '[27, 88, 67]', 'previousKeys' => '[37, 80]', 'nextKeys' => '[39, 78]');
         update_option('boxersandswipers_slimbox', $slimbox_tbl);
     }
     if (!get_option('boxersandswipers_nivolightbox')) {
         $nivolightbox_tbl = array('effect' => 'fade', 'keyboardNav' => 'true', 'clickOverlayToClose' => 'true');
         update_option('boxersandswipers_nivolightbox', $nivolightbox_tbl);
     }
     if (!get_option('boxersandswipers_imagelightbox')) {
         $imagelightbox_tbl = array('animationSpeed' => 250, 'preloadNext' => 'true', 'enableKeyboard' => 'true', 'quitOnEnd' => 'false', 'quitOnImgClick' => 'false', 'quitOnDocClick' => 'true');
         update_option('boxersandswipers_imagelightbox', $imagelightbox_tbl);
     }
     if (!get_option('boxersandswipers_photoswipe')) {
         $photoswipe_tbl = array('fadeInSpeed' => 250, 'fadeOutSpeed' => 500, 'slideSpeed' => 250, 'swipeThreshold' => 50, 'swipeTimeThreshold' => 250, 'loop' => 'true', 'slideshowDelay' => 3000, 'imageScaleMethod' => 'fit', 'preventHide' => 'false', 'backButtonHideEnabled' => 'true', 'captionAndToolbarHide' => 'false', 'captionAndToolbarHideOnSwipe' => 'true', 'captionAndToolbarFlipPosition' => 'false', 'captionAndToolbarAutoHideDelay' => 5000, 'captionAndToolbarOpacity' => 0.8, 'captionAndToolbarShowEmptyCaptions' => 'false');
         update_option('boxersandswipers_photoswipe', $photoswipe_tbl);
     }
     if (!get_option('boxersandswipers_swipebox')) {
         $swipebox_tbl = array('hideBarsDelay' => 3000, 'loopAtEnd' => 'false');
         update_option('boxersandswipers_swipebox', $swipebox_tbl);
     } else {
         $boxersandswipers_swipebox = get_option('boxersandswipers_swipebox');
         if ($plugin_version >= 2.22) {
             if (array_key_exists("loopAtEnd", $boxersandswipers_swipebox)) {
                 $loopatend = $boxersandswipers_swipebox['loopAtEnd'];
             } else {
                 $loopatend = 'false';
             }
             $swipebox_tbl = array('hideBarsDelay' => $boxersandswipers_swipebox['hideBarsDelay'], 'loopAtEnd' => $loopatend);
             update_option('boxersandswipers_swipebox', $swipebox_tbl);
         }
     }
 }
 /**
  * Constructor. Sets up the properties.
  *
  * @since 3.0.0
  *
  * @param string $plugin_file_path Main plugin file path.
  */
 public function __construct($plugin_file_path)
 {
     if (!isset($this->properties)) {
         $file_data = ['plugin_base_name' => plugin_basename($plugin_file_path), 'plugin_dir_path' => plugin_dir_path($plugin_file_path), 'plugin_dir_url' => plugins_url('/', $plugin_file_path), 'plugin_file_path' => (string) $plugin_file_path];
         $header_data = get_file_data($plugin_file_path, ['plugin_name' => 'Plugin Name', 'plugin_website' => 'Plugin URI', 'version' => 'Version', 'text_domain' => 'Text Domain', 'text_domain_path' => 'Domain Path']);
         $this->properties = array_merge($file_data, $header_data);
     }
 }
function r3df_popup_maker_divi_nav_fix()
{
    // Get the plugin version (added to css file loaded to clear browser caches on change)
    $plugin = get_file_data(__FILE__, array('Version' => 'Version'));
    // Register and enqueue the general css
    wp_register_script('r3df-popup-maker-divi-nav-fix', plugins_url('js/r3df-popup-maker-divi-nav-fix.js', __FILE__), array('et-builder-modules-global-functions-script'), $plugin['Version'], true);
    wp_enqueue_script('r3df-popup-maker-divi-nav-fix');
}
Example #25
0
function inline_comments_enqueue_scripts()
{
    $plugin_headers = get_file_data(__FILE__, array('Version' => 'Version', 'Name' => 'Original Plugin Name'));
    $clean_name = strtolower(str_replace(' ', '-', $plugin_headers['Name']));
    wp_register_style($clean_name . '-style', plugin_dir_url(__FILE__) . 'inc/css/style.css');
    wp_register_script('textarea_auto_expand-script', plugin_dir_url(__FILE__) . 'vendor/textarea-auto-expand/jquery.textarea_auto_expand.js');
    wp_register_script($clean_name . '-script', plugin_dir_url(__FILE__) . 'inc/js/script.js', array('jquery', 'textarea_auto_expand-script'));
}
 public static function load()
 {
     self::add_plugin('piklist', dirname(dirname(__FILE__)));
     self::$version = current(get_file_data(self::$paths['piklist'] . '/piklist.php', array('version' => 'Version')));
     load_plugin_textdomain('piklist', false, 'piklist/languages/');
     register_activation_hook('piklist/piklist.php', array('piklist', 'activate'));
     self::auto_load();
 }
 /**
  *
  * @TODO document
  *
  */
 function extension_scan_themes($themes)
 {
     $default_headers = array('Demo' => 'Demo', 'External' => 'External', 'Long' => 'Long');
     $themes = pagelines_store_object_sort($themes);
     $themes = json_decode(json_encode($themes), true);
     $get_themes = apply_filters('store_get_themes', pl_get_themes());
     foreach ($get_themes as $theme => $theme_data) {
         $up = null;
         $purchased = null;
         // Now we add our data...
         $theme_file = $theme_data['Stylesheet Files'][0];
         $pl_theme_data = get_file_data($theme_file, $default_headers);
         if ($theme_data['Template'] != 'pagelines') {
             continue;
         }
         if ('pagelines' == $theme_data['Stylesheet']) {
             continue;
         }
         // check for an update...
         if (isset($themes[$theme_data['Stylesheet']]['version']) && $themes[$theme_data['Stylesheet']]['version'] > $theme_data['Version']) {
             $up = $themes[$theme_data['Stylesheet']]['version'];
         } else {
             $up = '';
         }
         $pid = isset($themes[$theme_data['Stylesheet']]['productid']) ? $themes[$theme_data['Stylesheet']]['productid'] : '';
         $subscribed = isset($themes[$theme_data['Stylesheet']]['subscribed']) ? $themes[$theme_data['Stylesheet']]['subscribed'] : null;
         if (in_array($theme, $themes)) {
             continue;
         }
         $purchased = isset($themes[$theme_data['Stylesheet']]['purchased']) ? $themes[$theme_data['Stylesheet']]['purchased'] : '';
         // If we got this far, theme is a pagelines child theme not handled by the API
         // So we need to inject it into our themes array.
         $plus = isset($themes[$theme_data['Stylesheet']]['plus_product']) ? $themes[$theme_data['Stylesheet']]['plus_product'] : false;
         $new_theme = array();
         $new_theme['name'] = $theme_data['Name'];
         $new_theme['author'] = $theme_data['Author Name'];
         $new_theme['author_url'] = $theme_data['Author URI'];
         $new_theme['apiversion'] = $up;
         $new_theme['version'] = $theme_data['Version'];
         $new_theme['text'] = $theme_data['Description'];
         $new_theme['long'] = $pl_theme_data['Long'];
         $new_theme['external'] = $pl_theme_data['External'];
         $new_theme['Demo'] = $pl_theme_data['Demo'];
         $new_theme['tags'] = $theme_data['Tags'];
         $new_theme['featured'] = isset($themes[$theme_data['Stylesheet']]['featured']) ? $themes[$theme_data['Stylesheet']]['featured'] : null;
         $new_theme['price'] = isset($themes[$theme_data['Stylesheet']]['price']) ? $themes[$theme_data['Stylesheet']]['price'] : null;
         $new_theme['pid'] = $pid;
         $new_theme['subscribed'] = $subscribed;
         $new_theme['count'] = null;
         $new_theme['slug'] = isset($themes[$theme_data['Stylesheet']]['slug']) ? $themes[$theme_data['Stylesheet']]['slug'] : null;
         if ($purchased) {
             $new_theme['purchased'] = $purchased;
         }
         $new_theme['plus_product'] = $plus;
         $themes[$theme_data['Stylesheet']] = $new_theme;
     }
     return $themes;
 }
Example #28
0
 /**
  * Populate $plugin_data.
  * This method should called by plugin's main file right before loading controllers.
  *
  * @param
  *            string __FILE__ : Path of the plugin main file
  */
 public static function init($file_path)
 {
     $plugin_headers = array('name' => 'Plugin Name', 'version' => 'Version');
     self::$plugin_data = get_file_data($file_path, $plugin_headers);
     self::$plugin_data['file'] = $file_path;
     self::$plugin_data['slug'] = plugin_basename($file_path);
     self::$plugin_data['path'] = dirname($file_path);
     self::$plugin_data['url'] = plugins_url('', $file_path);
 }
 public static function text_domain()
 {
     static $text_domain;
     if (!$text_domain) {
         $data = get_file_data(__FILE__, array('text_domain' => 'Text Domain'));
         $text_domain = $data['text_domain'];
     }
     return $text_domain;
 }
function Fac_PHPVersion_AdminNotice()
{
    $name = get_file_data(__FILE__, array('Plugin Name'), 'plugin');
    $currentPHPVersion = Agp_GetPHPVersionById(Agp_GetCurrentPHPVersionId());
    $requiredtPHPVersion = Agp_GetPHPVersionById(AGP_PHP_VERSION);
    printf('<div class="error">
            <p><strong>%s</strong> plugin can\'t work properly. Your current PHP version is <strong>%s</strong>. Minimum required PHP version is <strong>%s</strong>.</p>
        </div>', $name[0], $currentPHPVersion, $requiredtPHPVersion);
}