Пример #1
0
function _pp_file_filtering_promo()
{
    if (0 === validate_plugin("pp-file-url-filter/pp-file-url-filter.php")) {
        $msg = __('To block direct URL access to attachments of unreadable posts, activate the PP File URL Filter plugin.', 'pp');
    } elseif (true == pp_key_status()) {
        $msg = sprintf(__('To block direct URL access to attachments of unreadable posts, %1$sinstall%2$s the PP File URL Filter plugin.', 'pp'), '<a href="admin.php?page=pp-settings&pp_tab=install">', '</a>');
    } else {
        $msg = sprintf(__('To block direct URL access to attachments of unreadable posts, %1$senter%2$s or %3$spurchase%4$s a support key and install the PP File URL Filter plugin.', 'pp'), '<a href="admin.php?page=pp-settings&pp_tab=install">', '</a>', '<a href="http://presspermit.com/purchase">', '</a>');
    }
    ?>
	<script type="text/javascript">
	/* <![CDATA[ */
	jQuery(document).ready( function($) {
	$('#posts-filter').after('<a href="#" class="pp-file-filtering-promo" style="margin-left:5px"><?php 
    _e('Block URL access', 'pp');
    ?>
</a><span class="pp-ext-promo" style="display:none;"><?php 
    echo $msg;
    ?>
</span>');
	
	$('a.pp-file-filtering-promo').click(function() {
		$(this).hide().next('span').show();
		return false;
	});
	
	});
	/* ]]> */
	</script>
	<?php 
}
Пример #2
0
/**
 * Deactivate a plugin
 *
 * @since 1.0
 *
 * @param string $plugin_file Relative path to plugin
 * @return bool Whether plugin was deactivated
 */
function deactivate_plugin($plugin_file)
{
    global $current_plugins;
    if (!isset($current_plugins[md5($plugin_file)])) {
        return false;
    }
    if (!validate_plugin($plugin_file)) {
        return false;
    }
    unset($current_plugins[md5($plugin_file)]);
    $data = new DataHandler();
    $data->save('plugins.data', serialize($current_plugins));
    return true;
}
    /**
     * Display a notice if AudioTheme isn't active.
     *
     * @since 1.0.0
     */
    public function display_notice()
    {
        $user_id = get_current_user_id();
        // Return early if user already dismissed the notice.
        if ('dismissed' == get_user_meta($user_id, $this->notice_key(), true)) {
            return;
        }
        ?>
		<div id="audiotheme-required-notice" class="error">
			<p>
				<?php 
        echo $this->strings['notice'];
        if (0 === validate_plugin('audiotheme/audiotheme.php')) {
            $activate_url = wp_nonce_url('plugins.php?action=activate&amp;plugin=audiotheme/audiotheme.php', 'activate-plugin_audiotheme/audiotheme.php');
            printf(' <a href="%s"><strong>%s</strong></a>', esc_url($activate_url), $this->strings['activate']);
        } else {
            printf(' <a href="https://audiotheme.com/view/audiotheme/"><strong>%s</strong></a>', $this->strings['learn_more']);
        }
        $dismiss_url = wp_nonce_url(add_query_arg(get_template(), 'dismiss-notice'), $this->dismiss_notice_action());
        printf(' <a href="%s" class="dismiss" style="float: right">%s</a>', esc_url($dismiss_url), $this->strings['dismiss']);
        ?>
			</p>
		</div>
		<script type="text/javascript">
		jQuery( '#audiotheme-required-notice' ).on( 'click', '.dismiss', function( e ) {
			var $notice = jQuery( this ).closest( '.error' );

			e.preventDefault();

			jQuery.get( ajaxurl, {
				action: '<?php 
        echo $this->dismiss_notice_action();
        ?>
',
				_wpnonce: '<?php 
        echo wp_create_nonce($this->dismiss_notice_action());
        ?>
'
			}, function() {
				$notice.slideUp();
			});
		});
		</script>
		<?php 
    }
function _ppc_item_ui_hints($for_item_type)
{
    if ('attachment' == $for_item_type && !defined('PPFF_VERSION')) {
        if (0 === validate_plugin("pp-file-url-filter/pp-file-url-filter.php")) {
            $msg = __('To block direct access to unreadable files, activate the PP File URL Filter plugin.', 'pp');
        } elseif (true == pp_key_status()) {
            $msg = sprintf(__('To block direct access to unreadable files, %1$sinstall%2$s the PP File URL Filter plugin.', 'pp'), '<a href="admin.php?page=pp-settings&pp_tab=install">', '</a>');
        } else {
            $msg = sprintf(__('To block direct access to unreadable files, %1$spurchase a support key%2$s and install the PP File URL Filter plugin.', 'pp'), '<a href="http://presspermit.com/purchase">', '</a>');
        }
        echo "<div class='pp-ext-promo' style='padding:0.5em'>{$msg}</div>";
    }
    if (!defined('PPCE_VERSION')) {
        if (0 === validate_plugin("pp-collaborative-editing/pp-collaborative-editing.php")) {
            $msg = __('To customize editing permissions, activate the PP Collaborative Editing plugin.', 'pp');
        } elseif (true == pp_key_status()) {
            $msg = sprintf(__('To customize editing permissions, %1$sinstall%2$s the PP Collaborative Editing plugin.', 'pp'), '<a href="admin.php?page=pp-settings&pp_tab=install">', '</a>');
        } else {
            $msg = sprintf(__('To customize editing permissions, %1$spurchase a support key%2$s and install the PP Collaborative Editing plugin.', 'pp'), '<a href="http://presspermit.com/purchase">', '</a>');
        }
        echo "<div class='pp-ext-promo' style='padding:0.5em;margin-top:0'>{$msg}</div>";
    }
}
Пример #5
0
<?php 
        //echo esc_html( __( 'Posts with a custom Visibility or Editability require a corresponding Permission Group role assignment.', 'pp' ) );
        $pp_groups_list_table->search_box(__('Search Groups', 'pp'), 'group');
        ?>

<?php 
        $pp_groups_list_table->display();
        ?>

</form>

<br class="clear" />

<?php 
        if (defined('BP_VERSION') && !defined('PPCE_VERSION') && pp_get_option('display_extension_hints')) {
            if (0 === validate_plugin("pp-buddypress-role-groups/pp-buddypress-role-groups.php")) {
                $msg = __('To assign roles or exceptions to BuddyPress groups, activate the PP BuddyPress Role Groups', 'pp');
            } elseif (true == pp_key_status()) {
                $msg = sprintf(__('To assign roles or exceptions to BuddyPress groups, %1$sinstall%2$s the PP BuddyPress Role Groups plugin.', 'pp'), '<a href="admin.php?page=pp-settings&pp_tab=install">', '</a>');
            } else {
                $msg = sprintf(__('To assign roles or exceptions to BuddyPress groups, %1$senter%2$s or %3$spurchase%4$s a support key and install the PP BuddyPress Role Groups plugin.', 'pp'), '<a href="admin.php?page=pp-settings&pp_tab=install">', '</a>', '<a href="http://presspermit.com/purchase">', '</a>');
            }
            echo "<div class='pp-ext-promo'>{$msg}</div>";
        }
        ?>

</div>
<?php 
        break;
}
// end of the $doaction switch
Пример #6
0
function _pp_post_status_promo()
{
    if (!defined('PPS_VERSION')) {
        if (0 === validate_plugin("pp-custom-post-statuses/pp-custom-post-statuses.php")) {
            $msg = __('To define custom privacy statuses, activate the PP Custom Post Statuses plugin.', 'pp');
        } elseif (true == pp_key_status()) {
            $msg = sprintf(__('To define custom privacy statuses, %1$sinstall%2$s the PP Custom Post Statuses plugin.', 'pp'), '<a href="admin.php?page=pp-settings&pp_tab=install">', '</a>');
        } else {
            $msg = sprintf(__('To define custom privacy statuses, %1$senter%2$s or %3$spurchase%4$s a support key and install the PP Custom Post Statuses plugin.', 'pp'), '<a href="admin.php?page=pp-settings&pp_tab=install">', '</a>', '<a href="http://presspermit.com/purchase">', '</a>');
        }
        ?>
		<script type="text/javascript">
		/* <![CDATA[ */
		jQuery(document).ready( function($) {
		$('#visibility-radio-private').next('label').after('<a href="#" class="pp-custom-privacy-promo" style="margin-left:5px"><?php 
        _e('define custom privacy', 'pp');
        ?>
</a><span class="pp-ext-promo" style="display:none;"><br /><?php 
        echo $msg;
        ?>
</span>');
		
		$('a.pp-custom-privacy-promo').click(function() {
			$(this).hide().next('span').show();
			return false;
		});
		
		});
		/* ]]> */
		</script>
		<?php 
    }
    if (!defined('PPS_VERSION') || !defined('PPCE_VERSION')) {
        $need_exts = array();
        if (!defined('PPCE_VERSION')) {
            $need_exts[] = 'PP Collaborative Editing Pack';
        }
        if (!defined('PPS_VERSION')) {
            $need_exts[] = 'PP Custom Post Statuses';
        }
        $need_exts = implode(' and ', $need_exts);
        if (true == pp_key_status()) {
            $msg = sprintf(__('To define custom moderation statuses, %1$sactivate%2$s %3$s.', 'pp'), '<a href="admin.php?page=pp-settings&pp_tab=install">', '</a>', $need_exts);
        } else {
            $msg = sprintf(__('To define custom moderation statuses, %1$senter%2$s or %3$spurchase%4$s a Press Permit support key. Then install %5$s.', 'pp'), '<a href="admin.php?page=pp-settings&pp_tab=install">', '</a>', '<a href="http://presspermit.com/purchase">', '</a>', $need_exts);
        }
        ?>
		<script type="text/javascript">
		/* <![CDATA[ */
		jQuery(document).ready( function($) {
		$('a.edit-post-status').after('<a href="#" class="pp-custom-moderation-promo" style="margin-left:5px"><?php 
        _e('Customize', 'pp');
        ?>
</a><span class="pp-ext-promo" style="display:none;"><br /><?php 
        echo $msg;
        ?>
</span>');
		
		$('a.pp-custom-moderation-promo').click(function() {
			$(this).hide().next('span').show();
			return false;
		});
		
		});
		/* ]]> */
		</script>
		<?php 
    }
}
    function options_ui()
    {
        global $pp_default_options, $pp_options_ui;
        $ui = $pp_options_ui;
        $tab = 'core';
        $section = 'permissions';
        // --- PERMISSIONS SECTION ---
        if (!empty($ui->form_options[$tab][$section])) {
            ?>
			<tr><th scope="row"><?php 
            echo $ui->section_captions[$tab][$section];
            ?>
</th><td>
			<?php 
            $hint = __('If disabled, manually "blocked" posts can be unblocked by Category / Term Exceptions.  Enabling this setting will provide more intuitive behavior, but may require configuration review and testing on prior installations.', 'pp');
            $ui->option_checkbox('post_blockage_priority', $tab, $section, $hint);
            ?>
			</td></tr>
		<?php 
        }
        // any options accessable in this section
        // --- FILTERED TAXONOMIES / POST TYPES SECTION ---
        foreach (array('object' => 'post_types', 'term' => 'taxonomies') as $scope => $section) {
            if (empty($ui->form_options[$tab][$section])) {
                continue;
            }
            ?>
			<tr><th scope="row"><?php 
            echo $ui->section_captions[$tab][$section];
            ?>
</th><td>
			<?php 
            if ('term' == $scope) {
                $option_name = 'enabled_taxonomies';
                _e('Modify permissions for these Taxonomies:', 'pp');
                echo '<br />';
                $types = get_taxonomies(array('public' => true), 'object');
                if ($omit_types = apply_filters('pp_unfiltered_taxonomies', array('post_status', 'topic-tag'))) {
                    // avoid confusion with Edit Flow administrative taxonomy
                    $types = array_diff_key($types, array_fill_keys((array) $omit_types, true));
                }
                $hidden_types = apply_filters('pp_hidden_taxonomies', array());
                $types = _pp_order_types($types);
            } else {
                $option_name = 'enabled_post_types';
                _e('Modify permissions for these Post Types:', 'pp');
                $types = get_post_types(array('public' => true), 'object');
                if ($omit_types = apply_filters('pp_unfiltered_post_types', array())) {
                    $types = array_diff_key($types, array_fill_keys((array) $omit_types, true));
                }
                $hidden_types = apply_filters('pp_hidden_post_types', array());
                $types = _pp_order_types($types);
            }
            $ui->all_otype_options[] = $option_name;
            if (isset($pp_default_options[$option_name])) {
                if (!($enabled = $ui->get_option($option_name))) {
                    $enabled = array();
                }
                foreach ($types as $key => $obj) {
                    if (!$key) {
                        continue;
                    }
                    $id = $option_name . '-' . $key;
                    $name = $option_name . "[{$key}]";
                    ?>
					
					<?php 
                    if ('nav_menu' == $key) {
                        ?>
						<input name="<?php 
                        echo $name;
                        ?>
" type="hidden" id="<?php 
                        echo $id;
                        ?>
" value="1" />
					<?php 
                    } else {
                        ?>
						<?php 
                        if (isset($hidden_types[$key])) {
                            ?>
							<input name="<?php 
                            echo $name;
                            ?>
" type="hidden" value="<?php 
                            echo $hidden_types[$key];
                            ?>
" />
						<?php 
                        } else {
                            ?>
							<div class="agp-vtight_input">
							<input name="<?php 
                            echo $name;
                            ?>
" type="hidden" value="0" />
							<label for="<?php 
                            echo $id;
                            ?>
" title="<?php 
                            echo $key;
                            ?>
">
							<input name="<?php 
                            echo $name;
                            ?>
" type="checkbox" id="<?php 
                            echo $id;
                            ?>
" value="1" <?php 
                            checked('1', !empty($enabled[$key]));
                            ?>
 />
							
							<?php 
                            if (isset($obj->labels_pp)) {
                                echo $obj->labels_pp->name;
                            } elseif (isset($obj->labels->name)) {
                                echo $obj->labels->name;
                            } else {
                                echo $key;
                            }
                            echo '</label></div>';
                        }
                    }
                    // displaying checkbox UI
                }
                // end foreach src_otype
            }
            // endif default option isset
            if ('object' == $scope) {
                if (pp_get_option('display_hints')) {
                    if ($types = get_post_types(array('public' => true, '_builtin' => false))) {
                        ?>
						<div class="pp-subtext">
						<?php 
                        printf(__('<span class="pp-important">Note</span>: Type-specific capability requirements (i.e. edit_things instead of edit_posts) will be imposed. If PP filters Media or a custom type, non-Administrators <span class="pp-important">will need a corresponding %1$ssupplemental role%2$s for editing</span>. Adding the type-specific capabilities directly to a WP role definition also works.'), "<a href='" . admin_url('?page=pp-groups') . "'>", '</a>');
                        ?>
						</div>
						
						<?php 
                        if (in_array('forum', $types) && !defined('PPP_VERSION') && pp_get_option('display_extension_hints')) {
                            ?>
							<div class="pp-subtext" style="margin-top:10px">
							<?php 
                            if (pp_key_active()) {
                                _e('To customize bbPress forum permissions, activate PP Compatibility Pack.', 'pp');
                            } else {
                                _e('To customize bbPress forum permissions, activate your Press Permit Pro support key.', 'pp');
                            }
                            ?>
							</div>
						<?php 
                        }
                        ?>
					<?php 
                    }
                }
                if (pp_wp_ver('3.5')) {
                    echo '<br /><div>';
                    $hint = __('If enabled, the create_posts, create_pages, etc. capabilities will be enforced for all Filtered Post Types.  <strong>NOTE: You will also need to use a WordPress Role Editor</strong> such as Capability Manager Enhanced to add the create_posts capability to desired roles.', 'pp');
                    $ret = $ui->option_checkbox('define_create_posts_cap', $tab, $section, $hint, '');
                    echo '</div>';
                }
            }
            ?>
			</td></tr>
			<?php 
        }
        // end foreach scope
        $section = 'front_end';
        // --- FRONT END SECTION ---
        if (!empty($ui->form_options[$tab][$section])) {
            ?>
			<tr><th scope="row"><?php 
            echo $ui->section_captions[$tab][$section];
            ?>
</th><td>
			<?php 
            $hint = __('Remove the "Private:" and "Protected" prefix from Post, Page titles', 'pp');
            $ui->option_checkbox('strip_private_caption', $tab, $section, $hint);
            ?>
			</td></tr>
		<?php 
        }
        // any options accessable in this section
        $section = 'admin';
        // --- BACK END SECTION ---
        if (!empty($ui->form_options[$tab][$section])) {
            ?>
			<tr><th scope="row"><?php 
            echo $ui->section_captions[$tab][$section];
            ?>
</th><td>
			<?php 
            $hint = 0 === validate_plugin("pp-collaborative-editing/pp-collaborative-editing.php") ? __('Note: pending further development, uneditable posts will always be hidden if the PP Collaborative Editing extension is active', 'pp') : '';
            if (defined('PPCE_VERSION')) {
                $args = array('val' => 1, 'disabled' => true, 'no_storage' => true);
            }
            $ui->option_checkbox('admin_hide_uneditable_posts', $tab, $section, $hint, '', $args);
            ?>
			</td></tr>
		<?php 
        }
        // any options accessable in this section
        $section = 'user_profile';
        // --- USER PROFILE SECTION ---
        if (!empty($ui->form_options[$tab][$section])) {
            ?>
			<tr><th scope="row"><?php 
            echo $ui->section_captions[$tab][$section];
            ?>
</th><td>
			<?php 
            $hint = '';
            if (!defined('PP_MULTISITE')) {
                $ui->option_checkbox('new_user_groups_ui', $tab, $section, $hint, '<br />');
            }
            $hint = __('note: Groups and Roles are always displayed in "Edit User"', 'pp');
            $ui->option_checkbox('display_user_profile_groups', $tab, $section);
            $ui->option_checkbox('display_user_profile_roles', $tab, $section, $hint);
            ?>
				
			</td></tr>
		<?php 
        }
        // any options accessable in this section
        $section = 'db_maint';
        if (get_option('pp_need_group_index_drop')) {
            ?>
			<tr><th scope="row"><?php 
            echo $ui->section_captions[$tab][$section];
            ?>
</th><td>
			<?php 
            $hint = '';
            $ui->option_checkbox('do_group_index_drop', $tab, $section, $hint, '<br />', array('no_storage' => true));
            ?>

			</td></tr>
		<?php 
        }
    }
Пример #8
0
                 deactivate_plugins($file, true);
             }
             update_option('recently_activated', array($file => time()) + (array) get_option('recently_activated'));
             wp_redirect(add_query_arg('_wpnonce', wp_create_nonce('edit-plugin-test_' . $file), "plugin-editor.php?file={$file}&liveupdate=1&scrollto={$scrollto}&networkwide=" . $network_wide));
             exit;
         }
         wp_redirect(self_admin_url("plugin-editor.php?file={$file}&a=te&scrollto={$scrollto}"));
     } else {
         wp_redirect(self_admin_url("plugin-editor.php?file={$file}&scrollto={$scrollto}"));
     }
     exit;
     break;
 default:
     if (isset($_GET['liveupdate'])) {
         check_admin_referer('edit-plugin-test_' . $file);
         $error = validate_plugin($file);
         if (is_wp_error($error)) {
             wp_die($error);
         }
         if (!empty($_GET['networkwide']) && !is_plugin_active_for_network($file) || !is_plugin_active($file)) {
             activate_plugin($file, "plugin-editor.php?file={$file}&phperror=1", !empty($_GET['networkwide']));
         }
         // we'll override this later if the plugin can be included without fatal error
         wp_redirect(self_admin_url("plugin-editor.php?file={$file}&a=te&scrollto={$scrollto}"));
         exit;
     }
     // List of allowable extensions
     $editable_extensions = array('php', 'txt', 'text', 'js', 'css', 'html', 'htm', 'xml', 'inc', 'include');
     $editable_extensions = (array) apply_filters('editable_extensions', $editable_extensions);
     if (!is_file($real_file)) {
         wp_die(sprintf('<p>%s</p>', __('No such file exists! Double check the name and try again.')));
Пример #9
0
/**
 * Validate active plugins
 *
 * Validate all active plugins, deactivates invalid and
 * returns an array of deactivated ones.
 *
 * @since 2.5.0
 * @return array invalid plugins, plugin as key, error as value
 */
function validate_active_plugins() {
	$plugins = get_option( 'active_plugins', array() );
	// Validate vartype: array.
	if ( ! is_array( $plugins ) ) {
		update_option( 'active_plugins', array() );
		$plugins = array();
	}

	if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) {
		$network_plugins = (array) get_site_option( 'active_sitewide_plugins', array() );
		$plugins = array_merge( $plugins, array_keys( $network_plugins ) );
	}

	if ( empty( $plugins ) )
		return array();

	$invalid = array();

	// Invalid plugins get deactivated.
	foreach ( $plugins as $plugin ) {
		$result = validate_plugin( $plugin );
		if ( is_wp_error( $result ) ) {
			$invalid[$plugin] = $result;
			deactivate_plugins( $plugin, true );
		}
	}
	return $invalid;
}
Пример #10
0
function validate_active_plugins()
{
    $check_plugins = get_option('active_plugins');
    // Sanity check.  If the active plugin list is not an array, make it an
    // empty array.
    if (!is_array($check_plugins)) {
        update_option('active_plugins', array());
        return;
    }
    //Invalid is any plugin that is deactivated due to error.
    $invalid = array();
    // If a plugin file does not exist, remove it from the list of active
    // plugins.
    foreach ($check_plugins as $check_plugin) {
        $result = validate_plugin($check_plugin);
        if (is_wp_error($result)) {
            $invalid[$check_plugin] = $result;
            deactivate_plugins($check_plugin, true);
        }
    }
    return $invalid;
}
Пример #11
0
    function display($agent_type, $id_suffix, $current_selections = array(), $args = array())
    {
        $defaults = array('agent_id' => 0, 'context' => '', 'label_select' => _x('Select &gt;', 'user', 'pp'), 'label_unselect' => _x('&lt; Unselect', 'user', 'pp'), 'label_selections' => __('Current Selections:', 'pp'), 'display_stored_selections' => true, 'create_dropdowns' => false, 'width' => '', 'width_current' => '', 'label_headline' => true, 'multi_select' => true, 'use_selection_js' => true);
        $args = apply_filters('pp_agents_selection_ui_args', array_merge($defaults, $args), $agent_type, $id_suffix);
        extract($args, EXTR_SKIP);
        $width = $width ? "width:{$width}px;" : '';
        $this->register_ajax_js($agent_type, $id_suffix, $context, $agent_id, $args);
        if ('user' == $agent_type) {
            if (defined('PP_USER_LASTNAME_SEARCH') && !defined('PP_USER_SEARCH_FIELD')) {
                $default_search_field = 'last_name';
            } elseif (defined('PP_USER_SEARCH_FIELD')) {
                $default_search_field = PP_USER_SEARCH_FIELD;
            } else {
                $default_search_field = '';
            }
        }
        if (true === $label_headline) {
            if ('user' == $agent_type) {
                if ($default_search_field) {
                    $search_caption = __(ucwords(str_replace('_', ' ', $default_search_field)), 'pp');
                    $label_headline = sprintf(__('Find Users by %s', 'pp'), $search_caption);
                } else {
                    $label_headline = __('Find Users', 'pp');
                }
            } else {
                $label_headline = __('Select Groups', 'pp');
            }
        }
        ?>
		<table id="pp-agent-selection_<?php 
        echo $id_suffix;
        ?>
-wrapper" class="pp-agents-selection">
		<tr><td id="pp-agent-selection_<?php 
        echo $id_suffix;
        ?>
 " style="vertical-align:top">
		<h4><?php 
        echo $label_headline;
        ?>
</h4>
		<input id="agent_search_text_<?php 
        echo $id_suffix;
        ?>
" type="text" size="8" />
		<button type="button" class="pp-agent-search-submit" id="agent_submit_<?php 
        echo $id_suffix;
        ?>
"><?php 
        echo __ppw("Search");
        ?>
</button>
		
		<?php 
        if ('user' == $agent_type) {
            ?>
			<br />
			<?php 
            $title = !defined('PP_USER_SEARCH_META_FIELDS') && pp_is_user_administrator() && pp_get_option('advanced_options') && pp_get_option('display_hints') ? __('For additional fields, define constant PP_USER_SEARCH_META_FIELDS', 'pp') : '';
            $fields = array('first_name' => __('First Name', 'pp'), 'last_name' => __('Last Name', 'pp'), 'nickname' => __('Nickname', 'pp'));
            if (defined('PP_USER_SEARCH_META_FIELDS')) {
                $custom_fields = str_replace(' ', '', PP_USER_SEARCH_META_FIELDS);
                $custom_fields = explode(',', $custom_fields);
                foreach ($custom_fields as $cfield) {
                    $fields[$cfield] = __(ucwords(str_replace('_', ' ', $cfield)), 'pp');
                }
            }
            if (isset($fields[$default_search_field])) {
                unset($fields[$default_search_field]);
            }
            $ilim = defined('PP_USER_SEARCH_META_FIELDS') ? 6 : 3;
            for ($i = 0; $i < $ilim; $i++) {
                ?>
				<div class="pp-user-meta-search" <?php 
                if ($i > 0 && empty($_GET["pp_search_user_meta_key_{$i}_{$id_suffix}"])) {
                    echo ' style="display:none;"';
                }
                ?>
>
				<select id="pp_search_user_meta_key_<?php 
                echo $i;
                ?>
_<?php 
                echo $id_suffix;
                ?>
">
				<option value=""><?php 
                _e('(user field)', 'pp');
                ?>
</option>
				<?php 
                foreach ($fields as $field => $lbl) {
                    ?>
					<option value="<?php 
                    echo $field;
                    ?>
"><?php 
                    echo $lbl;
                    ?>
</option>
				<?php 
                }
                ?>
				</select>
				&nbsp;
				<input id="pp_search_user_meta_val_<?php 
                echo $i;
                ?>
_<?php 
                echo $id_suffix;
                ?>
" type="text" <?php 
                if (empty($_GET["pp_search_user_meta_key_{$i}_{$id_suffix}"])) {
                    echo 'style="display:none"';
                }
                ?>
 title="<?php 
                echo $title;
                ?>
" size="8" />
				<?php 
                if ($i < $ilim - 1) {
                    ?>
				&nbsp;<span class="pp-usermeta-field-more" <?php 
                    if (empty($_GET["pp_search_user_meta_key_{$i}_{$id_suffix}"])) {
                        echo 'style="display:none"';
                    }
                    ?>
>+</span>
				<?php 
                }
                ?>
				</div>
			<?php 
            }
            ?>
		<?php 
        }
        ?>
		
		<?php 
        if ('user' == $agent_type && pp_get_option('user_search_by_role')) {
            ?>
			<select id="pp_search_role_<?php 
            echo $id_suffix;
            ?>
" class="pp-search-role">
			<option value=""><?php 
            _e('(any WP role)', 'pp');
            ?>
</option>
			<?php 
            wp_dropdown_roles();
            ?>
			</select>
		<?php 
        }
        ?>
		</td>
		
		<?php 
        if ($display_stored_selections) {
            ?>
			<td style="vertical-align:top" class="pp-members-current">
			</td>
		<?php 
        }
        ?>
		
		</tr>
		
		<tr><td>
		<h4><?php 
        _e('Search Results:', 'pp');
        ?>
<img class="waiting" style="display:none;float:right" src="<?php 
        echo esc_url(admin_url('images/wpspin_light.gif'));
        ?>
" alt="" /></h4>
		
		<select id="agent_results_<?php 
        echo $id_suffix;
        ?>
" class="pp_agent_results" <?php 
        if ($multi_select) {
            ?>
multiple="multiple" style="height:160px;<?php 
        } else {
            ?>
style="display:none;<?php 
        }
        echo $width;
        ?>
"></select>
		<span id="agent_msg_<?php 
        echo $id_suffix;
        ?>
"></span>
		</td>

		<?php 
        if ($display_stored_selections) {
            if ($width_current) {
                $width = "width:{$width_current}px;";
            }
            ?>
		<td class="pp-members-current">
		<h4><?php 
            echo $label_selections;
            ?>
</h4>
		
		<select id='<?php 
            echo $id_suffix;
            ?>
' name='<?php 
            echo $id_suffix;
            ?>
[]' multiple='multiple' style='height:160px;<?php 
            echo $width;
            ?>
'>
		
<?php 
            if ('user' == $agent_type) {
                $display_property = defined('PP_USER_RESULTS_DISPLAY_NAME') ? 'display_name' : 'user_login';
            } else {
                $display_property = 'display_name';
            }
            foreach ($current_selections as $agent) {
                $attribs = isset($agent->display_name) && $agent->user_login != $agent->display_name ? 'title="' . esc_attr($agent->display_name) . '"' : '';
                ?>
		<?php 
                $data = apply_filters('pp_agents_selection_ui_attribs', array('attribs' => $attribs, 'user_caption' => $agent->{$display_property}), $agent_type, $id_suffix, $agent);
                ?>
		<option value="<?php 
                echo $agent->ID;
                ?>
" <?php 
                echo $data['attribs'];
                ?>
><?php 
                echo $data['user_caption'];
                ?>
</option>
<?php 
            }
            ?>

		</select><br />
		</td>
		<?php 
        }
        ?>
		
		</tr>
		
		<?php 
        do_action('_pp_agents_selection_ui_select_pre', $id_suffix);
        ?>
		<tr>
		<?php 
        do_action('pp_agents_selection_ui_select_pre', $id_suffix);
        ?>
		

		<td><button type="button" id="select_agents_<?php 
        echo $id_suffix;
        ?>
" class="pp_add" style="float:right<?php 
        if (!$multi_select) {
            ?>
;display:none;<?php 
        }
        ?>
"><?php 
        echo $label_select;
        ?>
</button></td>
		
		<?php 
        if ($display_stored_selections) {
            ?>
		<td class="pp-members-current"><button type="button" id="unselect_agents_<?php 
            echo $id_suffix;
            ?>
" class="pp_remove"><?php 
            echo $label_unselect;
            ?>
</button></td>
		<?php 
        }
        ?>
		
		</tr>
		</table>	
<?php 
        if (!defined('PPM_VERSION') && pp_get_option('display_extension_hints')) {
            if (0 === validate_plugin("pp-membership/pp-membership.php")) {
                $msg = __('To set date limits on group membership, activate the PP Membership plugin.', 'pp');
            } elseif (true == pp_key_status()) {
                $msg = sprintf(__('To set date limits on group membership, %1$sinstall%2$s the PP Membership plugin.', 'pp'), '<a href="admin.php?page=pp-settings&pp_tab=install">', '</a>');
            } else {
                $msg = sprintf(__('To set date limits on group membership, %1$senter%2$s or %3$spurchase%4$s a support key and install the PP Membership plugin.', 'pp'), '<a href="admin.php?page=pp-settings&pp_tab=install">', '</a>', '<a href="http://presspermit.com/purchase">', '</a>');
            }
            echo "<div class='pp-ext-promo'>{$msg}</div>";
        }
        $csv = $current_selections ? implode(',', array_keys($current_selections)) : '';
        $csv = apply_filters('pp_agents_selection_ui_csv', $csv, $id_suffix, $current_selections);
        ?>
		<input type="hidden" id="<?php 
        echo $id_suffix;
        ?>
_csv" name="<?php 
        echo $id_suffix;
        ?>
_csv" value="<?php 
        echo $csv;
        ?>
" />
		<?php 
    }
