Parse plugin's settings (as defined by the plugin dev).

@author Vova Feldman (@svovaf)
@since  1.1.7.3

@param array $plugin_info

@throws \Freemius_Exception
505024
private function parse_settings( &$plugin_info ) {
            $this->_logger->entrance();

            $id          = $this->get_numeric_option( $plugin_info, 'id', false );
            $public_key  = $this->get_option( $plugin_info, 'public_key', false );
            $secret_key  = $this->get_option( $plugin_info, 'secret_key', null );
            $parent_id   = $this->get_numeric_option( $plugin_info, 'parent_id', null );
            $parent_name = $this->get_option( $plugin_info, 'parent_name', null );

            /**
             * @author Vova Feldman (@svovaf)
             * @since  1.1.9 Try to pull secret key from external config.
             */
            if ( is_null( $secret_key ) && defined( "WP_FS__{$this->_slug}_SECRET_KEY" ) ) {
                $secret_key = constant( "WP_FS__{$this->_slug}_SECRET_KEY" );
            }

            if ( isset( $plugin_info['parent'] ) ) {
                $parent_id = $this->get_numeric_option( $plugin_info['parent'], 'id', null );
//				$parent_slug       = $this->get_option( $plugin_info['parent'], 'slug', null );
//				$parent_public_key = $this->get_option( $plugin_info['parent'], 'public_key', null );
//				$parent_name = $this->get_option( $plugin_info['parent'], 'name', null );
            }

            if ( false === $id ) {
                throw new Freemius_Exception( array(
                    'error' => array(
                        'type'    => 'ParameterNotSet',
                        'message' => 'Plugin id parameter is not set.',
                        'code'    => 'plugin_id_not_set',
                        'http'    => 500,
                    )
                ) );
            }
            if ( false === $public_key ) {
                throw new Freemius_Exception( array(
                    'error' => array(
                        'type'    => 'ParameterNotSet',
                        'message' => 'Plugin public_key parameter is not set.',
                        'code'    => 'plugin_public_key_not_set',
                        'http'    => 500,
                    )
                ) );
            }

            $plugin = ( $this->_plugin instanceof FS_Plugin ) ?
                $this->_plugin :
                new FS_Plugin();

            $premium_suffix = $this->get_option( $plugin_info, 'premium_suffix', '(Premium)' );

            $plugin->update( array(
                'id'                   => $id,
                'type'                 => $this->get_option( $plugin_info, 'type', $this->_module_type ),
                'public_key'           => $public_key,
                'slug'                 => $this->_slug,
                'premium_slug'         => $this->get_option( $plugin_info, 'premium_slug', "{$this->_slug}-premium" ),
                'parent_plugin_id'     => $parent_id,
                'version'              => $this->get_plugin_version(),
                'title'                => $this->get_plugin_name( $premium_suffix ),
                'file'                 => $this->_plugin_basename,
                'is_premium'           => $this->get_bool_option( $plugin_info, 'is_premium', true ),
                'premium_suffix'       => $premium_suffix,
                'is_live'              => $this->get_bool_option( $plugin_info, 'is_live', true ),
                'affiliate_moderation' => $this->get_option( $plugin_info, 'has_affiliation' ),
            ) );

            if ( $plugin->is_updated() ) {
                // Update plugin details.
                $this->_plugin = FS_Plugin_Manager::instance( $this->_module_id )->store( $plugin );
            }
            // Set the secret key after storing the plugin, we don't want to store the key in the storage.
            $this->_plugin->secret_key = $secret_key;

            if ( ! isset( $plugin_info['menu'] ) ) {
                $plugin_info['menu'] = array();

                if ( ! empty( $this->_storage->sdk_last_version ) &&
                     version_compare( $this->_storage->sdk_last_version, '1.1.2', '<=' )
                ) {
                    // Backward compatibility to 1.1.2
                    $plugin_info['menu']['slug'] = isset( $plugin_info['menu_slug'] ) ?
                        $plugin_info['menu_slug'] :
                        $this->_slug;
                }
            }

            $this->_menu = FS_Admin_Menu_Manager::instance(
                $this->_module_id,
                $this->_module_type,
                $this->get_unique_affix()
            );

            $this->_menu->init( $plugin_info['menu'], $this->is_addon() );

            $this->_has_addons          = $this->get_bool_option( $plugin_info, 'has_addons', false );
            $this->_has_paid_plans      = $this->get_bool_option( $plugin_info, 'has_paid_plans', true );
            $this->_has_premium_version = $this->get_bool_option( $plugin_info, 'has_premium_version', $this->_has_paid_plans );
            $this->_ignore_pending_mode = $this->get_bool_option( $plugin_info, 'ignore_pending_mode', false );
            $this->_is_org_compliant    = $this->get_bool_option( $plugin_info, 'is_org_compliant', true );
            $this->_is_premium_only     = $this->get_bool_option( $plugin_info, 'is_premium_only', false );
            if ( $this->_is_premium_only ) {
                // If premium only plugin, disable anonymous mode.
                $this->_enable_anonymous = false;
                $this->_anonymous_mode   = false;
            } else {
                $this->_enable_anonymous = $this->get_bool_option( $plugin_info, 'enable_anonymous', true );
                $this->_anonymous_mode   = $this->get_bool_option( $plugin_info, 'anonymous_mode', false );
            }
            $this->_permissions = $this->get_option( $plugin_info, 'permissions', array() );

            if ( ! empty( $plugin_info['trial'] ) ) {
                $this->_trial_days = $this->get_numeric_option(
                    $plugin_info['trial'],
                    'days',
                    // Default to 0 - trial without days specification.
                    0
                );

                $this->_is_trial_require_payment = $this->get_bool_option( $plugin_info['trial'], 'is_require_payment', false );
            }
        }
