/** * Modify the links that appear on the Manage Stacks page beneath the Stack Titles on the right. * * @since 1.0.0 * @link http://mintplugins.com/doc/ * @see mp_core_add_query_arg() * @param $actions * @param $tag * @return $actions */ function mp_stacks_remove_quick_edit($actions, $tag) { unset($actions['inline hide-if-no-js']); //If this is a developer if (function_exists('mp_stacks_developer_textdomain')) { //Show the manual brick edit option $actions['view'] = '<a href="' . mp_core_add_query_arg(array('mp_stacks' => $tag->term_id), 'edit.php?post_type=mp_brick') . '">' . __("Edit this Stack's Bricks", 'mp_stacks') . '</a>'; } //Make the "Manage Stacks" page's "view" links to lists of bricks-per-stack instead of the front end archive page $actions['edit'] = '<a href="' . mp_core_add_query_arg(array('page' => 'mp-stacks-single-stack-edit-page', 'stack_id' => $tag->term_id), admin_url('admin.php')) . '">' . __("Edit", 'mp_stacks') . '</a>'; return $actions; }
/** * Renders a new tab on the settings page. This is called by the settings page. * * @access public * @since 1.0.0 * @see mp_core_add_query_arg() * @see get_admin_url() * @return void */ public function new_tab($active_tab, $tab_info) { //Get Parent Slug $parent_slug = isset($this->_args['parent_slug']) ? $this->_args['parent_slug'] : NULL; //If active tab is equal to the passd in tab slug, add the "active class" to the class atrribute $active_class = $active_tab == $this->_args['slug'] . '_' . $tab_info['slug'] ? 'nav-tab-active' : NULL; //Set tab link based on whether there is a parent_slug $tab_link = mp_core_add_query_arg(array('page' => $this->_args['slug'], 'tab' => $this->_args['slug'] . '_' . $tab_info['slug']), get_admin_url() . $parent_slug); //echo HTML for tab echo '<a href="' . $tab_link . '" class="nav-tab ' . $active_class . '">' . $tab_info['title'] . '</a>'; }
/** * Output css for all Stacks on this page in shortcodes into the a separate CSS file which is enqueued. * Parameter: none */ function mp_stacks_header_css() { //Loop through the query if (have_posts()) { while (have_posts()) { the_post(); $content = get_the_content(); //Execute all MP Stack shortcodes if (has_shortcode($content, 'mp_stack')) { //Find all mp_stack short codes preg_match_all("/(\\[mp_stack stack=\")(.*?)(\"\\])/", get_the_content(), $matches, PREG_SET_ORDER); //Loop through each stack shortcode foreach ($matches as $val) { //Output CSS for this stack //mp_stack_css( $val[2], true ); //Enqueue the CSS for this stack wp_enqueue_style('mp_stacks_css_' . $val[2], mp_core_add_query_arg(array('mp_stacks_css_page' => $val[2]), get_bloginfo('wpurl')), false, mp_stack_last_modified($val[2])); } } } // end of the loop. } //Reset the main loop wp_reset_postdata(); }
/** * MP Stacks Stack Packs - Plugin Directory Class for the mp_stacks Plugin by Mint Plugins * http://mintplugins.com/doc/plugin-directory-class/ */ function mp_stacks_template_packs_plugin_directory() { $args = array('parent_slug' => 'mp-stacks-about', 'page_title' => 'Stack Templates', 'slug' => 'mp_stacks_template_packs_plugin_directory', 'directory_list_url' => 'http://mintplugins.com/repo-group/mp-stacks-template-packs/', 'plugin_success_link' => mp_core_add_query_arg(array('page' => 'mp_stack_template_packs_plugin_directory'), admin_url('admin.php'))); new MP_CORE_Plugin_Directory($args); }
/** * Show Plugins on Page * * @access public * @since 1.0.0 * @see screen_icon() * @see sanitize_title() * @see MP_CORE_Plugin_Directory::check_if_plugin_is_on_this_server() * @see MP_CORE_Plugin_Directory::display_license() * @see wp_nonce_url() * @see plugins_api() * @see wp_create_nonce() * @return void */ public function plugin_directory_page() { echo '<div class="wrap">'; echo screen_icon('plugins') . '<h2>' . apply_filters('mp_core_directory_' . $this->_args['slug'] . '_title', $this->_args['page_title']) . '</h2>'; do_action('mp_core_directory_header_' . $this->_args['slug']); ?> <div class="wp-filter"> <ul class="filter-links"> <?php $description = NULL; //If multiple categories have been sent if (is_array($this->_args['directory_list_urls'])) { //If we are doing a search if ($this->_mp_directory_tab == 'search') { ?> <li class="plugin-install-search"><a href="<?php echo mp_core_add_query_arg(array('page' => $this->_args['slug'], 'mp_core_directory_tab' => 'search'), admin_url('admin.php')); ?> " class=" current"><?php echo __('Search Results', 'mp_core'); ?> </a> </li> <?php } //Loop through each Directory List URL passed-in foreach ($this->_args['directory_list_urls'] as $directory_list_slug => $directory_list_array) { ?> <li class="<?php echo $directory_list_slug; ?> "><a href="<?php echo mp_core_add_query_arg(array('page' => $this->_args['slug'], 'mp_core_directory_tab' => $directory_list_slug), admin_url('admin.php')); ?> " <?php echo $this->_mp_directory_tab == $directory_list_slug ? 'class="current"' : NULL; ?> ><?php echo $directory_list_array['title']; ?> </a> </li> <?php $description = $this->_mp_directory_tab == $directory_list_slug ? $directory_list_array['description'] : $description; } } ?> </ul> <form class="search-form search-plugins" method="get" action=""> <input type="hidden" name="mp_core_directory_tab" value="search"> <input type="hidden" name="page" value="<?php echo $this->_args['slug']; ?> "> <label><span class="screen-reader-text"><?php echo __('Search ', 'mp_core') . $this->_args['page_title']; ?> </span> <input type="search" name="search" value="<?php echo isset($_GET['search']) ? $_GET['search'] : ''; ?> " class="" placeholder="<?php echo __('Search ', 'mp_core') . $this->_args['page_title']; ?> "> </label> <input type="submit" name="" id="search-submit" class="button screen-reader-text" value="<?php echo __('Search ', 'mp_core') . $this->_args['page_title']; ?> "> </form> </div> <br class="clear"> <div class="tablenav top"> <div class="alignleft actions"> </div> <div class="tablenav-pages"> <span class="displaying-num"><?php echo $this->response['total_items']; ?> <?php echo __('items', 'mp_core'); ?> </span> <span class="pagination-links"> <a class="first-page <?php echo $this->_mp_directory_paged == 1 ? 'disabled' : NULL; ?> " title="<?php echo __('Go to the first page', 'mp_core'); ?> " href="<?php echo mp_core_add_query_arg(array('page' => $this->_args['slug'], 'mp_core_directory_tab' => $this->_mp_directory_tab, 'mp_core_directory_paged' => 1), admin_url('admin.php')); ?> ">«</a> <a class="prev-page <?php echo $this->_mp_directory_paged == 1 ? 'disabled' : NULL; ?> " title="<?php echo __('Go to the previous page', 'mp_core'); ?> " href="<?php echo mp_core_add_query_arg(array('page' => $this->_args['slug'], 'mp_core_directory_tab' => $this->_mp_directory_tab, 'mp_core_directory_paged' => $this->_mp_directory_paged == 1 ? 1 : $this->_mp_directory_paged - 1), admin_url('admin.php')); ?> ">‹</a> <span class="paging-input"> <form class="mp-core-directory-paged-form" action="<?php echo admin_url('admin.php'); ?> " method="get"> <label for="current-page-selector" class="screen-reader-text"><?php echo __('Select Page', 'mp_core'); ?> </label> <input class="page" type="hidden" name="page" value="<?php echo $this->_args['slug']; ?> "> <input class="mp_core_directory_tab" type="hidden" name="mp_core_directory_tab" value="<?php echo $this->_mp_directory_tab; ?> "> <input class="current-page" id="current-page-selector" title="Current page" type="text" name="mp_core_directory_paged" value="<?php echo !empty($_GET['mp_core_directory_paged']) ? $_GET['mp_core_directory_paged'] : 1; ?> " size="4"> </form> <?php echo __('of', 'mp_core'); ?> <span class="total-pages"><?php echo $this->response['total_pages']; ?> </span> </span> <a class="next-page <?php echo $this->_mp_directory_paged == $this->response['total_pages'] ? 'disabled' : NULL; ?> " title="<?php echo __('Go to the next page', 'mp_core'); ?> " href="<?php echo mp_core_add_query_arg(array('page' => $this->_args['slug'], 'mp_core_directory_tab' => $this->_mp_directory_tab, 'mp_core_directory_paged' => $this->_mp_directory_paged == $this->response['total_pages'] ? $this->_mp_directory_paged : $this->_mp_directory_paged + 1), admin_url('admin.php')); ?> ">›</a> <a class="last-page <?php echo $this->_mp_directory_paged == $this->response['total_pages'] ? 'disabled' : NULL; ?> " title="<?php echo __('Go to the last page', 'mp_core'); ?> " href="<?php echo mp_core_add_query_arg(array('page' => $this->_args['slug'], 'mp_core_directory_tab' => $this->_mp_directory_tab, 'mp_core_directory_paged' => $this->response['total_pages']), admin_url('admin.php')); ?> ">»</a> </span> </div> </div> <p class="mp-core-directory-tab-description"><?php echo !empty($description) ? $description : NULL; ?> </p> <?php echo '<div class="mp-directory-browser">'; echo '<div id="mp-directory-items">'; if (!is_array($this->plugins) || empty($this->plugins)) { echo '<div class="no-plugin-results">' . __('No items match your request.', 'mp_core') . '</div>'; echo '</div>'; return; } //Loop through all returned plugins from the wp_remote_post in the construct function foreach ($this->plugins as $plugin) { //Plugin Name Slug $plugin_name_slug = sanitize_title($plugin['plugin_name']); //EG move-plugins-core //This next section figures out what do make the $install_output variable //Check if plugin is installed $check_plugin = $this->check_if_plugin_is_on_this_server($plugin); //If the plugin is active if ($check_plugin['plugin_active']) { //Show the green light $installed_output = '<div class="mp-core-true-false-light mp-core-directory-true-false-light">'; $installed_output .= '<div class="mp-core-green-light"></div>'; $installed_output .= '</div>'; //Set $install_output to say the plugin is active $installed_output .= 'Plugin is active'; //If this plugin requires a license, show that license $install_output = $plugin['plugin_licensed'] == true ? $this->display_license($plugin_name_slug, $check_plugin, $plugin['plugin_buy_url'], $plugin['plugin_price']) : sprintf('<a class="button mp-directory-install-btn" href="%s"> ' . __('Re-Install "', 'mp_core') . $plugin['plugin_name'] . '"</a>', admin_url(sprintf('options-general.php?page=mp_core_install_plugin_page_' . $plugin['plugin_slug'] . '&action=install-plugin&mp-source=mp_core_directory&plugin=' . $plugin['plugin_slug'] . '&plugin_api_url=' . base64_encode($plugin['plugin_api_url']) . '&mp_core_directory_page=' . $this->_args['slug'] . '&mp_core_directory_tab=' . $this->_mp_directory_tab . '&_wpnonce=%s', wp_create_nonce('install-plugin')))); } elseif ($check_plugin['plugin_exists']) { //Show the red light $installed_output = '<div class="mp-core-true-false-light mp-core-directory-true-false-light">'; $installed_output .= '<div class="mp-core-grey-light"></div>'; $installed_output .= '</div>'; //Set $install_output to say the plugin is installed but not active $installed_output .= __('Plugin is installed but not active', 'mp_core'); //Set $install_output to "Activate" plugin $install_output = '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $check_plugin['plugin_directory'] . $plugin['plugin_filename'] . '&plugin_status=all&paged=1&s=', 'activate-plugin_' . $check_plugin['plugin_directory'] . $plugin['plugin_filename']) . '" title="' . __('Activate ', 'mp_core') . $plugin['plugin_name'] . '" class="button mp-directory-install-btn" >' . __('Activate ', 'mp_core') . '"' . $plugin['plugin_name'] . '"</a>'; //If this plugin requires a license, show that license $install_output .= $plugin['plugin_licensed'] == true ? $this->display_license($plugin_name_slug, $check_plugin, $plugin['plugin_buy_url'], $plugin['plugin_price']) : NULL; } else { //Show the red light $installed_output = '<div class="mp-core-true-false-light mp-core-directory-true-false-light">'; $installed_output .= '<div class="mp-core-grey-light"></div>'; $installed_output .= '</div>'; //Set $install_output to say the plugin is installed but not active $installed_output .= 'Plugin is not installed.'; /** If plugins_api isn't available, load the file that holds the function */ if (!function_exists('plugins_api')) { require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; } //Check if this plugin exists in the WordPress Repo $args = array('slug' => $plugin_name_slug); $api = plugins_api('plugin_information', $args); //If it doesn't, display link which downloads it from your custom URL if (isset($api->errors)) { //If this plugin requires a license, show that license if ($plugin['plugin_licensed'] == true) { //Create License Output $install_output = $this->display_license($plugin_name_slug, $check_plugin, $plugin['plugin_buy_url'], $plugin['plugin_price']); } else { // "Oops! this plugin doesn't exist in the repo. So lets display a custom download button."; $install_output = sprintf('<a class="button mp-directory-install-btn" href="%s"> ' . __('Install "', 'mp_core') . $plugin['plugin_name'] . '"</a>', admin_url(sprintf('options-general.php?page=mp_core_install_plugin_page_' . $plugin['plugin_slug'] . '&action=install-plugin&mp-source=mp_core_directory&plugin=' . $plugin['plugin_slug'] . '&plugin_api_url=' . base64_encode($plugin['plugin_api_url']) . '&mp_core_directory_page=' . $this->_args['slug'] . '&mp_core_directory_tab=' . $this->_mp_directory_tab . '&_wpnonce=%s', wp_create_nonce('install-plugin')))); } } else { //Otherwise display the WordPress.org Repo Install button $install_output = sprintf('<a class="button mp-directory-install-btn" href="%s"> ' . __('Install "', 'mp_core') . $plugin['plugin_name'] . '"</a>', admin_url(sprintf('update.php?action=install-plugin&mp-source=mp_core_directory&plugin=' . $plugin_name_slug . '&mp_core_directory_tab=' . $this->_mp_directory_tab . '&_wpnonce=%s', wp_create_nonce('install-plugin')))); } } //Show this plugin on the page ?> <div class="plugin-card"> <div class="plugin-card-top"> <a href="<?php echo $plugin['plugin_buy_url']; ?> " class="plugin-icon" target="_blank"><img src="<?php echo str_replace('http://', 'https://', $plugin['plugin_image']); ?> "></a> <div class="name column-name"> <h4><a href="<?php echo mp_core_add_query_arg(array('TB_iframe' => true, 'width' => '772', 'height' => '373'), $plugin['plugin_buy_url']); ?> " class="thickbox" target="_blank"><?php echo $plugin['plugin_name']; ?> </a></h4> </div> <div class="action-links mp-core-directory-price"> <h4><?php echo $plugin['plugin_price']; ?> </h4> </div> <div class="desc column-description"> <p><?php echo $plugin['plugin_description']; ?> </p> <p class="authors"> <cite>By <a href="<?php echo $plugin['plugin_author_url']; ?> " target="_blank"><?php echo $plugin['plugin_author']; ?> </a></cite> </p> </div> </div> <div class="plugin-card-bottom"> <div class="vers column-rating mp-column-installation"> <?php echo $installed_output; ?> <?php echo $install_output; ?> </div> <div class="column-updated mp-column-plugin-status"> </div> </div> </div> <?php } echo '</div>'; do_action('mp_core_directory_footer_' . $this->_args['slug']); echo '</div>'; ?> <div class="tablenav top"> <div class="alignleft actions"> </div> <div class="tablenav-pages"> <span class="displaying-num"><?php echo $this->response['total_items']; ?> <?php echo __('items', 'mp_core'); ?> </span> <span class="pagination-links"> <a class="first-page <?php echo $this->_mp_directory_paged == 1 ? 'disabled' : NULL; ?> " title="<?php echo __('Go to the first page', 'mp_core'); ?> " href="<?php echo mp_core_add_query_arg(array('page' => $this->_args['slug'], 'mp_core_directory_tab' => $this->_mp_directory_tab, 'mp_core_directory_paged' => 1), admin_url('admin.php')); ?> ">«</a> <a class="prev-page <?php echo $this->_mp_directory_paged == 1 ? 'disabled' : NULL; ?> " title="<?php echo __('Go to the previous page', 'mp_core'); ?> " href="<?php echo mp_core_add_query_arg(array('page' => $this->_args['slug'], 'mp_core_directory_tab' => $this->_mp_directory_tab, 'mp_core_directory_paged' => $this->_mp_directory_paged == 1 ? 1 : $this->_mp_directory_paged - 1), admin_url('admin.php')); ?> ">‹</a> <span class="paging-input"> <form class="mp-core-directory-paged-form" action="<?php echo admin_url('admin.php'); ?> " method="get"> <label for="current-page-selector" class="screen-reader-text"><?php echo __('Select Page', 'mp_core'); ?> </label> <input class="page" type="hidden" name="page" value="<?php echo $this->_args['slug']; ?> "> <input class="mp_core_directory_tab" type="hidden" name="mp_core_directory_tab" value="<?php echo $this->_mp_directory_tab; ?> "> <input class="current-page" id="current-page-selector" title="Current page" type="text" name="mp_core_directory_paged" value="<?php echo !empty($_GET['mp_core_directory_paged']) ? $_GET['mp_core_directory_paged'] : 1; ?> " size="4"> </form> <?php echo __('of', 'mp_core'); ?> <span class="total-pages"><?php echo $this->response['total_pages']; ?> </span> </span> <a class="next-page <?php echo $this->_mp_directory_paged == $this->response['total_pages'] ? 'disabled' : NULL; ?> " title="<?php echo __('Go to the next page', 'mp_core'); ?> " href="<?php echo mp_core_add_query_arg(array('page' => $this->_args['slug'], 'mp_core_directory_tab' => $this->_mp_directory_tab, 'mp_core_directory_paged' => $this->_mp_directory_paged == $this->response['total_pages'] ? $this->_mp_directory_paged : $this->_mp_directory_paged + 1), admin_url('admin.php')); ?> ">›</a> <a class="last-page <?php echo $this->_mp_directory_paged == $this->response['total_pages'] ? 'disabled' : NULL; ?> " title="<?php echo __('Go to the last page', 'mp_core'); ?> " href="<?php echo mp_core_add_query_arg(array('page' => $this->_args['slug'], 'mp_core_directory_tab' => $this->_mp_directory_tab, 'mp_core_directory_paged' => $this->response['total_pages']), admin_url('admin.php')); ?> ">»</a> </span> </div> </div><?php }
/** * Navigation tabs * * @access public * @since 1.9 * @return void */ public function tabs() { $selected = isset($_GET['page']) ? $_GET['page'] : 'mp-stacks-about'; ?> <h2 class="nav-tab-wrapper"> <a class="nav-tab <?php echo $selected == 'mp-stacks-about' ? 'nav-tab-active' : ''; ?> " href="<?php echo esc_url(admin_url(mp_core_add_query_arg(array('page' => 'mp-stacks-about'), 'index.php'))); ?> "> <?php _e('Getting Started', 'mp_stacks'); ?> </a> <?php /* <a class="nav-tab <?php echo $selected == 'mp-stacks-whats-new' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( mp_core_add_query_arg( array( 'page' => 'mp-stacks-whats-new' ), 'index.php' ) ) ); ?>"> <?php _e( "What's New", 'mp_stacks' ); ?> </a> <a class="nav-tab <?php echo $selected == 'mp-stacks-credits' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( mp_core_add_query_arg( array( 'page' => 'mp-stacks-credits' ), 'index.php' ) ) ); ?>"> <?php _e( 'Credits', 'mp_stacks' ); ?> </a> */ ?> </h2> <?php }
/** * Set the orderby string based on the URL or the Brick's Meta settings. * * @access public * @since 1.0.0 * @param $post_id String - the ID of the Brick where all the meta is saved. * @param $meta_prefix String - the prefix to put before each meta_field key to differentiate it from other plugins. :EG "postgrid" * @return $return_html String The html for the dropdown where the user chooses the orderby options */ function mp_stacks_grid_orderby_output($post_id, $meta_prefix) { $return_html = NULL; //Before we get to the isotope output, check if there are any orderby options first $orderby_options = mp_core_get_post_meta_multiple_checkboxes($post_id, $meta_prefix . '_isotope_orderby_options', array()); //If orderby options have been set if (is_array($orderby_options) && !empty($orderby_options)) { //Get any orderby params from the URL that might exist $url_order_by = isset($_GET['mp_orderby_' . $post_id]) ? sanitize_text_field($_GET['mp_orderby_' . $post_id]) : NULL; //If there isn't a URL orderby param, get the default orderby setting $default_orderby = empty($url_order_by) ? mp_core_get_post_meta($post_id, $meta_prefix . '_default_orderby', 'date') : $url_order_by; //Add an orderby dropdown menu before the first isotope dropdown $return_html .= '<select class="button mp-stacks-grid-orderby-select" id="mp-isotope-sort-select-' . $post_id . '" class="mp-stacks-grid-orderby-select" value="' . $default_orderby . '">'; //Nicely named orderby options $nicelynamed_orderby_options = apply_filters($meta_prefix . '_isotope_orderby_options', array(), $meta_prefix); //Add each orderby option to the output foreach ($orderby_options as $orderby_option) { $return_html .= '<option orderby_url="' . mp_core_add_query_arg(array('mp_orderby_' . $post_id => $orderby_option), mp_core_get_current_url()) . '" value="' . $orderby_option . '" ' . ($default_orderby == $orderby_option ? ' selected' : NULL) . ' >' . __('Order By: ', 'mp_stacks') . $nicelynamed_orderby_options[$orderby_option] . '</option>'; } $return_html .= '</select>'; } return $return_html; }