Пример #12
0
/**
 * This function checks core and plugins for which need to be upgraded/installed
 *
 * Note: This function is sometimes executed during upgrades from
 * ancient databases.  Avoid rash assumptions about what's installed
 * or these upgrades may fail.
 *
 * @param string $name The name of the plugin to check. If no name is specified,
 *                     all plugins are checked.
 * @return mixed If a name is specified, an object will be returned with upgrade data
 *                     about the requested component (which can be "core", "local", or a plugin).
 *                     If the component desn't need to be updated, an empty array will be returned.
 *               If no name is specified, an array of such objects will be returned.
 *                     It will also include an array key "settings", which will be an array
 *                     that may contain metadata about the upgrade/install process.
 */
function check_upgrades($name = null)
{
    $pluginstocheck = plugin_types();
    $toupgrade = array();
    $settings = array();
    $toupgradecount = 0;
    $newinstallcount = 0;
    $installing = false;
    $disablelogin = false;
    $newinstalls = array();
    require 'version.php';
    if (isset($config->disablelogin) && !empty($config->disablelogin)) {
        $disablelogin = true;
    }
    // check core first...
    if (empty($name) || $name == 'core') {
        try {
            $coreversion = get_config('version');
        } catch (Exception $e) {
            $coreversion = 0;
        }
        $core = new stdClass();
        $core->to = $config->version;
        $core->torelease = $config->release;
        $core->toseries = $config->series;
        $toupgrade['core'] = $core;
        if (empty($coreversion)) {
            if (is_mysql()) {
                // Show a more informative error message if using mysql with skip-innodb
                // In MySQL 5.6.x, we run the command 'SHOW ENGINES' to check if InnoDB is enabled or not
                global $db;
                $result = $db->Execute("SHOW ENGINES");
                $hasinnodb = false;
                while (!$result->EOF) {
                    if ($result->fields['Engine'] == 'InnoDB' && ($result->fields['Support'] == 'YES' || $result->fields['Support'] == 'DEFAULT')) {
                        $hasinnodb = true;
                        break;
                    }
                    $result->MoveNext();
                }
                if (!$hasinnodb) {
                    throw new ConfigSanityException("Mahara requires InnoDB tables.  Please ensure InnoDB tables are enabled in your MySQL server.");
                }
            }
            $core->install = true;
            $installing = true;
        } else {
            if ($config->version > $coreversion) {
                $corerelease = get_config('release');
                if (isset($config->minupgradefrom) && isset($config->minupgraderelease) && $coreversion < $config->minupgradefrom) {
                    throw new ConfigSanityException("Must upgrade to {$config->minupgradefrom} " . "({$config->minupgraderelease}) first " . " (you have {$coreversion} ({$corerelease})");
                }
                $toupgradecount++;
                $core->upgrade = true;
                $core->from = $coreversion;
                $core->fromrelease = $corerelease;
            } else {
                // Core doesn't need to be upgraded. Remove it from the list!
                unset($toupgrade['core']);
            }
        }
    }
    // If we were just checking if the core needed to be upgraded, we can stop here
    if ($name == 'core') {
        $toupgrade['core']->disablelogin = $disablelogin;
        return $toupgrade['core'];
    }
    if (!$installing && (empty($name) || $name == 'local')) {
        $localversion = get_config('localversion');
        $localrelease = get_config('localrelease');
        if (is_null($localversion)) {
            $localversion = 0;
            $localrelease = 0;
        }
        $config = new StdClass();
        require get_config('docroot') . 'local/version.php';
        if ($config->version > $localversion) {
            $toupgradecount++;
            $toupgrade['local'] = (object) array('upgrade' => true, 'from' => $localversion, 'fromrelease' => $localrelease, 'to' => $config->version, 'torelease' => $config->release);
        }
        if ($name == 'local') {
            $toupgrade['local']->disablelogin = $disablelogin;
            return $toupgrade['local'];
        }
    }
    $plugins = array();
    if (!empty($name)) {
        try {
            $bits = explode('.', $name);
            $pt = $bits[0];
            $pn = $bits[1];
            $pp = null;
            if ($pt == 'blocktype' && strpos($pn, '/') !== false) {
                $bits = explode('/', $pn);
                $pp = get_config('docroot') . 'artefact/' . $bits[0] . '/blocktype/' . $bits[1];
            }
            validate_plugin($pt, $pn, $pp);
            $plugins[] = explode('.', $name);
        } catch (InstallationException $_e) {
            log_warn("Plugin {$pt} {$pn} is not installable: " . $_e->GetMessage());
        }
    } else {
        foreach ($pluginstocheck as $plugin) {
            $dirhandle = opendir(get_config('docroot') . $plugin);
            while (false !== ($dir = readdir($dirhandle))) {
                if (strpos($dir, '.') === 0 or 'CVS' == $dir) {
                    continue;
                }
                if (!is_dir(get_config('docroot') . $plugin . '/' . $dir)) {
                    continue;
                }
                try {
                    validate_plugin($plugin, $dir);
                    $plugins[] = array($plugin, $dir);
                } catch (InstallationException $_e) {
                    log_warn("Plugin {$plugin} {$dir} is not installable: " . $_e->GetMessage());
                }
                if ($plugin == 'artefact') {
                    // go check it for blocks as well
                    $btlocation = get_config('docroot') . $plugin . '/' . $dir . '/blocktype';
                    if (!is_dir($btlocation)) {
                        continue;
                    }
                    $btdirhandle = opendir($btlocation);
                    while (false !== ($btdir = readdir($btdirhandle))) {
                        if (strpos($btdir, '.') === 0 or 'CVS' == $btdir) {
                            continue;
                        }
                        if (!is_dir(get_config('docroot') . $plugin . '/' . $dir . '/blocktype/' . $btdir)) {
                            continue;
                        }
                        $plugins[] = array('blocktype', $dir . '/' . $btdir);
                    }
                }
            }
        }
    }
    foreach ($plugins as $plugin) {
        $plugintype = $plugin[0];
        $pluginname = $plugin[1];
        $pluginpath = "{$plugin['0']}/{$plugin['1']}";
        $pluginkey = "{$plugin['0']}.{$plugin['1']}";
        if ($plugintype == 'blocktype' && strpos($pluginname, '/') !== false) {
            // sigh.. we're a bit special...
            $bits = explode('/', $pluginname);
            $pluginpath = 'artefact/' . $bits[0] . '/blocktype/' . $bits[1];
        }
        // Don't try to get the plugin info if we are installing - it will
        // definitely fail
        $pluginversion = 0;
        if (!$installing && table_exists(new XMLDBTable($plugintype . '_installed'))) {
            if ($plugintype == 'blocktype' && strpos($pluginname, '/')) {
                $bits = explode('/', $pluginname);
                $installed = get_record('blocktype_installed', 'name', $bits[1], 'artefactplugin', $bits[0]);
            } else {
                $installed = get_record($plugintype . '_installed', 'name', $pluginname);
            }
            if ($installed) {
                $pluginversion = $installed->version;
                $pluginrelease = $installed->release;
            }
        }
        $config = new StdClass();
        require get_config('docroot') . $pluginpath . '/version.php';
        if (isset($config->disablelogin) && !empty($config->disablelogin)) {
            $disablelogin = true;
        }
        if (empty($pluginversion)) {
            $newinstall = false;
            if (empty($installing) && $pluginkey != $name) {
                $newinstall = true;
            }
            $plugininfo = new StdClass();
            $plugininfo->install = true;
            $plugininfo->to = $config->version;
            $plugininfo->torelease = $config->release;
            if (property_exists($config, 'requires_config')) {
                $plugininfo->requires_config = $config->requires_config;
            }
            if (property_exists($config, 'requires_parent')) {
                $plugininfo->requires_parent = $config->requires_parent;
            }
            $classname = generate_class_name($plugintype, $pluginname);
            safe_require($plugintype, $pluginname);
            try {
                $classname::sanity_check();
            } catch (InstallationException $exc) {
                $plugininfo->to = get_string('notinstalled', 'admin');
                $plugininfo->torelease = get_string('notinstalled', 'admin');
                $plugininfo->errormsg = $exc->getMessage();
            }
            if ($newinstall) {
                $plugininfo->from = get_string('notinstalled', 'admin');
                $plugininfo->fromrelease = get_string('notinstalled', 'admin');
                $plugininfo->newinstall = true;
                $newinstallcount++;
                $newinstalls[$pluginkey] = $plugininfo;
            } else {
                $toupgrade[$pluginkey] = $plugininfo;
            }
        } else {
            if ($config->version > $pluginversion) {
                if (isset($config->minupgradefrom) && isset($config->minupgraderelease) && $pluginversion < $config->minupgradefrom) {
                    throw new ConfigSanityException("Must upgrade to {$config->minupgradefrom} " . " ({$config->minupgraderelease}) first " . " (you have {$pluginversion} ({$pluginrelease}))");
                }
                $toupgradecount++;
                $plugininfo = new StdClass();
                $plugininfo->upgrade = true;
                $plugininfo->from = $pluginversion;
                $plugininfo->fromrelease = $pluginrelease;
                $plugininfo->to = $config->version;
                $plugininfo->torelease = $config->release;
                if (property_exists($config, 'requires_config')) {
                    $plugininfo->requires_config = $config->requires_config;
                }
                if (property_exists($config, 'requires_parent')) {
                    $plugininfo->requires_parent = $config->requires_parent;
                }
                $classname = generate_class_name($plugintype, $pluginname);
                safe_require($plugintype, $pluginname);
                try {
                    $classname::sanity_check();
                } catch (InstallationException $exc) {
                    $plugininfo->to = $config->version;
                    $plugininfo->torelease = $pluginrelease;
                    $plugininfo->errormsg = $exc->getMessage();
                    $toupgrade[$pluginkey] = $plugininfo;
                    continue;
                }
                $toupgrade[$pluginkey] = $plugininfo;
            }
        }
    }
    // if we've just asked for one, don't return an array...
    if (!empty($name)) {
        if (count($toupgrade) == 1) {
            $upgrade = new StdClass();
            $upgrade->name = $name;
            foreach ((array) $toupgrade[$name] as $key => $value) {
                $upgrade->{$key} = $value;
            }
            $upgrade->disablelogin = $disablelogin;
            return $upgrade;
        } else {
            return array();
        }
    }
    // Nothing needed to be upgraded or installed
    if (count($toupgrade) == 0) {
        if (!empty($name)) {
            $disablelogin = false;
        }
    }
    // If we get here, it's because we have an array of objects to return
    uksort($toupgrade, 'sort_upgrades');
    $settings['disablelogin'] = $disablelogin;
    $settings['newinstallcount'] = $newinstallcount;
    $settings['newinstalls'] = $newinstalls;
    $settings['toupgradecount'] = $toupgradecount;
    $toupgrade['settings'] = $settings;
    return $toupgrade;
}
                update_option('recently_activated', array($file => time()) + (array) get_option('recently_activated'));
            } else {
                update_site_option('recently_activated', array($file => time()) + (array) get_site_option('recently_activated'));
            }
            wp_redirect(add_query_arg('_wpnonce', wp_create_nonce('edit-plugin-test_' . $file), "plugin-editor.php?file={$file}&plugin={$plugin}&liveupdate=1&scrollto={$scrollto}&networkwide=" . $network_wide));
            exit;
        }
        wp_redirect(self_admin_url("plugin-editor.php?file={$file}&plugin={$plugin}&a=te&scrollto={$scrollto}"));
    } else {
        wp_redirect(self_admin_url("plugin-editor.php?file={$file}&plugin={$plugin}&scrollto={$scrollto}"));
    }
    exit;
} else {
    if (isset($_GET['liveupdate'])) {
        check_admin_referer('edit-plugin-test_' . $file);
        $error = validate_plugin($plugin);
        if (is_wp_error($error)) {
            wp_die($error);
        }
        if (!empty($_GET['networkwide']) && !is_plugin_active_for_network($file) || !is_plugin_active($file)) {
            activate_plugin($plugin, "plugin-editor.php?file={$file}&phperror=1", !empty($_GET['networkwide']));
        }
        // we'll override this later if the plugin can be included without fatal error
        wp_redirect(self_admin_url("plugin-editor.php?file={$file}&plugin={$plugin}&a=te&scrollto={$scrollto}"));
        exit;
    }
    // List of allowable extensions
    $editable_extensions = array('php', 'txt', 'text', 'js', 'css', 'html', 'htm', 'xml', 'inc', 'include');
    /**
     * Filters file type extensions editable in the plugin editor.
     *
Пример #14
0
function activate_plugin($plugin, $redirect = '') {
		$current = get_option('active_plugins');
		$plugin = trim($plugin);

		$valid = validate_plugin($plugin);
		if ( is_wp_error($valid) )
			return $valid;

		if ( !in_array($plugin, $current) ) {
			if ( !empty($redirect) )
				wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect)); // we'll override this later if the plugin can be included without fatal error
			ob_start();
			@include(ABSPATH . PLUGINDIR . '/' . $plugin);
			$current[] = $plugin;
			sort($current);
			update_option('active_plugins', $current);
			do_action('activate_' . $plugin);
			ob_end_clean();
		}

		return null;
}
Пример #15
0
 /**
  * reset wp learn from plugin wordpress-reset
  * @param $args
  * @param $assoc_args
  */
 public function resetwp($args, $assoc_args)
 {
     global $current_user, $user_id;
     require_once ABSPATH . '/wp-admin/includes/upgrade.php';
     $blogname = get_option('blogname');
     $admin_email = get_option('admin_email');
     $blog_public = get_option('blog_public');
     if ($current_user->user_login != 'admin') {
         $user = get_user_by('login', 'admin');
     }
     if (empty($user->user_level) || $user->user_level < 10) {
         $user = $current_user;
     }
     global $wpdb, $reactivate_wp_reset_additional;
     $prefix = str_replace('_', '\\_', $wpdb->prefix);
     $tables = $wpdb->get_col("SHOW TABLES LIKE '{$prefix}%'");
     foreach ($tables as $table) {
         $wpdb->query("DROP TABLE {$table}");
     }
     $result = wp_install($blogname, $user->user_login, $user->user_email, $blog_public);
     extract($result, EXTR_SKIP);
     $query = $wpdb->prepare("UPDATE {$wpdb->users} SET user_pass = %s, user_activation_key = '' WHERE ID = %d", $user->user_pass, $user_id);
     $wpdb->query($query);
     $get_user_meta = function_exists('get_user_meta') ? 'get_user_meta' : 'get_usermeta';
     $update_user_meta = function_exists('update_user_meta') ? 'update_user_meta' : 'update_usermeta';
     if ($get_user_meta($user_id, 'default_password_nag')) {
         $update_user_meta($user_id, 'default_password_nag', false);
     }
     if ($get_user_meta($user_id, $wpdb->prefix . 'default_password_nag')) {
         $update_user_meta($user_id, $wpdb->prefix . 'default_password_nag', false);
     }
     if (defined('REACTIVATE_WP_RESET') && REACTIVATE_WP_RESET === true) {
         @activate_plugin(plugin_basename(__FILE__));
     }
     if (!empty($reactivate_wp_reset_additional)) {
         foreach ($reactivate_wp_reset_additional as $plugin) {
             $plugin = plugin_basename($plugin);
             if (!is_wp_error(validate_plugin($plugin))) {
                 @activate_plugin($plugin);
             }
         }
     }
     wp_clear_auth_cookie();
     wp_set_auth_cookie($user_id);
     wp_redirect(admin_url() . '?reset');
     //exit();
     $this->result('Reset WP successful.');
 }
Пример #16
0
}
if (isset($aCheck->valid) && $aCheck->valid) {
    $fv_player_pro_path = fv_flowplayer_get_extension_path('fv-player-pro');
    if (is_plugin_inactive($fv_player_pro_path) && !is_wp_error(validate_plugin($fv_player_pro_path))) {
        ?>
      <div id="fv_flowplayer_addon_pro">
        <p>Thank you for purchasing FV Player license! <input type="button" class='button fv_wp_flowplayer_activate_extension' data-plugin="<?php 
        echo $fv_player_pro_path;
        ?>
" value="Enable the Pro extension" /> <img style="display: none; " src="<?php 
        echo site_url();
        ?>
/wp-includes/images/wpspin.gif" width="16" height="16" /></p>
      </div>
    <?php 
    } elseif (is_plugin_active($fv_player_pro_path) && !is_wp_error(validate_plugin($fv_player_pro_path))) {
        ?>
      <div id="fv_flowplayer_addon_pro">
        <p>Thank you for purchasing FV Player license! <input type="button" class="button" onclick="window.location.href += '&fv_player_pro_installed=yes#fv_player_pro'" value="Pro pack installed" /></p>
      </div>
    <?php 
    } else {
        ?>
      <div id="fv_flowplayer_addon_pro">
        <p>Thank you for purchasing FV Player license! <form method="post"><input type="submit" class="button" value="Install Pro extension" /><?php 
        wp_nonce_field('fv_player_pro_install', 'nonce_fv_player_pro_install');
        ?>
</form></p>
      </div>
    <?php 
    }
    function options_ui()
    {
        global $pp_options_ui;
        $ui = $pp_options_ui;
        // shorten syntax
        $tab = 'install';
        $ppcom_connect = pp_update_info_enabled();
        $use_network_admin = pp_use_network_updates();
        $suppress_updates = $use_network_admin && !is_super_admin();
        $section = 'key';
        // --- UPDATE KEY SECTION ---
        if (!empty($ui->form_options[$tab][$section]) && !$suppress_updates) {
            ?>
			<tr><td scope="row" colspan="2"><span style="font-weight:bold;vertical-align:top"><?php 
            echo $ui->section_captions[$tab][$section];
            ?>
</span>
			<?php 
            global $activated;
            if ($ppcom_connect) {
                require_once dirname(__FILE__) . '/plugin_pp.php';
                PP_Plugin_Status::get_version_info();
            }
            $id = 'support_key';
            $opt_val = pp_get_option($id);
            if (!is_array($opt_val) || count($opt_val) < 2) {
                $activated = false;
                $expired = false;
                $key = '';
            } else {
                $activated = 1 == $opt_val[0];
                $expired = -1 == $opt_val[0];
                $key = $opt_val[1];
            }
            if (isset($opt_val['expire_date_gmt'])) {
                $expire_days = intval((strtotime($opt_val['expire_date_gmt']) - time()) / 86400);
            }
            if ($expired) {
                $class = 'activating';
                $is_err = true;
                $msg = sprintf(__('Your support key has expired. For information on renewal at a discounted rate, <a href="%s">click here</a>.', 'pp'), 'admin.php?page=pp-settings&amp;pp_renewal=1');
            } elseif (!empty($opt_val['expire_date_gmt'])) {
                $class = 'activating';
                if ($expire_days < 30) {
                    $is_err = true;
                }
                if ($expire_days < 1) {
                    $msg = sprintf(__('Your support key (for plugin updates) will expire today. For information on renewal at a discounted rate, <a href="%2$s">click here</a>.', 'pp'), $expire_days, 'admin.php?page=pp-settings&amp;pp_renewal=1');
                } elseif ($expire_days < 30) {
                    $msg = sprintf(__('Your support key (for plugin updates) will expire in %1$s days. For information on renewal at a discounted rate, <a href="%2$s">click here</a>.', 'pp'), $expire_days, 'admin.php?page=pp-settings&amp;pp_renewal=1');
                } else {
                    $class = "activating hidden";
                }
            } elseif (!$activated) {
                $class = 'activating';
                $msg = sprintf(__('Activate your support key to install Pro extensions and access the member support forums. Available at <a href="%s">presspermit.com</a>.', 'pp'), 'http://presspermit.com/' . 'purchase/');
            } else {
                $class = "activating hidden";
                $msg = '';
            }
            ?>
				
				<span style="margin-left:145px;">
					<?php 
            if ($expired && !empty($key)) {
                ?>
						<span class="pp-key-exired"><?php 
                _e("Key Expired", 'pp');
                ?>
</span>
						<button type="button" id="activation-button" name="activation-button" class="button-secondary"><?php 
                _e('Deactivate Key', 'pp');
                ?>
</button>
						<span class="pp-key-exired pp-key-warning"> <?php 
                _e('note: Renewal does not require deactivation. If you do deactivate, re-entry of the support key will be required.', 'pp');
                ?>
</span>
					<?php 
            } else {
                ?>
						<?php 
                if ($activated) {
                    ?>
						<span class="pp-key-active"><?php 
                    _e("Key Activated", 'pp');
                    ?>
</span>
						<?php 
                }
                ?>
						<input name="<?php 
                echo $id;
                ?>
" type="text" id="<?php 
                echo $id;
                ?>
" <?php 
                echo $activated ? ' style="display:none"' : '';
                ?>
 />
						<button type="button" id="activation-button" name="activation-button" class="button-secondary"><?php 
                echo !$activated ? __('Activate Key', 'pp') : __('Deactivate Key', 'pp');
                ?>
</button>
					<?php 
            }
            ?>
					
					<img id="pp_support_waiting" class="waiting" style="display:none;position:relative" src="<?php 
            echo esc_url(admin_url('images/wpspin_light.gif'));
            ?>
" alt="" />
				</span>

				<br />
				
				<span style="margin-left:217px">
					<?php 
            if ($activated) {
                ?>
					<span class="pp-key-active pp-key-warning"> <?php 
                _e('note: If you deactive, re-entry of the support key will be required for re-activation.', 'pp');
                ?>
</span>
					<?php 
            } elseif (!$expired) {
                ?>
					<span class="pp-subtext"> <?php 
                _e('note: Your site URL and version info will be sent to presspermit.com', 'pp');
                ?>
</span>
					<?php 
            }
            ?>
				</span>
				
				<br /><div id="activation-status" class="<?php 
            echo $class;
            ?>
"><?php 
            echo $msg;
            ?>
</div><div id="activation-reload" style="display:none;margin-top:10px"><a href="<?php 
            echo admin_url('admin.php?page=pp-settings');
            ?>
"><?php 
            _e('reload extension links', 'pp');
            ?>
</a></div>
				
				<?php 
            if (!empty($is_err)) {
                ?>
				<div id="activation-error" class="error" style="margin-top:35px"><?php 
                echo $msg;
                ?>
</div>
				<?php 
            }
            ?>
				
				<?php 
            if (!$activated || $expired) {
                require_once dirname(__FILE__) . '/pro-promo_pp.php';
            }
            ?>
			</td></tr>
		<?php 
            do_action('pp_support_key_ui');
            self::footer_js($activated);
        }
        // any options accessable in this section
        $section = 'version';
        // --- VERSION SECTION ---
        if (!empty($ui->form_options[$tab][$section])) {
            ?>
			<tr>
			<th scope="row"><?php 
            echo $ui->section_captions[$tab][$section];
            ?>
</th>
			<td>
			
			<?php 
            if ($ppcom_connect) {
                $update_info = pp_get_all_updates_info(!empty($_REQUEST['pp_refresh_updates']));
            } else {
                $update_info = array();
            }
            //dump($update_info);
            $info_link = '';
            $update_link = '';
            $alert = '';
            if (!$suppress_updates) {
                $wp_plugin_updates = get_site_transient('update_plugins');
                if ($wp_plugin_updates && isset($wp_plugin_updates->response[PPC_BASENAME]) && !empty($wp_plugin_updates->response[PPC_BASENAME]->new_version) && version_compare($wp_plugin_updates->response[PPC_BASENAME]->new_version, PPC_VERSION, '>')) {
                    $slug = 'press-permit-core';
                    $_url = "plugin-install.php?tab=plugin-information&plugin={$slug}&section=changelog&TB_iframe=true&width=600&height=800";
                    $info_url = $use_network_admin ? network_admin_url($_url) : admin_url($_url);
                    $info_link = "<span class='update-message'> &bull; <a href='{$info_url}' class='thickbox'>" . sprintf(__ppw('%s&nbsp;details', 'pp'), $update_info[$slug]['new_version']) . '</a></span>';
                }
            }
            printf(__('Press Permit Core Version: %1$s %2$s', 'pp'), PPC_VERSION, $info_link . $update_link . $alert);
            ?>
			<br />
			<?php 
            printf(__("Database Schema Version: %s", 'pp'), PPC_DB_VERSION);
            ?>
			<br />
			<?php 
            global $wp_version;
            printf(__("WordPress Version: %s", 'pp'), $wp_version);
            ?>
			<br />
			<?php 
            printf(__("PHP Version: %s", 'pp'), phpversion());
            ?>
			<br />
			<?php 
            if (empty($activated) && empty($expired) && !defined('PP_FORCE_PPCOM_INFO')) {
                ?>
				<div style="margin-top:10px">
				<?php 
                $hint = __('Periodically query presspermit.com for available extensions. Your version info will be sent.', 'pp');
                $ui->option_checkbox('ppcom_update_info', $tab, $section, $hint);
                ?>
				</div>
			<?php 
            }
            ?>
			
			</td></tr>
		<?php 
        }
        // any options accessable in this section
        $section = 'extensions';
        // --- EXTENSIONS SECTION ---
        if (!empty($ui->form_options[$tab][$section])) {
            ?>
			<tr><th scope="row"><?php 
            echo $ui->section_captions[$tab][$section];
            if ($ppcom_connect) {
                echo '&nbsp;&nbsp;&bull;&nbsp;&nbsp;<a href="admin.php?page=pp-settings&amp;pp_refresh_updates=1">' . __('refresh', 'pp') . '</a>';
            }
            ?>
</th><td>
			<?php 
            global $pp_extensions;
            $missing = $inactive = array();
            if (pp_get_option('display_hints') && $ppcom_connect) {
                $ext_info = pp_get_extension_info(!empty($_REQUEST['pp_refresh_done']));
                $ext_info->blurb['capability-manager-enhanced'] = __('Create your own WP roles or modify the capabilities defined for any WP Role.', 'pp');
                $ext_info->descript['capability-manager-enhanced'] = __('Create your own WP roles or modify the capabilities defined for any WP Role. Not necessary for all installations, but PP interop is particularly important for bbPress and BuddyPress installations.', 'pp');
            }
            if (!empty($ext_info) && (empty($ext_info->blurb) || empty($ext_info->descript))) {
                unset($ext_info);
            }
            if ($missing = array_diff_key($update_info, $pp_extensions)) {
                unset($missing['press-permit-core']);
                foreach (array_keys($missing) as $slug) {
                    if (0 === validate_plugin("{$slug}/{$slug}.php")) {
                        unset($missing[$slug]);
                        $inactive[$slug] = true;
                    }
                }
            }
            ksort($pp_extensions);
            if ($pp_extensions) {
                $change_log_caption = __('<strong>Change Log</strong> (since your current version)', 'pp');
                ?>
				<h4 style="margin-bottom:2px;margin-top:0"><?php 
                _e('Active Extensions:', 'pp');
                ?>
</h4>
				<table class="pp-extensions">
				<?php 
                foreach ($pp_extensions as $slug => $plugin_info) {
                    $info_link = '';
                    $update_link = '';
                    $alert = '';
                    if (isset($update_info[$slug]) && version_compare($update_info[$slug]['new_version'], $plugin_info->version, '>')) {
                        $_url = "plugin-install.php?tab=plugin-information&plugin={$slug}&TB_iframe=true&width=600&height=800";
                        $info_url = $use_network_admin ? network_admin_url($_url) : admin_url($_url);
                        $info_link = "<span class='update-message'> &bull; <a href='{$info_url}' class='thickbox' title='{$change_log_caption}'>" . sprintf(__ppw('%s&nbsp;details', 'pp'), $update_info[$slug]['new_version']) . '</a></span>';
                        if (!$suppress_updates) {
                            $style = $activated ? '' : "style='display:none'";
                            $url = pp_plugin_update_url($plugin_info->basename, $slug) . '&pp_install=1&TB_iframe=true&height=400';
                            $update_link = "<span class='pp-update-link' {$style}> &bull; <a href='{$url}' class='thickbox' target='_blank'>" . __ppw('update&nbsp;now', 'pp') . '</a></span>';
                            $alert = !empty($update_info[$slug]['alert']) ? " &bull; <span class='pp-red'>{$update_info[$slug]['alert']}</span>" : '';
                        }
                    }
                    ?>
				<tr>
				<td <?php 
                    if ($alert) {
                        echo 'colspan="2"';
                    }
                    ?>
><?php 
                    echo __($plugin_info->label) . ' <span class="pp-gray">' . $plugin_info->version . "</span> {$info_link} {$update_link} {$alert}";
                    ?>
</td>
				<?php 
                    if (!empty($ext_info) && !$alert) {
                        ?>
				<td>
					<?php 
                        if (isset($ext_info->blurb[$slug])) {
                            ?>
					<span class="pp-ext-info" title="<?php 
                            if (isset($ext_info->descript[$slug])) {
                                echo esc_attr($ext_info->descript[$slug]);
                            }
                            ?>
"><?php 
                            echo $ext_info->blurb[$slug];
                            ?>
</span>
					<?php 
                        }
                        ?>
				</td>
				<?php 
                    }
                    ?>
				</tr>
				<?php 
                }
                ?>
				</table>
			<?php 
            }
            if (!defined('CAPSMAN_ENH_VERSION')) {
                if (0 === validate_plugin('capability-manager-enhanced/capsman-enhanced.php') || 0 === validate_plugin('capsman-enhanced/capsman-enhanced.php')) {
                    $inactive['capability-manager-enhanced'] = true;
                } else {
                    $missing['capability-manager-enhanced'] = true;
                }
            }
            ksort($inactive);
            if ($inactive) {
                ?>
			<h4 style="margin-bottom:2px"><?php 
                $url = PP_MULTISITE ? 'network/plugins.php/' : 'plugins.php';
                printf(__('%1$sInactive Extensions%2$s:', 'pp'), "<a href='{$url}'>", '</a>');
                ?>
</h4>
			<table class="pp-extensions">
			<?php 
                foreach (array_keys($inactive) as $slug) {
                    ?>
			<tr>
			<td><?php 
                    echo pp_pretty_slug($slug);
                    ?>
</td>
			<?php 
                    if (!empty($ext_info)) {
                        ?>
				<td>
					<?php 
                        if (isset($ext_info->blurb[$slug])) {
                            ?>
					<span class="pp-ext-info" title="<?php 
                            if (isset($ext_info->descript[$slug])) {
                                echo esc_attr($ext_info->descript[$slug]);
                            }
                            ?>
"><?php 
                            echo $ext_info->blurb[$slug];
                            ?>
</span>
					<?php 
                        }
                        ?>
				</td>
			<?php 
                    }
                    ?>
			</tr>
			<?php 
                }
                ?>
			</table>
			<?php 
            }
            ksort($missing);
            if ($missing) {
                ?>
			<h4 style="margin-bottom:2px"><?php 
                _e('Available Pro Extensions:', 'pp');
                ?>
</h4>
			<table class="pp-extensions">
			<?php 
                foreach (array_keys($missing) as $slug) {
                    if ($need_supplemental_key = isset($update_info[$slug]['key_type']) && 'pp' != $update_info[$slug]['key_type']) {
                        $any_supplemental_key = true;
                    }
                    if ($activated && isset($update_info[$slug]) && !$need_supplemental_key && !$suppress_updates) {
                        $_url = "update.php?action={$slug}&amp;plugin={$slug}&pp_install=1&TB_iframe=true&height=400";
                        $install_url = $use_network_admin ? network_admin_url($_url) : admin_url($_url);
                        $url = wp_nonce_url($install_url, "{$slug}_{$slug}");
                        $install_link = "<span> &bull; <a href='{$url}' class='thickbox' target='_blank'>" . __ppw('install', 'pp') . '</a></span>';
                    } else {
                        $install_link = '';
                    }
                    ?>
			<tr>
			<td><?php 
                    if (!empty($update_info[$slug])) {
                        echo "<a href='http://presspermit.com/extensions/{$slug}'>" . pp_pretty_slug($slug) . '</a>' . $install_link;
                    } else {
                        $caption = ucwords(str_replace('-', ' ', $slug));
                        echo '<span class="plugins update-message"><a href="' . pp_plugin_info_url($slug) . '" class="thickbox" title=" ' . $caption . '">' . str_replace(' ', '&nbsp;', $caption) . '</a></span>';
                    }
                    ?>
</td>
			<?php 
                    if (!empty($ext_info)) {
                        ?>
				<td>
					<?php 
                        if (isset($ext_info->blurb[$slug])) {
                            ?>
					<span class="pp-ext-info" title="<?php 
                            if (isset($ext_info->descript[$slug])) {
                                echo esc_attr($ext_info->descript[$slug]);
                            }
                            ?>
"><?php 
                            echo $ext_info->blurb[$slug];
                            ?>
</span>
					<?php 
                        }
                        ?>
				</td>
			<?php 
                    }
                    ?>
			</tr>
			<?php 
                }
                ?>
			</table>
			<p style="padding-left:15px;">
			<?php 
                if (!$activated) {
                    echo '<span class="pp-red">' . __('To enable one-click installation and update of extensions, please activate your Press Permit Pro support key above.', 'pp') . '<span>';
                } elseif (!empty($any_supplemental_key)) {
                    printf(__('Visit %1$spresspermit.com%2$s for further information on obtaining and installing extensions.', 'pp'), '<a href="http://presspermit.com">', '</a>');
                }
                ?>
			</p>
			
			<?php 
            } elseif (!pp_update_info_enabled()) {
                ?>
				<p style="margin-top:20px"><strong><?php 
                _e('Press Permit Pro extensions supply:', 'pp');
                ?>
</strong></p>
				<ul class="pp-bullet-list">
				<li><?php 
                printf(__('%1$sContent-specific editing permissions, with Edit Flow, Revisionary and Post Forking support%2$s', 'pp'), '<a href="http://presspermit.com/extensions/pp-collaborative-editing">', '</a>');
                ?>
</li>
				<li><?php 
                printf(__('%1$sCustom Post Statuses (for visibility or moderation)%2$s', 'pp'), '<a href="http://presspermit.com/extensions/pp-custom-post-statuses">', '</a>');
                ?>
</li>
				<li><?php 
                printf(__('%1$sCustomize bbPress forum access%2$s', 'pp'), '<a href="http://presspermit.com/extensions/pp-compatibility">', '</a>');
                ?>
</li>
				<li><?php 
                printf(__('%1$sFile URL filtering%2$s', 'pp'), '<a href="http://presspermit.com/extensions/pp-file-url-filter">', '</a>');
                ?>
</li>
				<li><?php 
                printf(__('%1$sRole Scoper import script%2$s', 'pp'), '<a href="http://presspermit.com/extensions/pp-import">', '</a>');
                ?>
</li>
				<li><?php 
                printf(__('%1$s...and more%2$s', 'pp'), '<a href="http://presspermit.com/extensions/">', '</a>');
                ?>
</li>
				</ul>
				<p>
				<?php 
                printf(__('For updated availability, enable the "update info" option above or visit %1$spresspermit.com%2$s.', 'pp'), '<a href="http://presspermit.com/extensions/">', '</a>');
                ?>
</p>
			<?php 
            }
            ?>
			<?php 
            if (!empty($ext_info) && pp_get_option('display_hints')) {
                ?>
			<p><span class="pp-subtext">
			<?php 
                _e('Note: Hover over descriptions for more detail. Press Permit extensions can also be maintained on the Plugins screen.', 'pp');
                ?>
			</span></p>
			<?php 
            }
            ?>
			
			<?php 
            ?>
			</td></tr>
			<?php 
        }
        // any options accessable in this section
        $section = 'help';
        // --- HELP SECTION ---
        if (!empty($ui->form_options[$tab][$section])) {
            ?>
			<tr><th scope="row"><?php 
            echo $ui->section_captions[$tab][$section];
            ?>
</th><td>
			<?php 
            if ($activated) {
                ?>
				<ul class="pp-support-list">
				<li><a href='http://presspermit.com/docs/' target='pp_doc'><?php 
                _e('Press Permit Documentation', 'pp');
                ?>
</a></li>

				<li class="pp-support-forum"><a href="admin.php?page=pp-settings&amp;pp_support_forum=1" target="pp_forum"><?php 
                _e('Press Permit Support Forums', 'pp');
                ?>
</a> <strong>*</strong></li>

				<li class="upload-config"><a href="admin.php?page=pp-settings&amp;pp_upload_config=1"><?php 
                _e('Upload site configuration to presspermit.com now', 'pp');
                ?>
</a> <strong>*</strong> 
				<img id="pp_upload_waiting" class="waiting" style="display:none;position:relative" src="<?php 
                echo esc_url(admin_url('images/wpspin_light.gif'));
                ?>
" alt="" />
				</li>
				</ul>
				
				<div style="text-indent: -10px;padding-left: 10px;margin-top:15px;margin-left:10px"><strong>
				<?php 
                printf(__('%s Site configuration data selected below will be uploaded to presspermit.com:', 'pp'), '<strong>* </strong>');
                ?>
				</strong></div>
				
				<div style="padding-left:22px">
				<?php 
                $ok = (array) pp_get_option('support_data');
                $ok['ver'] = 1;
                $ui->all_options[] = 'support_data';
                $avail = array('ver' => __('Version info for server, WP, bbPress, BuddyPress, PP and all extensions', 'pp'), 'pp_options' => __('PP Settings and related WP Settings', 'pp'), 'theme' => __('Theme name, version and status', 'pp'), 'active_plugins' => __('Activated plugins list', 'pp'), 'installed_plugins' => __('Inactive plugins list', 'pp'), 'wp_roles_types' => __('WordPress Roles, Capabilities, Post Types, Taxonomies and Post Statuses', 'pp'), 'pp_permissions' => __('Role Assignments and Exceptions', 'pp'), 'pp_groups' => __('Group definitions', 'pp'), 'pp_group_members' => __('Group Membership (id only)', 'pp'), 'pp_imports' => __('Role Scoper / PP 1.x Configuration and PP Import Results', 'pp'), 'post_data' => __('Post id, status, author id, parent id, and term ids and taxonomy name (when support accessed from post or term edit form)', 'pp'), 'error_log' => __('PHP Error Log (recent entries, no absolute paths)', 'pp'));
                $ok['ver'] = true;
                $ok['pp_options'] = true;
                ?>
				<div class="support_data">
				<?php 
                foreach ($avail as $key => $caption) {
                    $id = 'support_data_' . $key;
                    $disabled = in_array($key, array('ver', 'pp_options')) ? 'disabled="disabled"' : '';
                    ?>
					<div>
					<label for="<?php 
                    echo $id;
                    ?>
"><input type="checkbox" id="<?php 
                    echo $id;
                    ?>
" name="support_data[<?php 
                    echo $key;
                    ?>
]" value="1" <?php 
                    echo $disabled;
                    checked('1', !empty($ok[$key]), true);
                    ?>
 /> <?php 
                    echo $caption;
                    ?>
</label>
					</div>
				<?php 
                }
                ?>
				</div>
				
				<div>
				<label for="pp_support_data_all"><input type="checkbox" id="pp_support_data_all" value="1" /> <?php 
                _e('(all)', 'pp');
                ?>
</label>
				</div>
				
				<div style="margin-top:10px">
				<?php 
                _e('<strong>note:</strong> user data, absolute paths, database prefix, post title, post content and post excerpt are <strong>never</strong> uploaded', 'pp');
                ?>
				</div>
				
				</div>
				<?php 
            } else {
                ?>
				<div>
				<?php 
                _e('Purchase of a support key enables access to the following resources:', 'pp');
                ?>
				</div>
	
				<ul class="pp-support-list pp-bullet-list">
				<!-- <li><a href='http://presspermit.com/docs/' target='pp_doc'><?php 
                _e('Pro Documentation on presspermit.com', 'pp');
                ?>
</a></li> -->
				<li><a href='http://presspermit.com/forums/' target='pp_forum'><?php 
                _e('Pro Support Forums on presspermit.com', 'pp');
                ?>
</a></li>
				<li><?php 
                _e('Optional uploading of your site configuration to assist troubleshooting', 'pp');
                ?>
</li>
				</ul>
				<?php 
            }
            if (version_compare(PPC_VERSION, '1.0', '<')) {
                echo '<div>';
                _e('Note that these resources may be unavailable or incomplete during the project\'s initial beta phase.', 'pp');
                echo '</div>';
            }
            ?>
			</td></tr>
		<?php 
        }
        // any options accessable in this section
        if (!empty($activated)) {
            $section = 'beta_updates';
            // --- BETA UPDATES SECTION ---
            if (!empty($ui->form_options[$tab][$section]) && !$suppress_updates && $ppcom_connect) {
                ?>
				<tr><th scope="row"><?php 
                echo $ui->section_captions[$tab][$section];
                ?>
</th><td>
				<?php 
                if (preg_match("/dev|alpha|beta|rc/i", PPC_VERSION) && version_compare(PPC_VERSION, '0.9', '>')) {
                    $hint = __('If you have already received a beta update and want to switch back to the current production version, switch off this option and click Update. Then look for an update prompt in the Plugins list.', 'pp');
                } else {
                    $hint = '';
                }
                $ui->option_checkbox('beta_updates', $tab, $section, $hint);
                ?>
				</td></tr>
				<?php 
            }
            // any options accessable in this section
        }
    }
Пример #18
0
                    continue;
                }
                $btdirhandle = opendir($btlocation);
                while (false !== ($btdir = readdir($btdirhandle))) {
                    if (strpos($btdir, '.') === 0) {
                        continue;
                    }
                    if (!is_dir(get_config('docroot') . $plugin . '/' . $dir . '/blocktype/' . $btdir)) {
                        continue;
                    }
                    if (!array_key_exists($dir . '/' . $btdir, $plugins['blocktype']['installed'])) {
                        try {
                            if (!array_key_exists($dir, $plugins['artefact']['installed'])) {
                                throw new InstallationException(get_string('blocktypeprovidedbyartefactnotinstallable', 'error', $dir));
                            }
                            validate_plugin('blocktype', $dir . '/' . $btdir, get_config('docroot') . 'artefact/' . $dir . '/blocktype/' . $btdir);
                            $plugins['blocktype']['notinstalled'][$dir . '/' . $btdir] = array();
                        } catch (InstallationException $_e) {
                            $plugins['blocktype']['notinstalled'][$dir . '/' . $btdir]['notinstallable'] = $_e->getMessage();
                        }
                    }
                }
            }
        }
    }
}
global $THEME;
$loadingicon = $THEME->get_url('images/loading.gif');
$successicon = $THEME->get_url('images/success.png');
$failureicon = $THEME->get_url('images/failure.png');
$loadingstring = json_encode(get_string('upgradeloading', 'admin'));
Пример #19
0
/**
 * This function checks core and plugins for which need to be upgraded/installed
 *
 * @param string $name The name of the plugin to check. If no name is specified,
 *                     all plugins are checked.
 * @return array of objects
 */