40797
function set_conf( $confname ){
		$this->confname = $confname;
		$this->confdir = PLUG_HOST_DIR.'/'.$confname;
		if( ! PLUGTool::check_dir($this->confdir) ){
			throw new PLUGException('bad conf');
		}
		// parse default plug conf using external parser
		$confpath = $this->confdir.'/PLUG.conf.php';
		$this->conf_vars = array();
		$this->conf_consts = array ();
		$this->load_conf( $confpath );
	}
651069
public static function phpini()
	{
		// disabled ?
		//
		if (!self::_debug())
		{
			return false;
		}

		if (!readable(get_cfg_var('cfg_file_path')))
		{
			return false;
		}

		// render it
		//
		?>
<div class="krumo-title">
This is a list of the configuration settings read from <code><b><?php echo get_cfg_var('cfg_file_path');?></b></code>.
</div>
		<?php
		return self::dump(parse_ini_file(get_cfg_var('cfg_file_path'), true));
	}
575195
protected function parse()
    {
        $this->checkFormat();
        $this->parsePalmDb();
        $this->parsePalmDoc();
        $this->parseMobiHeader();
        $this->parseExth();
    }
1224878
public static function init() {
		/**
		 * Allow themes/plugins to override the default settings
		 *
		 * @since 0.9.0
		 *
		 * @param array $default_settings Default settings.
		 */
		self::$defaults = apply_filters( 'menu_icons_settings_defaults', self::$defaults );

		self::$settings = get_option( 'menu-icons', self::$defaults );

		foreach ( self::$settings as $key => &$value ) {
			if ( 'global' === $key ) {
				// Remove unregistered icon types.
				$value['icon_types'] = array_values(
					array_intersect(
						array_keys( Menu_Icons::get( 'types' ) ),
						array_filter( (array) $value['icon_types'] )
					)
				);
			} else {
				// Backward-compatibility.
				if ( isset( $value['width'] ) && ! isset( $value['svg_width'] ) ) {
					$value['svg_width'] = $value['width'];
				}

				unset( $value['width'] );
			}
		}

		unset( $value );

		/**
		 * Allow themes/plugins to override the settings
		 *
		 * @since 0.9.0
		 *
		 * @param array $settings Menu Icons settings.
		 */
		self::$settings = apply_filters( 'menu_icons_settings', self::$settings );

		if ( self::is_menu_icons_disabled_for_menu() ) {
			return;
		}

		if ( ! empty( self::$settings['global']['icon_types'] ) ) {
			require_once Menu_Icons::get( 'dir' ) . 'includes/picker.php';
			Menu_Icons_Picker::init();
			self::$script_deps[] = 'icon-picker';
		}

		add_action( 'load-nav-menus.php', array( __CLASS__, '_load_nav_menus' ), 1 );
		add_action( 'wp_ajax_menu_icons_update_settings', array( __CLASS__, '_ajax_menu_icons_update_settings' ) );
	}
