Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
brandondove committed Mar 25, 2014
1 parent 91475fd commit 36931e4
Show file tree
Hide file tree
Showing 43 changed files with 3,378 additions and 1,915 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Here's a [guide on how to install WordPress SEO in your WordPress site](https://
If you want to run the Git version though, you have two options:

* You can clone the GitHub repository: https://github.com/yoast/wordpress-seo.git
* Download it directly as a ZIP file: https://github.com/yoast/wordpress-seo/archive/master.zip
* Downloading it directly unfortunately won't work as the .zip file doesn't contain the submodules.

This will download the latest development version of WordPress SEO by Yoast. While this version is usually stable,
it is not recommended for use in a production environment.
Expand Down
60 changes: 38 additions & 22 deletions admin/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,20 @@ function __construct() {
add_action( 'delete_category', array( $this, 'schedule_rewrite_flush' ) );
}

if ( WPSEO_Options::grant_access() ) {
// Needs the lower than default priority so other plugins can hook underneath it without issue.
add_action( 'admin_menu', array( $this, 'register_settings_page' ), 5 );
add_action( 'network_admin_menu', array( $this, 'register_network_settings_page' ) );
// Needs the lower than default priority so other plugins can hook underneath it without issue.
add_action( 'admin_menu', array( $this, 'register_settings_page' ), 5 );
add_action( 'network_admin_menu', array( $this, 'register_network_settings_page' ) );

add_filter( 'plugin_action_links', array( $this, 'add_action_link' ), 10, 2 );
add_action( 'admin_enqueue_scripts', array( $this, 'config_page_scripts' ) );
add_filter( 'plugin_action_links_' . WPSEO_BASENAME, array( $this, 'add_action_link' ), 10, 2 );

if ( '0' == get_option( 'blog_public' ) ) {
add_action( 'admin_footer', array( $this, 'blog_public_warning' ) );
}
add_action( 'admin_enqueue_scripts', array( $this, 'config_page_scripts' ) );

if ( ( ( isset( $options['theme_has_description'] ) && $options['theme_has_description'] === true ) || $options['theme_description_found'] !== '' ) && $options['ignore_meta_description_warning'] !== true ) {
add_action( 'admin_footer', array( $this, 'meta_description_warning' ) );
}
if ( '0' == get_option( 'blog_public' ) ) {
add_action( 'admin_footer', array( $this, 'blog_public_warning' ) );
}

if ( ( ( isset( $options['theme_has_description'] ) && $options['theme_has_description'] === true ) || $options['theme_description_found'] !== '' ) && $options['ignore_meta_description_warning'] !== true ) {
add_action( 'admin_footer', array( $this, 'meta_description_warning' ) );
}

if ( $options['cleanslugs'] === true ) {
Expand Down Expand Up @@ -81,6 +80,9 @@ function schedule_rewrite_flush() {
* @global array $submenu used to change the label on the first item.
*/
function register_settings_page() {
if( WPSEO_Options::grant_access() !== true ) {
return;
}

// Add main page
$admin_page = add_menu_page( __( 'Yoast WordPress SEO:', 'wordpress-seo' ) . ' ' . __( 'General Settings', 'wordpress-seo' ), __( 'SEO', 'wordpress-seo' ), 'manage_options', 'wpseo_dashboard', array( $this, 'load_page' ), plugins_url( 'images/yoast-icon.png', WPSEO_FILE ), '99.31337' );
Expand Down Expand Up @@ -162,7 +164,7 @@ function title_metas_help_tab() {
'id' => 'title-vars',
'title' => __( 'Basic Variables', 'wordpress-seo' ),
'content' => '
<h2>' . __( 'Basic Variables.', 'wordpress-seo' ) . '</h2>
<h2>' . __( 'Basic Variables', 'wordpress-seo' ) . '</h2>
<table class="yoast_help">
<tr>
<th>%%date%%</th>
Expand Down Expand Up @@ -227,9 +229,9 @@ function title_metas_help_tab() {
$screen->add_help_tab(
array(
'id' => 'title-vars-advanced',
'title' => __( 'Advanced Variables.', 'wordpress-seo' ),
'title' => __( 'Advanced Variables', 'wordpress-seo' ),
'content' => '
<h2>' . __( 'Advanced Variables.', 'wordpress-seo' ) . '</h2>
<h2>' . __( 'Advanced Variables', 'wordpress-seo' ) . '</h2>
<table class="yoast_help">
<tr>
<th>%%pt_single%%</th>
Expand Down Expand Up @@ -320,7 +322,9 @@ function title_metas_help_tab() {
* Register the settings page for the Network settings.
*/
function register_network_settings_page() {
add_menu_page( __( 'Yoast WordPress SEO:', 'wordpress-seo' ) . ' ' . __( 'MultiSite Settings', 'wordpress-seo' ), __( 'SEO', 'wordpress-seo' ), 'delete_users', 'wpseo_dashboard', array( $this, 'network_config_page' ), plugins_url( 'images/yoast-icon.png', WPSEO_FILE ) );
if( WPSEO_Options::grant_access() ) {
add_menu_page( __( 'Yoast WordPress SEO:', 'wordpress-seo' ) . ' ' . __( 'MultiSite Settings', 'wordpress-seo' ), __( 'SEO', 'wordpress-seo' ), 'delete_users', 'wpseo_dashboard', array( $this, 'network_config_page' ), plugins_url( 'images/yoast-icon.png', WPSEO_FILE ) );
}
}


Expand Down Expand Up @@ -418,7 +422,7 @@ function save_bulk_edit_options( $status, $option, $value ) {
* Display an error message when the blog is set to private.
*/
function blog_public_warning() {
if ( function_exists( 'is_network_admin' ) && is_network_admin() ) {
if ( ( function_exists( 'is_network_admin' ) && is_network_admin() ) || WPSEO_Options::grant_access() !== true ) {
return;
}

Expand All @@ -436,7 +440,7 @@ function blog_public_warning() {
* @since 1.4.14
*/
function meta_description_warning() {
if ( function_exists( 'is_network_admin' ) && is_network_admin() ) {
if ( ( function_exists( 'is_network_admin' ) && is_network_admin() ) || WPSEO_Options::grant_access() !== true ) {
return;
}

Expand Down Expand Up @@ -464,20 +468,32 @@ function meta_description_warning() {
* @return array $links
*/
function add_action_link( $links, $file ) {
static $this_plugin;
if ( empty( $this_plugin ) ) $this_plugin = 'wordpress-seo/wp-seo.php';
if ( $file == $this_plugin ) {
if ( WPSEO_BASENAME === $file && WPSEO_Options::grant_access() ) {
$settings_link = '<a href="' . esc_url( admin_url( 'admin.php?page=wpseo_dashboard' ) ) . '">' . __( 'Settings', 'wordpress-seo' ) . '</a>';
array_unshift( $links, $settings_link );
}

if ( class_exists( 'Yoast_Product_WPSEO_Premium' ) ) {
$license_manager = new Yoast_Plugin_License_Manager( new Yoast_Product_WPSEO_Premium() );
if ( $license_manager->license_is_valid() ) {
return $links;
}
}

// add link to premium support landing page
$premium_link = '<a href="https://yoast.com/wordpress/plugins/seo-premium/support/#utm_source=wordpress-seo-settings-link&utm_medium=text-link&utm_campaign=support-link">' . __( 'Premium Support', 'wordpress-seo' ) .'</a>';
array_unshift( $links, $premium_link );

return $links;
}

/**
* Enqueues the (tiny) global JS needed for the plugin.
*/
function config_page_scripts() {
wp_enqueue_script( 'wpseo-admin-global-script', plugins_url( 'js/wp-seo-admin-global' . WPSEO_CSSJS_SUFFIX . '.js', WPSEO_FILE ), array( 'jquery' ), WPSEO_VERSION, true );
if( WPSEO_Options::grant_access() ) {
wp_enqueue_script( 'wpseo-admin-global-script', plugins_url( 'js/wp-seo-admin-global' . WPSEO_CSSJS_SUFFIX . '.js', WPSEO_FILE ), array( 'jquery' ), WPSEO_VERSION, true );
}
}


Expand Down
28 changes: 18 additions & 10 deletions admin/class-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,46 +85,46 @@ function admin_sidebar() {
'alt' => 'Website Review banner',
),
array(
'url' => 'https://yoast.com/wordpress/seo-premium/#utm_source=wordpress-seo-config&utm_medium=banner&utm_campaign=premium-seo-banner',
'url' => 'https://yoast.com/wordpress/plugins/seo-premium/#utm_source=wordpress-seo-config&utm_medium=banner&utm_campaign=premium-seo-banner',
'img' => 'banner-premium-seo.png',
'alt' => 'Banner WordPress SEO Premium',
),
);

if ( ! class_exists( 'wpseo_Video_Sitemap' ) ) {
$banners[] = array(
'url' => 'https://yoast.com/wordpress/video-seo/#utm_source=wordpress-seo-config&utm_medium=banner&utm_campaign=video-seo-banner',
'url' => 'https://yoast.com/wordpress/plugins/video-seo/#utm_source=wordpress-seo-config&utm_medium=banner&utm_campaign=video-seo-banner',
'img' => 'banner-video-seo.png',
'alt' => 'Banner WordPress SEO Video SEO extension',
);
}

if ( ! class_exists( 'wpseo_Video_Manual' ) ) {
$banners[] = array(
'url' => 'https://yoast.com/wordpress/video-manual-wordpress-seo/#utm_source=wordpress-seo-config&utm_medium=banner&utm_campaign=video-manual-banner',
'url' => 'https://yoast.com/wordpress/plugins/video-manual-wordpress-seo/#utm_source=wordpress-seo-config&utm_medium=banner&utm_campaign=video-manual-banner',
'img' => 'banner-video-seo-manual.png',
'alt' => 'Banner WordPress SEO Video manual',
);
}

if ( class_exists( 'Woocommerce' ) ) {
$banners[] = array(
'url' => 'https://yoast.com/wordpress/yoast-woocommerce-seo/#utm_source=wordpress-seo-config&utm_medium=banner&utm_campaign=woocommerce-seo-banner',
'url' => 'https://yoast.com/wordpress/plugins/yoast-woocommerce-seo/#utm_source=wordpress-seo-config&utm_medium=banner&utm_campaign=woocommerce-seo-banner',
'img' => 'banner-woocommerce-seo.png',
'alt' => 'Banner WooCommerce SEO plugin',
);
}

if ( ! defined( 'WPSEO_LOCAL_VERSION' ) ) {
$banners[] = array(
'url' => 'https://yoast.com/wordpress/local-seo/#utm_source=wordpress-seo-config&utm_medium=banner&utm_campaign=local-seo-banner',
'url' => 'https://yoast.com/wordpress/plugins/local-seo/#utm_source=wordpress-seo-config&utm_medium=banner&utm_campaign=local-seo-banner',
'img' => 'banner-local-seo.png',
'alt' => 'Banner Local SEO plugin',
);
}
shuffle( $banners );
?>
<div class="postbox-container" id="sidebar-container">
<div class="wpseo_content_cell" id="sidebar-container">
<div id="sidebar">
<?php
$i = 0;
Expand All @@ -135,7 +135,10 @@ function admin_sidebar() {
$i++;
}
?>
<br/><br/><br/>
<?php
echo __( 'Remove these ads?', 'wordpress-seo' ) . '<br/>';
echo '<a target="_blank" href="https://yoast.com/wordpress/plugins/seo-premium/#utm_source=wordpress-seo-config&utm_medium=textlink&utm_campaign=remove-ads-link">' . __('Upgrade to WordPress SEO Premium &raquo;', 'wordpress-seo') . '</a><br/><br/>';
?>
</div>
</div>
<?php
Expand All @@ -161,7 +164,8 @@ function admin_header( $form = true, $option = 'yoast_wpseo_options', $optionsho
require_once( ABSPATH . 'wp-admin/options-head.php' );
?>
<h2 id="wpseo-title"><?php echo esc_html( get_admin_page_title() ); ?></h2>
<div id="wpseo_content_top" class="postbox-container">
<div class="wpseo_content_wrapper">
<div class="wpseo_content_cell" id="wpseo_content_top">
<div class="metabox-holder">
<div class="meta-box-sortables">
<?php
Expand Down Expand Up @@ -196,6 +200,8 @@ function admin_footer( $submit = true, $show_sidebar = true ) {
$this->admin_sidebar();
}

echo '</div><!-- end of div wpseo_content_wrapper -->';


/* Add the current settings array to the page for debugging purposes,
but not for a limited set of pages were it wouldn't make sense */
Expand Down Expand Up @@ -231,12 +237,14 @@ function admin_footer( $submit = true, $show_sidebar = true ) {
/**
* Deletes all post meta values with a given meta key from the database
*
* @todo [JRF => whomever] This method does not seem to be used anywhere. Double-check before removal.
*
* @param string $meta_key Key to delete all meta values for.
*/
function delete_meta( $meta_key ) {
/*function delete_meta( $meta_key ) {
global $wpdb;
$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key = %s", $meta_key ) );
}
}*/

/**
* Exports the current site's WP SEO settings.
Expand Down
Loading

0 comments on commit 36931e4

Please sign in to comment.