function check_upgrades($name = null)
{
    $pluginstocheck = plugin_types();
    $toupgrade = array();
    $installing = false;
    $disablelogin = false;
    require 'version.php';
    if (isset($config->disablelogin) && !empty($config->disablelogin)) {
        $disablelogin = true;
    }
    // check core first...
    if (empty($name) || $name == 'core') {
        try {
            $coreversion = get_config('version');
        } catch (Exception $e) {
            $coreversion = 0;
        }
        if (empty($coreversion)) {
            if (is_mysql()) {
                // Show a more informative error message if using mysql with skip-innodb
                global $db;
                $result = $db->Execute("SHOW VARIABLES LIKE 'have_innodb'");
                if ($result->fields['Value'] != 'YES') {
                    throw new ConfigSanityException("Mahara requires InnoDB tables.  Please ensure InnoDB tables are enabled in your MySQL server.");
                }
            }
            $core = new StdClass();
            $core->install = true;
            $core->to = $config->version;
            $core->torelease = $config->release;
            $toupgrade['core'] = $core;
            $installing = true;
        } else {
            if ($config->version > $coreversion) {
                $corerelease = get_config('release');
                if (isset($config->minupgradefrom) && isset($config->minupgraderelease) && $coreversion < $config->minupgradefrom) {
                    throw new ConfigSanityException("Must upgrade to {$config->minupgradefrom} " . "({$config->minupgraderelease}) first " . " (you have {$coreversion} ({$corerelease})");
                }
                $core = new StdClass();
                $core->upgrade = true;
                $core->from = $coreversion;
                $core->fromrelease = $corerelease;
                $core->to = $config->version;
                $core->torelease = $config->release;
                $toupgrade['core'] = $core;
            }
        }
    }
    // If we were just checking if the core needed to be upgraded, we can stop here
    if ($name == 'core') {
        $toupgrade['core']->disablelogin = $disablelogin;
        return $toupgrade['core'];
    }
    $plugins = array();
    if (!empty($name)) {
        try {
            $bits = explode('.', $name);
            $pt = $bits[0];
            $pn = $bits[1];
            $pp = null;
            if ($pt == 'blocktype' && strpos($pn, '/') !== false) {
                $bits = explode('/', $pn);
                $pp = get_config('docroot') . 'artefact/' . $bits[0] . '/blocktype/' . $bits[1];
            }
            validate_plugin($pt, $pn, $pp);
            $plugins[] = explode('.', $name);
        } catch (InstallationException $_e) {
            log_warn("Plugin {$pt} {$pn} is not installable: " . $_e->GetMessage());
        }
    } else {
        foreach ($pluginstocheck as $plugin) {
            $dirhandle = opendir(get_config('docroot') . $plugin);
            while (false !== ($dir = readdir($dirhandle))) {
                if (strpos($dir, '.') === 0) {
                    continue;
                }
                if (!is_dir(get_config('docroot') . $plugin . '/' . $dir)) {
                    continue;
                }
                try {
                    validate_plugin($plugin, $dir);
                    $plugins[] = array($plugin, $dir);
                } catch (InstallationException $_e) {
                    log_warn("Plugin {$plugin} {$dir} is not installable: " . $_e->GetMessage());
                }
                if ($plugin == 'artefact') {
                    // go check it for blocks as well
                    $btlocation = get_config('docroot') . $plugin . '/' . $dir . '/blocktype';
                    if (!is_dir($btlocation)) {
                        continue;
                    }
                    $btdirhandle = opendir($btlocation);
                    while (false !== ($btdir = readdir($btdirhandle))) {
                        if (strpos($btdir, '.') === 0) {
                            continue;
                        }
                        if (!is_dir(get_config('docroot') . $plugin . '/' . $dir . '/blocktype/' . $btdir)) {
                            continue;
                        }
                        $plugins[] = array('blocktype', $dir . '/' . $btdir);
                    }
                }
            }
        }
    }
    foreach ($plugins as $plugin) {
        $plugintype = $plugin[0];
        $pluginname = $plugin[1];
        $pluginpath = "{$plugin['0']}/{$plugin['1']}";
        $pluginkey = "{$plugin['0']}.{$plugin['1']}";
        if ($plugintype == 'blocktype' && strpos($pluginname, '/') !== false) {
            // sigh.. we're a bit special...
            $bits = explode('/', $pluginname);
            $pluginpath = 'artefact/' . $bits[0] . '/blocktype/' . $bits[1];
        }
        // Don't try to get the plugin info if we are installing - it will
        // definitely fail
        $pluginversion = 0;
        if (!$installing && table_exists(new XMLDBTable($plugintype . '_installed'))) {
            if ($plugintype == 'blocktype' && strpos($pluginname, '/')) {
                $bits = explode('/', $pluginname);
                $installed = get_record('blocktype_installed', 'name', $bits[1], 'artefactplugin', $bits[0]);
            } else {
                $installed = get_record($plugintype . '_installed', 'name', $pluginname);
            }
            if ($installed) {
                $pluginversion = $installed->version;
                $pluginrelease = $installed->release;
            }
        }
        $config = new StdClass();
        require get_config('docroot') . $pluginpath . '/version.php';
        if (isset($config->disablelogin) && !empty($config->disablelogin)) {
            $disablelogin = true;
        }
        if (empty($pluginversion)) {
            if (empty($installing) && $pluginkey != $name) {
                continue;
            }
            $plugininfo = new StdClass();
            $plugininfo->install = true;
            $plugininfo->to = $config->version;
            $plugininfo->torelease = $config->release;
            if (property_exists($config, 'requires_config')) {
                $plugininfo->requires_config = $config->requires_config;
            }
            if (property_exists($config, 'requires_parent')) {
                $plugininfo->requires_parent = $config->requires_parent;
            }
            $toupgrade[$pluginkey] = $plugininfo;
        } else {
            if ($config->version > $pluginversion) {
                if (isset($config->minupgradefrom) && isset($config->minupgraderelease) && $pluginversion < $config->minupgradefrom) {
                    throw new ConfigSanityException("Must upgrade to {$config->minupgradefrom} " . " ({$config->minupgraderelease}) first " . " (you have {$pluginversion} ({$pluginrelease}))");
                }
                $plugininfo = new StdClass();
                $plugininfo->upgrade = true;
                $plugininfo->from = $pluginversion;
                $plugininfo->fromrelease = $pluginrelease;
                $plugininfo->to = $config->version;
                $plugininfo->torelease = $config->release;
                if (property_exists($config, 'requires_config')) {
                    $plugininfo->requires_config = $config->requires_config;
                }
                if (property_exists($config, 'requires_parent')) {
                    $plugininfo->requires_parent = $config->requires_parent;
                }
                $toupgrade[$pluginkey] = $plugininfo;
            }
        }
    }
    // if we've just asked for one, don't return an array...
    if (!empty($name) && count($toupgrade) == 1) {
        $upgrade = new StdClass();
        $upgrade->name = $name;
        foreach ((array) $toupgrade[$name] as $key => $value) {
            $upgrade->{$key} = $value;
        }
        $upgrade->disablelogin = $disablelogin;
        return $upgrade;
    }
    $toupgrade['disablelogin'] = $disablelogin;
    if (count($toupgrade) == 1) {
        $toupgrade = array();
    }
    uksort($toupgrade, 'sort_upgrades');
    return $toupgrade;
}
Пример #20
0
function fv_wp_flowplayer_install_extension($plugin_package = 'fv_player_pro')
{
    global $hook_suffix;
    $aInstalled = get_option('fv_flowplayer_extension_install') ? get_option('fv_flowplayer_extension_install') : array();
    $aInstalled = array_merge($aInstalled, array($plugin_package => false));
    update_option('fv_flowplayer_extension_install', $aInstalled);
    $aPluginInfo = get_transient('fv_flowplayer_license');
    $plugin_basename = $aPluginInfo->{$plugin_package}->slug;
    $download_url = $aPluginInfo->{$plugin_package}->url;
    $sPluginBasenameReal = fv_flowplayer_get_extension_path(str_replace('_', '-', $plugin_package));
    $plugin_basename = $sPluginBasenameReal ? $sPluginBasenameReal : $plugin_basename;
    $url = wp_nonce_url(site_url() . '/wp-admin/options-general.php?page=fvplayer', 'fv_player_pro_install', 'nonce_fv_player_pro_install');
    set_current_screen();
    ob_start();
    if (false === ($creds = request_filesystem_credentials($url, '', false, false, false))) {
        $form = ob_get_clean();
        include ABSPATH . 'wp-admin/admin-header.php';
        echo fv_wp_flowplayer_install_extension_talk($form);
        include ABSPATH . 'wp-admin/admin-footer.php';
        die;
    }
    if (!WP_Filesystem($creds)) {
        ob_start();
        request_filesystem_credentials($url, $method, true, false, false);
        $form = ob_get_clean();
        include ABSPATH . 'wp-admin/admin-header.php';
        echo fv_wp_flowplayer_install_extension_talk($form);
        include ABSPATH . 'wp-admin/admin-footer.php';
        die;
    }
    require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    $sTaskDone = 'FV Flowplayer Pro extension installed - check the new <a href="' . site_url() . '/wp-admin/options-general.php?page=fvplayer#fv_player_pro">Pro features!</a>!';
    if (!$sPluginBasenameReal || is_wp_error(validate_plugin($plugin_basename))) {
        echo '<div style="display: none;">';
        $objInstaller = new Plugin_Upgrader();
        $objInstaller->install($download_url);
        echo '</div>';
        wp_cache_flush();
        if (is_wp_error($objInstaller->skin->result)) {
            update_option('fv_wordpress_flowplayer_deferred_notices', 'FV Flowplayer Pro extension install failed - ' . $objInstaller->skin->result->get_error_message());
            $bResult = false;
        } else {
            if ($objInstaller->plugin_info()) {
                $plugin_basename = $objInstaller->plugin_info();
            }
            $activate = activate_plugin($plugin_basename);
            if (is_wp_error($activate)) {
                update_option('fv_wordpress_flowplayer_deferred_notices', 'FV Flowplayer Pro extension install failed - ' . $activate->get_error_message());
                $bResult = false;
            }
        }
    } else {
        if ($sPluginBasenameReal) {
            $sTaskDone = 'FV Flowplayer Pro extension upgraded succesfully!';
            echo '<div style="display: none;">';
            $objInstaller = new Plugin_Upgrader();
            $objInstaller->upgrade($sPluginBasenameReal);
            echo '</div></div>';
            //  explanation: extra closing tag just to be safe (in case of "The plugin is at the latest version.")
            wp_cache_flush();
            if (is_wp_error($objInstaller->skin->result)) {
                update_option('fv_wordpress_flowplayer_deferred_notices', 'FV Flowplayer Pro extension upgrade failed - ' . $objInstaller->skin->result->get_error_message());
                $bResult = false;
            } else {
                if ($objInstaller->plugin_info()) {
                    $plugin_basename = $objInstaller->plugin_info();
                }
                $activate = activate_plugin($plugin_basename);
                if (is_wp_error($activate)) {
                    update_option('fv_wordpress_flowplayer_deferred_notices', 'FV Flowplayer Pro extension upgrade failed - ' . $activate->get_error_message());
                    $bResult = false;
                }
            }
        }
    }
    if (!isset($bResult)) {
        if (!isset($_GET['page']) || strcmp($_GET['page'], 'fvplayer') != 0) {
            update_option('fv_wordpress_flowplayer_deferred_notices', $sTaskDone);
        }
        $bResult = true;
    }
    $aInstalled = get_option('fv_flowplayer_extension_install') ? get_option('fv_flowplayer_extension_install') : array();
    $aInstalled = array_merge($aInstalled, array($plugin_package => $bResult));
    update_option('fv_flowplayer_extension_install', $aInstalled);
    return $bResult;
}
Пример #21
0
 public function ssw_find_plugins()
 {
     global $wpdb;
     $options = $this->ssw_fetch_config_options();
     $wpmu_pretty_plugins = $options['external_plugins']['wpmu_pretty_plugins'];
     $plugins_list = array('');
     if ($wpmu_pretty_plugins == true) {
         $plugins_categories = get_site_option($this->wpmu_pretty_plugins_categories_site_option);
         $all_plugins = get_site_option($this->wpmu_pretty_plugins_plugins_list_site_option);
         foreach ($all_plugins as $key => $value) {
             if (!function_exists('validate_plugin')) {
                 require_once ABSPATH . 'wp-admin/includes/plugin.php';
             }
             /* Validate if the plugin still exists in the system though it is present in Pretty Plugins list */
             $validated = validate_plugin($key);
             if (!is_wp_error($validated)) {
                 /* Find list of all plugins which are not network activated and store it in plugins_list variable */
                 if (!is_plugin_active_for_network($key)) {
                     $plugins_list[$key] = $value;
                 }
             }
         }
     } else {
         if (!function_exists('get_plugins')) {
             require_once ABSPATH . 'wp-admin/includes/plugin.php';
         }
         $all_plugins = get_plugins();
         foreach ($all_plugins as $key => $value) {
             /* Find list of all plugins which are not network activated and store it in plugins_list variable */
             if (!is_plugin_active_for_network($key)) {
                 $plugins_list[$key] = $value;
             }
         }
         $plugins_categories = array('');
     }
     $plugin_options['plugins_categories'] = $plugins_categories;
     $plugin_options['plugins_list'] = $plugins_list;
     $this->ssw_update_plugin_options($plugin_options);
 }
        /**
         * add_option_page callback operations
         * The settings page
         */
        function admin_page()
        {
            global $current_user, $reactivate_wp_reset_additional;
            if (isset($_POST['wordpress_reset_confirm']) && $_POST['wordpress_reset_confirm'] != 'reset') {
                echo '<div class="error fade"><p><strong>Invalid confirmation word. Please type the word \'reset\' in the confirmation field.</strong></p></div>';
            } elseif (isset($_POST['_wpnonce'])) {
                echo '<div class="error fade"><p><strong>Invalid nonce. Please try again.</strong></p></div>';
            }
            $missing = array();
            if (!empty($reactivate_wp_reset_additional)) {
                foreach ($reactivate_wp_reset_additional as $key => $plugin) {
                    if (is_wp_error(validate_plugin($plugin))) {
                        unset($reactivate_wp_reset_additional[$key]);
                        $missing[] = $plugin;
                    }
                }
            }
            $will_reactivate = defined('REACTIVATE_WP_RESET') && REACTIVATE_WP_RESET === true ? true : false;
            ?>
		<div class="wrap">
			<div id="icon-tools" class="icon32"><br /></div>
			<h1><?php 
            esc_html_e('Reset', 'wp-reset');
            ?>
</h1>
			<h2><?php 
            esc_html_e('Details about the reset', 'wp-reset');
            ?>
</h2>
			<p><strong><?php 
            esc_html_e('After completing this reset you will be taken to the dashboard.', 'wp-reset');
            ?>
</strong></p>
			<?php 
            $admin = get_user_by('login', 'admin');
            ?>
			<?php 
            if (!isset($admin->user_login) || $admin->user_level < 10) {
                $user = $current_user;
                ?>
				<p><?php 
                printf(esc_html__('The "admin" user does not exist. The user %s will be recreated using its current password with user level 10.', 'wp-reset'), '<strong>' . esc_html($user->user_login) . '</strong>');
                ?>
</p>
			<?php 
            } else {
                ?>
				<p><?php 
                esc_html_e('The "admin" user exists and will be recreated with its current password.', 'wp-reset');
                ?>
</p>
			<?php 
            }
            ?>
			<?php 
            if ($will_reactivate) {
                ?>
				<p><?php 
                _e('This plugin <strong>will be automatically reactivated</strong> after the reset.', 'wp-reset');
                ?>
</p>
			<?php 
            } else {
                ?>
				<p><?php 
                _e('This plugin <strong>will not be automatically reactivated</strong> after the reset.', 'wp-reset');
                ?>
</p>
				<p><?php 
                printf(esc_html__('To have this plugin auto-reactivate, add %1s to your %2s file.', 'wp-reset'), '<span class="code"><code>define( \'REACTIVATE_WP_RESET\', true );</code></span>', '<span class="code">wp-config.php</span>');
                ?>
</p>
			<?php 
            }
            ?>
			<?php 
            if (!empty($reactivate_wp_reset_additional)) {
                ?>
				<?php 
                esc_html_e('The following additional plugins will be reactivated:', 'wp-reset');
                ?>
				<ul style="list-style-type: disc;">
					<?php 
                foreach ($reactivate_wp_reset_additional as $plugin) {
                    ?>
						<?php 
                    $plugin_data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin);
                    ?>
						<li style="margin: 5px 0 0 30px;"><strong><?php 
                    echo esc_html($plugin_data['Name']);
                    ?>
</strong></li>
					<?php 
                }
                ?>
					<?php 
                unset($reactivate_wp_reset_additional, $plugin, $plugin_data);
                ?>
				</ul>
			<?php 
            }
            ?>
			<?php 
            if (!empty($missing)) {
                ?>
				<?php 
                esc_html_e('The following additional plugins are missing and cannot be reactivated:', 'wp-reset');
                ?>
				<ul style="list-style-type: disc;">
					<?php 
                foreach ($missing as $plugin) {
                    ?>
						<li style="margin: 5px 0 0 30px;"><strong><?php 
                    echo esc_html($plugin);
                    ?>
</strong></li>
					<?php 
                }
                ?>
					<?php 
                unset($missing, $plugin);
                ?>
				</ul>
			<?php 
            }
            ?>
			<h3><?php 
            esc_html_e('Reset', 'wp-reset');
            ?>