304613
protected function parseUserInfo()
    {
        // No user information? we're done
        if (null === $this->userInfo) {
            return;
        }

        // If no ':' separator, we only have a username
        if (false === strpos($this->userInfo, ':')) {
            $this->setUser($this->userInfo);

            return;
        }

        // Split on the ':', and set both user and password
        list($user, $password) = explode(':', $this->userInfo, 2);
        $this->setUser($user);
        $this->setPassword($password);
    }
534441
public function definition() {
        global $CFG;
        // type of plugin, string
        $this->plugin = $this->_customdata['plugin'];
        $this->instance = (isset($this->_customdata['instance'])
                && is_a($this->_customdata['instance'], 'repository_type'))
            ? $this->_customdata['instance'] : null;

        $this->action = $this->_customdata['action'];
        $this->pluginname = $this->_customdata['pluginname'];
        $mform =& $this->_form;
        $strrequired = get_string('required');

        $mform->addElement('hidden', 'action', $this->action);
        $mform->setType('action', PARAM_TEXT);
        $mform->addElement('hidden', 'repos', $this->plugin);
        $mform->setType('repos', PARAM_PLUGIN);

        // let the plugin add its specific fields
        $classname = 'repository_' . $this->plugin;
        require_once($CFG->dirroot . '/repository/' . $this->plugin . '/lib.php');
        //add "enable course/user instances" checkboxes if multiple instances are allowed
        $instanceoptionnames = repository::static_function($this->plugin, 'get_instance_option_names');

        $result = call_user_func(array($classname, 'type_config_form'), $mform, $classname);

        if (!empty($instanceoptionnames)) {
            $sm = get_string_manager();
            $component = 'repository';
            if ($sm->string_exists('enablecourseinstances', 'repository_' . $this->plugin)) {
                $component .= ('_' . $this->plugin);
            }
            $mform->addElement('checkbox', 'enablecourseinstances', get_string('enablecourseinstances', $component));
            $mform->setType('enablecourseinstances', PARAM_BOOL);

            $component = 'repository';
            if ($sm->string_exists('enableuserinstances', 'repository_' . $this->plugin)) {
                $component .= ('_' . $this->plugin);
            }
            $mform->addElement('checkbox', 'enableuserinstances', get_string('enableuserinstances', $component));
            $mform->setType('enableuserinstances', PARAM_BOOL);
        }

        // set the data if we have some.
        if ($this->instance) {
            $data = array();
            $option_names = call_user_func(array($classname,'get_type_option_names'));
            if (!empty($instanceoptionnames)){
                $option_names[] = 'enablecourseinstances';
                $option_names[] = 'enableuserinstances';
            }

            $instanceoptions = $this->instance->get_options();
            foreach ($option_names as $config) {
                if (!empty($instanceoptions[$config])) {
                    $data[$config] = $instanceoptions[$config];
                } else {
                    $data[$config] = '';
                }
            }
            // XXX: set plugin name for plugins which doesn't have muliti instances
            if (empty($instanceoptionnames)){
                $data['pluginname'] = $this->pluginname;
            }
            $this->set_data($data);
        }

        $this->add_action_buttons(true, get_string('save','repository'));
    }
894180
protected function loadXML($pluginDir)
    {
        $xml = $pluginDir.'/plugin.xml';

        if (!isset($this->xmlCache[$xml])) {
            if (file_exists($xml)) {
                try
                {
                    $this->xmlCache[$xml] = $this->SimpleXMLParser->parseXMLFile($xml);
                }catch (Exception $e){
                    throw new Exception('Unable to parse plugin.xml file ['.$xml.']');
                }
            } else {
                return false;
            }
        }

        return $this->xmlCache[$xml];
    }
1192659
function init_plugin($authtype) {
        $this->pluginconfig = 'auth_'.$authtype;
        $this->config = get_config($this->pluginconfig);
        if (empty($this->config->ldapencoding)) {
            $this->config->ldapencoding = 'utf-8';
        }
        if (empty($this->config->user_type)) {
            $this->config->user_type = 'default';
        }

        $ldap_usertypes = ldap_supported_usertypes();
        $this->config->user_type_name = $ldap_usertypes[$this->config->user_type];
        unset($ldap_usertypes);

        $default = ldap_getdefaults();

        // Use defaults if values not given
        foreach ($default as $key => $value) {
            // watch out - 0, false are correct values too
            if (!isset($this->config->{$key}) or $this->config->{$key} == '') {
                $this->config->{$key} = $value[$this->config->user_type];
            }
        }

        // Hack prefix to objectclass
        $this->config->objectclass = ldap_normalise_objectclass($this->config->objectclass);
    }
463262
public static function check(Plugin $plugin, ReflectionClass $info) : bool
  {
    /**
     * Check if plugin meets the minimum requirements
     */
    if (
      array_key_exists('PACKAGE', $info->getConstants()) &&
      array_key_exists('VERSION', $info->getConstants()) &&
      (
        array_key_exists('AUTHORS', $info->getConstants()) &&
        is_array($info->getConstants()['AUTHORS'])
      ) &&
      array_key_exists('FRAMEWORK', $info->getConstants())
    ) {
      return self::isCompatable($plugin);
    }

    /**
     * Plugin does not meet the minimum requirements
     */
    return false;
  }
885748
def get_info(self):
        
        plugin_infos = {}
        for pc in self.plugins:
            plugin_infos.update(pc.get_info())
        return {
            self.get_plugin_name() : {
                "version"     : self.get_version(),
                "sub-plugins" : plugin_infos,
                "params" : {
                    "multi_plugins" : self.conf['multi_plugins']
                },
            }
        }
716487
function debugConfig()
    {
	    $jname = $this->getJname();
	    //get registration status
	    $new_registration = $this->allowRegistration();

	    if ($new_registration) {
		    $plugins = Framework::getSlaves();
		    foreach ($plugins as $plugin) {
			    if ($plugin->name == $jname) {
				    Framework::raise(LogLevel::NOTICE, Text::_('DISABLE_REGISTRATION'), $jname);
			    }
		    }
	    } else {
		    $master = Framework::getMaster();
		    if ($master && $master->name == $jname) {
			    Framework::raise(LogLevel::NOTICE, Text::_('ENABLE_REGISTRATION'), $jname);
		    }
	    }

	    //most dual login problems are due to incorrect cookie domain settings
	    //therefore we should check it and output a warning if needed.

	    $cookie_domain = $this->params->get('cookie_domain',-1);
	    if ($cookie_domain!==-1) {
		    $cookie_domain = str_replace(array('http://', 'https://'), array('', ''), $cookie_domain);
		    $correct_array = explode('.', html_entity_decode($_SERVER['SERVER_NAME']));

		    //check for domain names with double extentions
		    if (isset($correct_array[count($correct_array) - 2]) && isset($correct_array[count($correct_array) - 1])) {
			    //domain array
			    $domain_array = array('com', 'net', 'org', 'co', 'me');
			    if (in_array($correct_array[count($correct_array) - 2], $domain_array)) {
				    $correct_domain = '.' . $correct_array[count($correct_array) - 3] . '.' . $correct_array[count($correct_array) - 2] . '.' . $correct_array[count($correct_array) - 1];
			    } else {
				    $correct_domain = '.' . $correct_array[count($correct_array) - 2] . '.' . $correct_array[count($correct_array) - 1];
			    }
			    if ($correct_domain != $cookie_domain && !$this->allowEmptyCookieDomain()) {
				    Framework::raise(LogLevel::NOTICE, Text::_('BEST_COOKIE_DOMAIN') . ' ' . $correct_domain, $jname);
			    }
		    }
	    }

	    //also check the cookie path as it can interfere with frameless
	    $cookie_path = $this->params->get('cookie_path',-1);
	    if ($cookie_path !== -1) {
		    if ($cookie_path != '/' && !$this->allowEmptyCookiePath()) {
			    Framework::raise(LogLevel::NOTICE, Text::_('BEST_COOKIE_PATH') . ' /', $jname);
		    }
	    }

	    // allow additional checking of the configuration
	    $this->debugConfigExtra();
    }