</h3>
			<p><?php 
            printf(esc_html__('Type %s in the confirmation field to confirm the reset and then click the reset button:', 'wp-reset'), '<strong>reset</strong>');
            ?>
</p>
			<form id="wordpress_reset_form" action="" method="post">
				<?php 
            wp_nonce_field('wordpress_reset');
            ?>
				<input id="wordpress_reset" type="hidden" name="wordpress_reset" value="true" />
				<input id="wordpress_reset_confirm" type="text" name="wordpress_reset_confirm" value="" />
				<p class="submit">
					<input id="wordpress_reset_submit" style="width: 80px;" type="submit" name="Submit" class="button-primary" value="<?php 
            esc_html_e('Reset');
            ?>
" />
				</p>
			</form>
		</div>
		<?php 
        }
    public static function dashboard_widget_footer()
    {
        ?>
		<footer>

		<div class="protect">
			<?php 
        if (Jetpack::is_module_active('protect')) {
            ?>
				<h3><?php 
            echo number_format_i18n(get_site_option('jetpack_protect_blocked_attempts', 0));
            ?>
</h3>
				<p><?php 
            echo esc_html_x('Blocked malicious login attempts', '{#} Blocked malicious login attempts -- number is on a prior line, text is a caption.', 'jetpack');
            ?>
</p>
			<?php 
        } elseif (current_user_can('jetpack_activate_modules') && !self::is_development_mode()) {
            ?>
				<a href="<?php 
            echo esc_url(wp_nonce_url(Jetpack::admin_url(array('action' => 'activate', 'module' => 'protect')), 'jetpack_activate-protect'));
            ?>
" class="button button-jetpack" title="<?php 
            esc_attr_e('Protect helps to keep you secure from brute-force login attacks.', 'jetpack');
            ?>
">
					<?php 
            esc_html_e('Activate Protect', 'jetpack');
            ?>
				</a>
			<?php 
        } else {
            ?>
				<?php 
            esc_html_e('Protect is inactive.', 'jetpack');
            ?>
			<?php 
        }
        ?>
		</div>

		<div class="akismet">
			<?php 
        if (is_plugin_active('akismet/akismet.php')) {
            ?>
				<h3><?php 
            echo number_format_i18n(get_option('akismet_spam_count', 0));
            ?>
</h3>
				<p><?php 
            echo esc_html_x('Spam comments blocked by Akismet.', '{#} Spam comments blocked by Akismet -- number is on a prior line, text is a caption.', 'jetpack');
            ?>
</p>
			<?php 
        } elseif (current_user_can('activate_plugins') && !is_wp_error(validate_plugin('akismet/akismet.php'))) {
            ?>
				<a href="<?php 
            echo esc_url(wp_nonce_url(add_query_arg(array('action' => 'activate', 'plugin' => 'akismet/akismet.php'), admin_url('plugins.php')), 'activate-plugin_akismet/akismet.php'));
            ?>
" class="button button-jetpack">
					<?php 
            esc_html_e('Activate Akismet', 'jetpack');
            ?>
				</a>
			<?php 
        } else {
            ?>
				<p><a href="<?php 
            echo esc_url('https://akismet.com/?utm_source=jetpack&utm_medium=link&utm_campaign=Jetpack%20Dashboard%20Widget%20Footer%20Link');
            ?>
"><?php 
            esc_html_e('Akismet can help to keep your blog safe from spam!', 'jetpack');
            ?>
</a></p>
			<?php 
        }
        ?>
		</div>


		<?php 
        if (!current_user_can('edit_posts') && self::is_user_connected()) {
            ?>
			<div style="width: 100%; text-align: center; padding-top: 20px; clear: both;"><a class="button" title="<?php 
            esc_attr_e('Unlink your account from WordPress.com', 'jetpack');
            ?>
" href="<?php 
            echo esc_url(wp_nonce_url(add_query_arg(array('action' => 'unlink', 'redirect' => 'sub-unlink'), admin_url('index.php')), 'jetpack-unlink'));
            ?>
"><?php 
            esc_html_e('Unlink your account from WordPress.com', 'jetpack');
            ?>
</a></div>
		<?php 
        }
        ?>

		</footer>
		<?php 
    }