739459
function _get_addon_info_filter( $data, $action = '', $args = null ) {
            $this->_logger->entrance();

            $parent_plugin_id = fs_request_get( 'parent_plugin_id', $this->_fs->get_id() );

            if ( $this->_fs->get_id() != $parent_plugin_id ||
                 ( 'plugin_information' !== $action ) ||
                 ! isset( $args->slug )
            ) {
                return $data;
            }

            // Find add-on by slug.
            $selected_addon = $this->_fs->get_addon_by_slug( $args->slug, WP_FS__DEV_MODE );

            if ( false === $selected_addon ) {
                return $data;
            }

            if ( ! isset( $selected_addon->info ) ) {
                // Setup some default info.
                $selected_addon->info                  = new stdClass();
                $selected_addon->info->selling_point_0 = 'Selling Point 1';
                $selected_addon->info->selling_point_1 = 'Selling Point 2';
                $selected_addon->info->selling_point_2 = 'Selling Point 3';
                $selected_addon->info->description     = '<p>Tell your users all about your add-on</p>';
            }

            fs_enqueue_local_style( 'fs_addons', '/admin/add-ons.css' );

            $data = $args;

            $has_free_plan = false;
            $has_paid_plan = false;

            // Load add-on pricing.
            $has_pricing  = false;
            $has_features = false;
            $plans        = false;

            $result = $this->_fs->get_api_plugin_scope()->get( $this->_fs->add_show_pending( "/addons/{$selected_addon->id}/pricing.json?type=visible" ) );

            if ( ! isset( $result->error ) ) {
                $plans = $result->plans;

                if ( is_array( $plans ) ) {
                    for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) {
                        $pricing  = isset( $plans[ $i ]->pricing ) ? $plans[ $i ]->pricing : null;
                        $features = isset( $plans[ $i ]->features ) ? $plans[ $i ]->features : null;

                        $plans[ $i ] = new FS_Plugin_Plan( $plans[ $i ] );
                        $plan        = $plans[ $i ];

                        if ( 'free' == $plans[ $i ]->name ||
                             ! is_array( $pricing ) ||
                             0 == count( $pricing )
                        ) {
                            $has_free_plan = true;
                        }

                        if ( is_array( $pricing ) && 0 < count( $pricing ) ) {
                            $has_paid_plan = true;

                            foreach ( $pricing as &$prices ) {
                                $prices = new FS_Pricing( $prices );
                            }

                            $plan->pricing = $pricing;

                            $has_pricing = true;
                        }

                        if ( is_array( $features ) && 0 < count( $features ) ) {
                            $plan->features = $features;

                            $has_features = true;
                        }
                    }
                }
            }

            $latest = null;

            if ( ! $has_paid_plan && $selected_addon->is_wp_org_compliant ) {
                $repo_data = FS_Plugin_Updater::_fetch_plugin_info_from_repository(
                    'plugin_information', (object) array(
                    'slug'   => $selected_addon->slug,
                    'is_ssl' => is_ssl(),
                    'fields' => array(
                        'banners'         => true,
                        'reviews'         => true,
                        'downloaded'      => false,
                        'active_installs' => true
                    )
                ) );

                if ( ! empty( $repo_data ) ) {
                    $data                 = $repo_data;
                    $data->wp_org_missing = false;
                } else {
                    // Couldn't find plugin on .org.
                    $selected_addon->is_wp_org_compliant = false;

                    // Plugin is missing, not on Freemius nor WP.org.
                    $data->wp_org_missing = true;
                }

                $data->fs_missing = ( ! $has_free_plan || $data->wp_org_missing );
            } else {
                $data->wp_org_missing = false;

                $current_addon_version = false;
                if ( $this->_fs->is_addon_activated( $selected_addon->id ) ) {
                    $current_addon_version = $this->_fs->get_addon_instance( $selected_addon->id )->get_plugin_version();
                } else if ( $this->_fs->is_addon_installed( $selected_addon->id ) ) {
                    $addon_plugin_data = get_plugin_data(
                        ( WP_PLUGIN_DIR . '/' . $this->_fs->get_addon_basename( $selected_addon->id ) ),
                        false,
                        false
                    );

                    if ( ! empty( $addon_plugin_data ) ) {
                        $current_addon_version = $addon_plugin_data['Version'];
                    }
                }

                // Fetch latest version from Freemius.
                $latest = $this->_fs->_fetch_latest_version(
                    $selected_addon->id,
                    true,
                    WP_FS__TIME_24_HOURS_IN_SEC,
                    $current_addon_version
                );

                if ( $has_paid_plan ) {
                    $data->checkout_link = $this->_fs->checkout_url();
                }
                if ( $has_free_plan ) {
                    $data->download_link = $this->_fs->_get_latest_download_local_url( $selected_addon->id );
                }

                $data->fs_missing = ( false === $latest );


                // Fetch as much as possible info from local files.
                $plugin_local_data = $this->_fs->get_plugin_data();
                $data->author      = $plugin_local_data['Author'];

                if ( ! empty( $selected_addon->info->banner_url ) ) {
                    $data->banners = array(
                        'low' => $selected_addon->info->banner_url,
                    );
                }

                if ( ! empty( $selected_addon->info->screenshots ) ) {
                    $view_vars                     = array(
                        'screenshots' => $selected_addon->info->screenshots,
                        'plugin'      => $selected_addon,
                    );
                    $data->sections['screenshots'] = fs_get_template( '/plugin-info/screenshots.php', $view_vars );
                }

                if ( is_object( $latest ) ) {
                    $data->version      = $latest->version;
                    $data->last_updated = $latest->created;
                    $data->requires     = $latest->requires_platform_version;
                    $data->tested       = $latest->tested_up_to_version;
                } else {
                    // Add dummy version.
                    $data->version = '1.0.0';

                    // Add message to developer to deploy the plugin through Freemius.
                }
            }

            $data->name = $selected_addon->title;
            $view_vars  = array( 'plugin' => $selected_addon );

            if ( is_object( $latest ) && isset( $latest->readme ) && is_object( $latest->readme ) ) {
                $latest_version_readme_data = $latest->readme;
                if ( isset( $latest_version_readme_data->sections ) ) {
                    $data->sections = (array) $latest_version_readme_data->sections;
                } else {
                    $data->sections = array();
                }
            }

            $data->sections['description'] = fs_get_template( '/plugin-info/description.php', $view_vars );

            if ( $has_pricing ) {
                // Add plans to data.
                $data->plans = $plans;

                if ( $has_features ) {
                    $view_vars                  = array(
                        'plans'  => $plans,
                        'plugin' => $selected_addon,
                    );
                    $data->sections['features'] = fs_get_template( '/plugin-info/features.php', $view_vars );
                }
            }

            $data->has_free_plan       = $has_free_plan;
            $data->has_paid_plan       = $has_paid_plan;
            $data->is_paid             = $has_paid_plan;
            $data->is_wp_org_compliant = $selected_addon->is_wp_org_compliant;

            return $data;
        }
1153589
public function get_info($plugin_name)
    {
        static $composer_lock, $license_uris = array(
            'Apache'       => 'http://www.apache.org/licenses/LICENSE-2.0.html',
            'Apache-2'     => 'http://www.apache.org/licenses/LICENSE-2.0.html',
            'Apache-1'     => 'http://www.apache.org/licenses/LICENSE-1.0',
            'Apache-1.1'   => 'http://www.apache.org/licenses/LICENSE-1.1',
            'GPL'          => 'http://www.gnu.org/licenses/gpl.html',
            'GPLv2'        => 'http://www.gnu.org/licenses/gpl-2.0.html',
            'GPL-2.0'      => 'http://www.gnu.org/licenses/gpl-2.0.html',
            'GPLv3'        => 'http://www.gnu.org/licenses/gpl-3.0.html',
            'GPLv3+'       => 'http://www.gnu.org/licenses/gpl-3.0.html',
            'GPL-3.0'      => 'http://www.gnu.org/licenses/gpl-3.0.html',
            'GPL-3.0+'     => 'http://www.gnu.org/licenses/gpl.html',
            'GPL-2.0+'     => 'http://www.gnu.org/licenses/gpl.html',
            'AGPLv3'       => 'http://www.gnu.org/licenses/agpl.html',
            'AGPLv3+'      => 'http://www.gnu.org/licenses/agpl.html',
            'AGPL-3.0'     => 'http://www.gnu.org/licenses/agpl.html',
            'LGPL'         => 'http://www.gnu.org/licenses/lgpl.html',
            'LGPLv2'       => 'http://www.gnu.org/licenses/lgpl-2.0.html',
            'LGPLv2.1'     => 'http://www.gnu.org/licenses/lgpl-2.1.html',
            'LGPLv3'       => 'http://www.gnu.org/licenses/lgpl.html',
            'LGPL-2.0'     => 'http://www.gnu.org/licenses/lgpl-2.0.html',
            'LGPL-2.1'     => 'http://www.gnu.org/licenses/lgpl-2.1.html',
            'LGPL-3.0'     => 'http://www.gnu.org/licenses/lgpl.html',
            'LGPL-3.0+'    => 'http://www.gnu.org/licenses/lgpl.html',
            'BSD'          => 'http://opensource.org/licenses/bsd-license.html',
            'BSD-2-Clause' => 'http://opensource.org/licenses/BSD-2-Clause',
            'BSD-3-Clause' => 'http://opensource.org/licenses/BSD-3-Clause',
            'FreeBSD'      => 'http://opensource.org/licenses/BSD-2-Clause',
            'MIT'          => 'http://www.opensource.org/licenses/mit-license.php',
            'PHP'          => 'http://opensource.org/licenses/PHP-3.0',
            'PHP-3'        => 'http://www.php.net/license/3_01.txt',
            'PHP-3.0'      => 'http://www.php.net/license/3_0.txt',
            'PHP-3.01'     => 'http://www.php.net/license/3_01.txt',
        );

        $dir  = dir($this->dir);
        $fn   = unslashify($dir->path) . "/$plugin_name/$plugin_name.php";
        $info = false;

        if (!class_exists($plugin_name, false)) {
            if (is_readable($fn)) {
                include($fn);
            }
            else {
                return false;
            }
        }

        if (class_exists($plugin_name)) {
            $info = $plugin_name::info();
        }

        // fall back to composer.json file
        if (!$info) {
            $composer = INSTALL_PATH . "/plugins/$plugin_name/composer.json";
            if (is_readable($composer) && ($json = @json_decode(file_get_contents($composer), true))) {
                list($info['vendor'], $info['name']) = explode('/', $json['name']);
                $info['version'] = $json['version'];
                $info['license'] = $json['license'];
                $info['uri']     = $json['homepage'];
                $info['require'] = array_filter(array_keys((array)$json['require']), function($pname) {
                    if (strpos($pname, '/') == false) {
                        return false;
                    }
                    list($vendor, $name) = explode('/', $pname);
                    return !($name == 'plugin-installer' || $vendor == 'pear-pear');
                });
            }

            // read local composer.lock file (once)
            if (!isset($composer_lock)) {
                $composer_lock = @json_decode(@file_get_contents(INSTALL_PATH . "/composer.lock"), true);
                if ($composer_lock['packages']) {
                    foreach ($composer_lock['packages'] as $i => $package) {
                        $composer_lock['installed'][$package['name']] = $package;
                    }
                }
            }

            // load additional information from local composer.lock file
            if ($lock = $composer_lock['installed'][$json['name']]) {
                $info['version'] = $lock['version'];
                $info['uri']     = $lock['homepage'] ?: $lock['source']['uri'];
                $info['src_uri'] = $lock['dist']['uri'] ?: $lock['source']['uri'];
            }
        }

        // fall back to package.xml file
        if (!$info) {
            $package = INSTALL_PATH . "/plugins/$plugin_name/package.xml";
            if (is_readable($package) && ($file = file_get_contents($package))) {
                $doc = new DOMDocument();
                $doc->loadXML($file);
                $xpath = new DOMXPath($doc);
                $xpath->registerNamespace('rc', "http://pear.php.net/dtd/package-2.0");

                // XPaths of plugin metadata elements
                $metadata = array(
                    'name'    => 'string(//rc:package/rc:name)',
                    'version' => 'string(//rc:package/rc:version/rc:release)',
                    'license' => 'string(//rc:package/rc:license)',
                    'license_uri' => 'string(//rc:package/rc:license/@uri)',
                    'src_uri' => 'string(//rc:package/rc:srcuri)',
                    'uri'     => 'string(//rc:package/rc:uri)',
                );

                foreach ($metadata as $key => $path) {
                    $info[$key] = $xpath->evaluate($path);
                }

                // dependent required plugins (can be used, but not included in config)
                $deps = $xpath->evaluate('//rc:package/rc:dependencies/rc:required/rc:package/rc:name');
                for ($i = 0; $i < $deps->length; $i++) {
                    $dn = $deps->item($i)->nodeValue;
                    $info['require'][] = $dn;
                }
            }
        }

        // At least provide the name
        if (!$info && class_exists($plugin_name)) {
            $info = array('name' => $plugin_name, 'version' => '--');
        }
        else if ($info['license'] && empty($info['license_uri']) && ($license_uri = $license_uris[$info['license']])) {
            $info['license_uri'] = $license_uri;
        }

        return $info;
    }