Пример #24
0
     wp_enqueue_script('updates');
     require_once ABSPATH . 'wp-admin/admin-header.php';
     echo '<div class="wrap">';
     echo '<h1>' . esc_html($title) . '</h1>';
     $url = self_admin_url('update.php?action=update-selected&amp;plugins=' . urlencode(join(',', $plugins)));
     $url = wp_nonce_url($url, 'bulk-update-plugins');
     echo "<iframe src='{$url}' style='width: 100%; height:100%; min-height:850px;'></iframe>";
     echo '</div>';
     require_once ABSPATH . 'wp-admin/admin-footer.php';
     exit;
 case 'error_scrape':
     if (!current_user_can('activate_plugins')) {
         wp_die(__('You do not have sufficient permissions to activate plugins for this site.'));
     }
     check_admin_referer('plugin-activation-error_' . $plugin);
     $valid = validate_plugin($plugin);
     if (is_wp_error($valid)) {
         wp_die($valid);
     }
     if (!WP_DEBUG) {
         error_reporting(E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR);
     }
     @ini_set('display_errors', true);
     //Ensure that Fatal errors are displayed.
     // Go back to "sandbox" scope so we get the same errors as before
     /**
      * @param string $plugin
      */
     function plugin_sandbox_scrape($plugin)
     {
         wp_register_plugin_realpath(WP_PLUGIN_DIR . '/' . $plugin);
 protected function validate_plugin($plugin)
 {
     if (!isset($plugin) || empty($plugin)) {
         return new WP_Error('missing_plugin', __('You are required to specify a plugin to activate.', 'jetpack'), 400);
     }
     if (is_wp_error($error = validate_plugin(urldecode($plugin)))) {
         return new WP_Error('unknown_plugin', $error->get_error_messages(), 404);
     }
     return true;
 }
 /**
  * Check the status of a plugin.
  *
  * @param string $plugin Base plugin path from plugins directory.
  * @return int 1 if active; 2 if inactive; 0 if not installed
  */
 static function get_plugin_status($location = '')
 {
     $errors = validate_plugin($location);
     // Plugin is found
     if (!is_wp_error($errors)) {
         if (is_plugin_inactive($location)) {
             return 2;
         }
         return 1;
     } else {
         return false;
     }
 }
    function wp_all_import_addon_notifications()
    {
        if (!empty($_GET['page']) and preg_match('%(pmxi-admin)%i', $_GET['page'])) {
            if (!function_exists('is_plugin_active')) {
                require_once ABSPATH . 'wp-admin/includes/plugin.php';
            }
            $current_theme = wp_get_theme();
            $parent_theme = $current_theme->parent();
            $theme_name = $current_theme->get('Name');
            $parent_theme_name = $parent_theme ? $parent_theme->get('Name') : '';
            $current_themes = array($theme_name, $parent_theme_name);
            $recommended_addons = array();
            // Reales WP Add-On
            if (in_array('Reales WP', $current_themes) and is_wp_error(validate_plugin('reales-wp-xml-csv-property-listings-import/reales-add-on.php'))) {
                $recommended_addons[] = array('title' => 'Reales WP', 'url' => 'https://wordpress.org/plugins/reales-wp-xml-csv-property-listings-import/');
            }
            // WooCommerce Add-On
            if (is_plugin_active('woocommerce/woocommerce.php') and is_wp_error(validate_plugin('woocommerce-xml-csv-product-import/plugin.php')) and is_wp_error(validate_plugin('wpai-woocommerce-add-on/wpai-woocommerce-add-on.php'))) {
                $recommended_addons[] = array('title' => 'WooCommerce', 'url' => 'https://wordpress.org/plugins/woocommerce-xml-csv-product-import/');
            }
            // WP Job Manager Add-On
            if (is_plugin_active('wp-job-manager/wp-job-manager.php') and is_wp_error(validate_plugin('wp-job-manager-xml-csv-listings-import/wp-job-manager-add-on.php'))) {
                $recommended_addons[] = array('title' => 'WP Job Manager', 'url' => 'https://wordpress.org/plugins/wp-job-manager-xml-csv-listings-import/');
            }
            // WP Residence Add-On
            if (is_wp_error(validate_plugin('wp-residence-add-on-for-wp-all-import/wp-residence-add-on.php')) and (preg_match('%(WP Residence)%i', $theme_name) or preg_match('%(WP Residence)%i', $parent_theme_name))) {
                $recommended_addons[] = array('title' => 'WP Residence', 'url' => 'https://wordpress.org/plugins/wp-residence-add-on-for-wp-all-import/');
            }
            // Realia Add-On
            if (is_wp_error(validate_plugin('realia-xml-csv-property-listings-import/realia-add-on.php')) and (in_array('Realia', $current_themes) or is_plugin_active('realia/realia.php'))) {
                $recommended_addons[] = array('title' => 'Realia', 'url' => 'https://wordpress.org/plugins/realia-xml-csv-property-listings-import/');
            }
            // Listify Add-On
            if (in_array('Listify', $current_themes) and is_wp_error(validate_plugin('listify-xml-csv-listings-import/listify-add-on.php'))) {
                $recommended_addons[] = array('title' => 'Listify', 'url' => 'https://wordpress.org/plugins/listify-xml-csv-listings-import/');
            }
            // RealHomes Add-On
            if (in_array('RealHomes Theme', $current_themes) and is_wp_error(validate_plugin('realhomes-xml-csv-property-listings-import/realhomes-add-on.php'))) {
                $recommended_addons[] = array('title' => 'RealHomes', 'url' => 'https://wordpress.org/plugins/realhomes-xml-csv-property-listings-import/');
            }
            // Jobify Add-On
            if (in_array('Jobify', $current_themes) and is_wp_error(validate_plugin('jobify-xml-csv-listings-import/jobify-add-on.php'))) {
                $recommended_addons[] = array('title' => 'Jobify', 'url' => 'https://wordpress.org/plugins/jobify-xml-csv-listings-import/');
            }
            // Yoast SEO Add-On
            if (is_plugin_active('wordpress-seo/wp-seo.php') and is_wp_error(validate_plugin('yoast-seo-settings-xml-csv-import/yoast-addon.php'))) {
                $recommended_addons[] = array('title' => 'Yoast SEO', 'url' => 'https://wordpress.org/plugins/yoast-seo-settings-xml-csv-import/');
            }
            // ACF Add-On
            if (is_plugin_active('advanced-custom-fields-pro/acf.php') and is_wp_error(validate_plugin('wpai-acf-add-on/wpai-acf-add-on.php'))) {
                if (!get_option(sanitize_key($addon['title']) . '_notice_ignore')) {
                    ?>
					<div class="updated notice is-dismissible wpallimport-dismissible" rel="<?php 
                    echo sanitize_key($addon['title']);
                    ?>
"><p>
						<?php 
                    printf(__('Make imports easier with the <strong>Advanced Custom Fields Add-On</strong> for WP All Import: <a href="%s" target="_blank">Read More</a>', 'wp_all_import_plugin'), 'http://www.wpallimport.com/advanced-custom-fields/');
                    ?>
					</p></div>
					<?php 
                }
            }
            if (!empty($recommended_addons)) {
                foreach ($recommended_addons as $addon) {
                    if (!get_option(sanitize_key($addon['title']) . '_notice_ignore')) {
                        ?>
						<div class="updated notice is-dismissible wpallimport-dismissible" rel="<?php 
                        echo sanitize_key($addon['title']);
                        ?>
"><p>
							<?php 
                        printf(__('Make imports easier with the <strong>free %s Add-On</strong> for WP All Import: <a href="%s" target="_blank">Get Add-On</a>', 'wp_all_import_plugin'), $addon['title'], $addon['url']);
                        ?>
						</p></div>
						<?php 
                    }
                }
            }
        }
    }
Пример #28
0
/**
 * Returns all directories of installed plugins except for local
 * from the current codebase.
 *
 * This is relatively slow and not fully cached, use with care!
 *
 * @return array ('plugintkey' => path, ...)
 * For example, array (
 *     'artefact.blog' => $CFG->docroot . 'artefact/blog',
 *     'blocktype.blog' => $CFG->docroot . 'artefact/blog/blocktype/blog',
 *     ...
 * )
 */
function get_installed_plugins_paths()
{
    $versions = array();
    // All installed plugins
    $plugins = array();
    foreach (plugin_types_installed() as $plugin) {
        $dirhandle = opendir(get_config('docroot') . $plugin);
        while (false !== ($dir = readdir($dirhandle))) {
            if (strpos($dir, '.') === 0 || 'CVS' == $dir) {
                continue;
            }
            if (!is_dir(get_config('docroot') . $plugin . '/' . $dir)) {
                continue;
            }
            try {
                validate_plugin($plugin, $dir);
                $plugins[] = array($plugin, $dir);
            } catch (InstallationException $_e) {
                log_warn("Plugin {$plugin} {$dir} is not installable: " . $_e->GetMessage());
            }
            if ($plugin === 'artefact') {
                // go check it for blocks as well
                $btlocation = get_config('docroot') . $plugin . '/' . $dir . '/blocktype';
                if (!is_dir($btlocation)) {
                    continue;
                }
                $btdirhandle = opendir($btlocation);
                while (false !== ($btdir = readdir($btdirhandle))) {
                    if (strpos($btdir, '.') === 0 || 'CVS' == $btdir) {
                        continue;
                    }
                    if (!is_dir(get_config('docroot') . $plugin . '/' . $dir . '/blocktype/' . $btdir)) {
                        continue;
                    }
                    $plugins[] = array('blocktype', $dir . '/' . $btdir);
                }
            }
        }
    }
    $pluginpaths = array();
    foreach ($plugins as $plugin) {
        $plugintype = $plugin[0];
        $pluginname = $plugin[1];
        $pluginpath = "{$plugin['0']}/{$plugin['1']}";
        $pluginkey = "{$plugin['0']}.{$plugin['1']}";
        if ($plugintype == 'blocktype' && strpos($pluginname, '/') !== false) {
            $bits = explode('/', $pluginname);
            $pluginpath = 'artefact/' . $bits[0] . '/blocktype/' . $bits[1];
        }
        $pluginpaths[$pluginkey] = get_config('docroot') . $pluginpath;
    }
    return $pluginpaths;
}
Пример #29
0
/**
 * Validate active plugins
 *
 * Validate all active plugins, deactivates invalid and
 * returns an array of deactivated ones.
 *
 * @since 2.5.0
 * @return array invalid plugins, plugin as key, error as value
 */
function validate_active_plugins()
{
    $plugins = get_option('active_plugins', array());
    // validate vartype: array
    if (!is_array($plugins)) {
        update_option('active_plugins', array());
        $plugins = array();
    }
    if (is_multisite() && is_super_admin()) {
        $network_plugins = (array) get_site_option('active_sitewide_plugins', array());
        $plugins = array_merge($plugins, array_keys($network_plugins));
    }
    if (empty($plugins)) {
        return;
    }
    $invalid = array();
    // invalid plugins get deactivated
    foreach ($plugins as $plugin) {
        $result = validate_plugin($plugin);
        if (is_wp_error($result)) {
            $invalid[$plugin] = $result;
            deactivate_plugins($plugin, true);
        }
    }
    return $invalid;
}
Пример #30
0
    function display($agent_type, $id_suffix, $current_selections = array(), $args = array())
    {
        $defaults = array('agent_id' => 0, 'context' => '', 'label_select' => _x('Select &gt;', 'user', 'pp'), 'label_unselect' => _x('&lt; Unselect', 'user', 'pp'), 'label_selections' => __('Current Selections:', 'pp'), 'display_stored_selections' => true, 'create_dropdowns' => false, 'width' => '', 'width_current' => '', 'label_headline' => true, 'multi_select' => true, 'use_selection_js' => true);
        $args = apply_filters('pp_agents_selection_ui_args', array_merge($defaults, $args), $agent_type, $id_suffix);
        extract($args, EXTR_SKIP);
        $width = $width ? "width:{$width}px;" : '';
        $this->register_ajax_js($agent_type, $id_suffix, $context, $agent_id, $args);
        if (true === $label_headline) {
            $label_headline = 'user' == $agent_type ? __('Select Users', 'pp') : __('Select Groups', 'pp');
        }
        ?>
		<table id="pp-agent-selection_<?php 
        echo $id_suffix;
        ?>
-wrapper" class="pp-agents-selection">
		<tr><td id="pp-agent-selection_<?php 
        echo $id_suffix;
        ?>
">
		<h4><?php 
        echo $label_headline;
        ?>
</h4>
		<input id="agent_search_text_<?php 
        echo $id_suffix;
        ?>
" type="text" size="8" />
		<button type="button" class="pp-agent-search-submit" id="agent_submit_<?php 
        echo $id_suffix;
        ?>
"><?php 
        echo __ppw("Search");
        ?>
</button>
		<img class="waiting" style="display:none;" src="<?php 
        echo esc_url(admin_url('images/wpspin_light.gif'));
        ?>
" alt="" />
		
		<?php 
        if ('user' == $agent_type && pp_get_option('user_search_by_role')) {
            ?>
			<br /><select id="pp_search_role_<?php 
            echo $id_suffix;
            ?>
">
			<option value=""><?php 
            _e('(any WP role)', 'pp');
            ?>
</option>
			<?php 
            wp_dropdown_roles();
            ?>
			</select>
		<?php 
        }
        ?>
		
		</td>
		
		<?php 
        if ($display_stored_selections) {
            ?>
		<td style="vertical-align:bottom" class="pp-members-current"><h4><?php 
            echo $label_selections;
            ?>
</h4></td>
		<?php 
        }
        ?>
		
		</tr>
		
		<tr><td>
		<select id="agent_results_<?php 
        echo $id_suffix;
        ?>
" class="pp_agent_results" <?php 
        if ($multi_select) {
            ?>
multiple="multiple" style="height:160px;<?php 
        } else {
            ?>
style="display:none;<?php 
        }
        echo $width;
        ?>
"></select>
		<span id="agent_msg_<?php 
        echo $id_suffix;
        ?>
"></span>
		</td>

		<?php 
        if ($display_stored_selections) {
            if ($width_current) {
                $width = "width:{$width_current}px;";
            }
            ?>
		<td class="pp-members-current">
		<select id='<?php 
            echo $id_suffix;
            ?>
' name='<?php 
            echo $id_suffix;
            ?>
[]' multiple='multiple' style='height:160px;<?php 
            echo $width;
            ?>
float:right'>
		
<?php 
            $display_property = 'user' == $agent_type ? 'user_login' : 'display_name';
            foreach ($current_selections as $agent) {
                $attribs = isset($agent->display_name) && $agent->user_login != $agent->display_name ? 'title="' . esc_attr($agent->display_name) . '"' : '';
                ?>
		<?php 
                $data = apply_filters('pp_agents_selection_ui_attribs', array('attribs' => $attribs, 'user_caption' => $agent->{$display_property}), $agent_type, $id_suffix, $agent);
                ?>
		<option value="<?php 
                echo $agent->ID;
                ?>
" <?php 
                echo $data['attribs'];
                ?>
><?php 
                echo $data['user_caption'];
                ?>
</option>
<?php 
            }
            ?>

		</select><br />
		</td>
		<?php 
        }
        ?>
		
		</tr>
		
		<?php 
        do_action('_pp_agents_selection_ui_select_pre', $id_suffix);
        ?>
		<tr>
		<?php 
        do_action('pp_agents_selection_ui_select_pre', $id_suffix);
        ?>
		

		<td><button type="button" id="select_agents_<?php 
        echo $id_suffix;
        ?>
" class="pp_add" style="float:right<?php 
        if (!$multi_select) {
            ?>
;display:none;<?php 
        }
        ?>
"><?php 
        echo $label_select;
        ?>
</button></td>
		
		<?php 
        if ($display_stored_selections) {
            ?>
		<td class="pp-members-current"><button type="button" id="unselect_agents_<?php 
            echo $id_suffix;
            ?>
" class="pp_remove"><?php 
            echo $label_unselect;
            ?>
</button></td>
		<?php 
        }
        ?>
		
		</tr>
		</table>	
<?php 
        if (!defined('PPM_VERSION') && pp_get_option('display_extension_hints')) {
            if (0 === validate_plugin("pp-membership/pp-membership.php")) {
                $msg = __('To set date limits on group membership, activate the PP Membership plugin.', 'pp');
            } elseif (true == pp_key_status()) {
                $msg = sprintf(__('To set date limits on group membership, %1$sinstall%2$s the PP Membership plugin.', 'pp'), '<a href="admin.php?page=pp-settings&pp_tab=install">', '</a>');
            } else {
                $msg = sprintf(__('To set date limits on group membership, %1$senter%2$s or %3$spurchase%4$s a support key and install the PP Membership plugin.', 'pp'), '<a href="admin.php?page=pp-settings&pp_tab=install">', '</a>', '<a href="http://presspermit.com/purchase">', '</a>');
            }
            echo "<div class='pp-ext-promo'>{$msg}</div>";
        }
        $csv = $current_selections ? implode(',', array_keys($current_selections)) : '';
        $csv = apply_filters('pp_agents_selection_ui_csv', $csv, $id_suffix, $current_selections);
        ?>
		<input type="hidden" id="<?php 
        echo $id_suffix;
        ?>
_csv" name="<?php 
        echo $id_suffix;
        ?>
_csv" value="<?php 
        echo $csv;
        ?>
" />
		<?php 
    }