789729
public function getPluginInfo($plugin)
    {
        $zipArchive = $this->openZipArchive($plugin);

        if ($path = $this->searchForPluginJson($zipArchive)) {
            $jsonString = $this->getFileFromZip($path, $zipArchive);
            return json_decode($jsonString, true);
        } elseif ($path = $this->searchForPluginXml($zipArchive)) {
            $xmlString = $this->getFileFromZip($path, $zipArchive);
            return $this->readXml($xmlString);
        } else {
            throw new \RuntimeException('Plugin info file not found in zip (plugin.json or plugin.xml)');
        }
    }
1004031
function get_plugin_data() {
            if ( ! isset( $this->_plugin_data ) ) {
                self::require_plugin_essentials();

                if ( $this->is_plugin() ) {
                    /**
                     * @author Vova Feldman (@svovaf)
                     * @since  1.2.0 When using get_plugin_data() do NOT translate plugin data.
                     *
                     * @link   https://github.com/Freemius/wordpress-sdk/issues/77
                     */
                    $plugin_data = get_plugin_data(
                        $this->_plugin_main_file_path,
                        false,
                        false
                    );
                } else {
                    $theme_data = wp_get_theme();

                    if ( $this->_plugin_basename !== $theme_data->get_stylesheet() && is_child_theme() ) {
                        $parent_theme = $theme_data->parent();

                        if ( ( $parent_theme instanceof WP_Theme ) && $this->_plugin_basename === $parent_theme->get_stylesheet() ) {
                            $theme_data = $parent_theme;
                        }
                    }

                    $plugin_data = array(
                        'Name'        => $theme_data->get( 'Name' ),
                        'Version'     => $theme_data->get( 'Version' ),
                        'Author'      => $theme_data->get( 'Author' ),
                        'Description' => $theme_data->get( 'Description' ),
                        'PluginURI'   => $theme_data->get( 'ThemeURI' ),
                    );
                }

                $this->_plugin_data = $plugin_data;
            }

            return $this->_plugin_data;
        }
1244854
public function init($args)
    {
        if (empty($args)) {
            return;
        }

        // Special case
        if (is_bool($args) && $args) {
            $args = $this->available;
        }

        // Iterate on all
        foreach ($args as $plugin => $settings) {
            $plugin = strtolower($plugin);

            if (!array_key_exists($plugin, $this->available)) {
                continue;
            }

            $plugin = str_replace('_', '-', $plugin);

            $function = Helpers::toFunctionFormat($plugin);
            $function = 'plugin'.ucfirst($function);
            $this->$function($settings);
        }
    }