Commit 7ef5d569 authored by Simon's avatar Simon

UTM links added, app ID updated, plugins updated

parent 75049996
...@@ -179,11 +179,11 @@ services: ...@@ -179,11 +179,11 @@ services:
wp plugin install pods --version=2.7.14 --activate-network; wp plugin install pods --version=2.7.14 --activate-network;
# wp plugin update pods --version=2.7.14; # wp plugin update pods --version=2.7.14;
wp plugin install polylang --version=2.6.2 --activate-network; wp plugin install polylang --version=2.6.3 --activate-network;
# wp plugin update polylang --version=2.6.2; # wp plugin update polylang --version=2.6.3;
wp plugin install wordpress-seo --version=11.7 --activate-network; wp plugin install wordpress-seo --version=11.8 --activate-network;
# wp plugin update wordpress-seo --version=11.7; # wp plugin update wordpress-seo --version=11.8;
wp plugin update akismet --version=4.1.2; wp plugin update akismet --version=4.1.2;
wp plugin uninstall hello; wp plugin uninstall hello;
......
...@@ -97,6 +97,10 @@ class PLL_Frontend extends PLL_Base { ...@@ -97,6 +97,10 @@ class PLL_Frontend extends PLL_Base {
new PLL_Share_Term_Slug( $this ); new PLL_Share_Term_Slug( $this );
} }
} }
if ( class_exists( 'PLL_Sync_Post' ) ) {
$this->sync_post = new PLL_Sync_Post( $this );
}
} }
/** /**
......
...@@ -37,10 +37,13 @@ function pll_the_languages( $args = '' ) { ...@@ -37,10 +37,13 @@ function pll_the_languages( $args = '' ) {
* *
* @since 0.8.1 * @since 0.8.1
* *
* @param string $field Optional, the language field to return ( see PLL_Language ), defaults to 'slug' * @param string $field Optional, the language field to return ( see PLL_Language ), defaults to 'slug', pass OBJECT constant to get the language object.
* @return string|bool The requested field for the current language * @return string|PLL_Language|bool The requested field for the current language
*/ */
function pll_current_language( $field = 'slug' ) { function pll_current_language( $field = 'slug' ) {
if ( OBJECT === $field ) {
return PLL()->curlang;
}
return isset( PLL()->curlang->$field ) ? PLL()->curlang->$field : false; return isset( PLL()->curlang->$field ) ? PLL()->curlang->$field : false;
} }
...@@ -49,11 +52,20 @@ function pll_current_language( $field = 'slug' ) { ...@@ -49,11 +52,20 @@ function pll_current_language( $field = 'slug' ) {
* *
* @since 1.0 * @since 1.0
* *
* @param string $field Optional, the language field to return ( see PLL_Language ), defaults to 'slug' * @param string $field Optional, the language field to return ( see PLL_Language ), defaults to 'slug', pass OBJECT constant to get the language object.
* @return string The requested field for the default language * @return string|PLL_Language|bool The requested field for the default language
*/ */
function pll_default_language( $field = 'slug' ) { function pll_default_language( $field = 'slug' ) {
return isset( PLL()->options['default_lang'] ) && ( $lang = PLL()->model->get_language( PLL()->options['default_lang'] ) ) && isset( $lang->$field ) ? $lang->$field : false; if ( isset( PLL()->options['default_lang'] ) ) {
$lang = PLL()->model->get_language( PLL()->options['default_lang'] );
if ( $lang ) {
if ( OBJECT === $field ) {
return $lang;
}
return isset( $lang->$field ) ? $lang->$field : false;
}
}
return false;
} }
/** /**
......
...@@ -26,7 +26,7 @@ class PLL_Walker_List extends Walker { ...@@ -26,7 +26,7 @@ class PLL_Walker_List extends Walker {
esc_attr( $element->locale ), esc_attr( $element->locale ),
esc_url( $element->url ), esc_url( $element->url ),
$element->flag, $element->flag,
$args['show_flags'] ? sprintf( '<span style="margin-%1$s:0.3em;">%2$s</span>', is_rtl() ? 'right' : 'left', esc_html( $element->name ) ) : esc_html( $element->name ), $args['show_flags'] && $args['show_names'] ? sprintf( '<span style="margin-%1$s:0.3em;">%2$s</span>', is_rtl() ? 'right' : 'left', esc_html( $element->name ) ) : esc_html( $element->name ),
'discard' === $args['item_spacing'] ? '' : "\t", 'discard' === $args['item_spacing'] ? '' : "\t",
'discard' === $args['item_spacing'] ? '' : "\n" 'discard' === $args['item_spacing'] ? '' : "\n"
); );
......
...@@ -87,13 +87,15 @@ class PLL_WPML_Compat { ...@@ -87,13 +87,15 @@ class PLL_WPML_Compat {
if ( $exist_string && $exist_string !== $string ) { if ( $exist_string && $exist_string !== $string ) {
$languages = PLL()->model->get_languages_list(); $languages = PLL()->model->get_languages_list();
// Assign translations of the old string to the new string. // Assign translations of the old string to the new string, except for the default language.
foreach ( $languages as $language ) { foreach ( $languages as $language ) {
if ( pll_default_language() !== $language->slug ) {
$mo = new PLL_MO(); $mo = new PLL_MO();
$mo->import_from_db( $language ); $mo->import_from_db( $language );
$mo->add_entry( $mo->make_entry( $string, $mo->translate( $exist_string ) ) ); $mo->add_entry( $mo->make_entry( $string, $mo->translate( $exist_string ) ) );
$mo->export_to_db( $language ); $mo->export_to_db( $language );
} }
}
$this->unregister_string( $context, $name ); $this->unregister_string( $context, $name );
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
/** /**
Plugin Name: Polylang Plugin Name: Polylang
Plugin URI: https://polylang.pro Plugin URI: https://polylang.pro
Version: 2.6.2 Version: 2.6.3
Author: WP SYNTEX Author: WP SYNTEX
Author uri: https://polylang.pro Author uri: https://polylang.pro
Description: Adds multilingual capability to WordPress Description: Adds multilingual capability to WordPress
...@@ -51,7 +51,7 @@ if ( defined( 'POLYLANG_BASENAME' ) ) { ...@@ -51,7 +51,7 @@ if ( defined( 'POLYLANG_BASENAME' ) ) {
} }
} else { } else {
// Go on loading the plugin // Go on loading the plugin
define( 'POLYLANG_VERSION', '2.6.2' ); define( 'POLYLANG_VERSION', '2.6.3' );
define( 'PLL_MIN_WP_VERSION', '4.7' ); define( 'PLL_MIN_WP_VERSION', '4.7' );
define( 'POLYLANG_FILE', __FILE__ ); // this file define( 'POLYLANG_FILE', __FILE__ ); // this file
......
...@@ -4,7 +4,7 @@ Donate link: https://polylang.pro ...@@ -4,7 +4,7 @@ Donate link: https://polylang.pro
Tags: multilingual, bilingual, translate, translation, language, multilanguage, international, localization Tags: multilingual, bilingual, translate, translation, language, multilanguage, international, localization
Requires at least: 4.7 Requires at least: 4.7
Tested up to: 5.2 Tested up to: 5.2
Stable tag: 2.6.2 Stable tag: 2.6.3
License: GPLv3 or later License: GPLv3 or later
Making WordPress multilingual Making WordPress multilingual
...@@ -76,6 +76,14 @@ Don't hesitate to [give your feedback](http://wordpress.org/support/view/plugin- ...@@ -76,6 +76,14 @@ Don't hesitate to [give your feedback](http://wordpress.org/support/view/plugin-
== Changelog == == Changelog ==
= 2.6.3 (2019-08-06) =
* Pro: Fix fatal error when updating an ACF field from frontend
* Pro: Add action 'pll_post_synchronized'
* Allow to get the current or default language object using the API. Props Jory Hogeveen. #359
* Fix empty span in languages switcher widget when showing only flags
* Fix wpml_register_single_string when updating the original string
= 2.6.2 (2019-07-16) = = 2.6.2 (2019-07-16) =
* Pro: Fix slow admin in case the translations update server can't be reached * Pro: Fix slow admin in case the translations update server can't be reached
......
...@@ -18,11 +18,15 @@ class WPSEO_Admin_Gutenberg_Compatibility_Notification implements WPSEO_WordPres ...@@ -18,11 +18,15 @@ class WPSEO_Admin_Gutenberg_Compatibility_Notification implements WPSEO_WordPres
private $notification_id = 'wpseo-outdated-gutenberg-plugin'; private $notification_id = 'wpseo-outdated-gutenberg-plugin';
/** /**
* Instance of gutenberg compatibility checker.
*
* @var WPSEO_Gutenberg_Compatibility * @var WPSEO_Gutenberg_Compatibility
*/ */
private $compatibility_checker; private $compatibility_checker;
/** /**
* Instance of Yoast Notification Center.
*
* @var Yoast_Notification_Center * @var Yoast_Notification_Center
*/ */
private $notification_center; private $notification_center;
......
...@@ -469,7 +469,7 @@ class WPSEO_Admin_Init { ...@@ -469,7 +469,7 @@ class WPSEO_Admin_Init {
$message .= sprintf( $message .= sprintf(
/* translators: %1$s expands to Yoast SEO, %2$s expands to 5.0 */ /* translators: %1$s expands to Yoast SEO, %2$s expands to 5.0 */
__( __(
'If you’ve held off on updating to %2$s and higher because of the new Gutenberg editor, please install the Classic editor plugin. It will give you the same editing experience you have now, but also the security of newer versions of WordPress and %1$s.', 'If you’ve held off on updating to %2$s and higher because of the new Gutenberg editor, please install the Classic Editor plugin. It will give you the same editing experience you have now, but also the security of newer versions of WordPress and %1$s.',
'wordpress-seo' 'wordpress-seo'
), ),
'Yoast SEO', 'Yoast SEO',
......
...@@ -25,21 +25,29 @@ class WPSEO_Admin_Asset { ...@@ -25,21 +25,29 @@ class WPSEO_Admin_Asset {
const TYPE_CSS = 'css'; const TYPE_CSS = 'css';
/** /**
* The name option identifier.
*
* @var string * @var string
*/ */
const NAME = 'name'; const NAME = 'name';
/** /**
* The source option identifier.
*
* @var string * @var string
*/ */
const SRC = 'src'; const SRC = 'src';
/** /**
* The dependencies option identifier.
*
* @var string * @var string
*/ */
const DEPS = 'deps'; const DEPS = 'deps';
/** /**
* The version option identifier.
*
* @var string * @var string
*/ */
const VERSION = 'version'; const VERSION = 'version';
...@@ -47,11 +55,15 @@ class WPSEO_Admin_Asset { ...@@ -47,11 +55,15 @@ class WPSEO_Admin_Asset {
/* Style specific. */ /* Style specific. */
/** /**
* The media option identifier.
*
* @var string * @var string
*/ */
const MEDIA = 'media'; const MEDIA = 'media';
/** /**
* The rtl option identifier.
*
* @var string * @var string
*/ */
const RTL = 'rtl'; const RTL = 'rtl';
...@@ -59,6 +71,8 @@ class WPSEO_Admin_Asset { ...@@ -59,6 +71,8 @@ class WPSEO_Admin_Asset {
/* Script specific. */ /* Script specific. */
/** /**
* The "in footer" option identifier.
*
* @var string * @var string
*/ */
const IN_FOOTER = 'in_footer'; const IN_FOOTER = 'in_footer';
...@@ -136,6 +150,8 @@ class WPSEO_Admin_Asset { ...@@ -136,6 +150,8 @@ class WPSEO_Admin_Asset {
); );
/** /**
* Constructs an instance of the WPSEO_Admin_Asset class.
*
* @param array $args The arguments for this asset. * @param array $args The arguments for this asset.
* *
* @throws InvalidArgumentException Throws when no name or src has been provided. * @throws InvalidArgumentException Throws when no name or src has been provided.
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
class WPSEO_Customizer { class WPSEO_Customizer {
/** /**
* Holds the customize manager.
*
* @var WP_Customize_Manager * @var WP_Customize_Manager
*/ */
protected $wp_customize; protected $wp_customize;
...@@ -66,7 +68,7 @@ class WPSEO_Customizer { ...@@ -66,7 +68,7 @@ class WPSEO_Customizer {
$this->wp_customize = $wp_customize; $this->wp_customize = $wp_customize;
$this->breadcrumbs_section(); $this->breadcrumbs_section();
$this->breadcrumbs_blog_remove_setting(); $this->breadcrumbs_blog_show_setting();
$this->breadcrumbs_separator_setting(); $this->breadcrumbs_separator_setting();
$this->breadcrumbs_home_setting(); $this->breadcrumbs_home_setting();
$this->breadcrumbs_prefix_setting(); $this->breadcrumbs_prefix_setting();
...@@ -99,25 +101,25 @@ class WPSEO_Customizer { ...@@ -99,25 +101,25 @@ class WPSEO_Customizer {
} }
/** /**
* Adds the breadcrumbs remove blog checkbox. * Adds the breadcrumbs show blog checkbox.
*/ */
private function breadcrumbs_blog_remove_setting() { private function breadcrumbs_blog_show_setting() {
$index = 'breadcrumbs-display-blog-page'; $index = 'breadcrumbs-display-blog-page';
$control_args = array( $control_args = array(
'label' => __( 'Remove blog page from breadcrumbs', 'wordpress-seo' ), 'label' => __( 'Show blog page in breadcrumbs', 'wordpress-seo' ),
'type' => 'checkbox', 'type' => 'checkbox',
'active_callback' => array( $this, 'breadcrumbs_blog_remove_active_cb' ), 'active_callback' => array( $this, 'breadcrumbs_blog_show_active_cb' ),
); );
$this->add_setting_and_control( $index, $control_args ); $this->add_setting_and_control( $index, $control_args );
} }
/** /**
* Returns whether or not to show the breadcrumbs blog remove option. * Returns whether or not to show the breadcrumbs blog show option.
* *
* @return bool * @return bool
*/ */
public function breadcrumbs_blog_remove_active_cb() { public function breadcrumbs_blog_show_active_cb() {
return 'page' === get_option( 'show_on_front' ); return 'page' === get_option( 'show_on_front' );
} }
......
...@@ -15,14 +15,14 @@ class WPSEO_Gutenberg_Compatibility { ...@@ -15,14 +15,14 @@ class WPSEO_Gutenberg_Compatibility {
* *
* @var string * @var string
*/ */
const CURRENT_RELEASE = '6.1.1'; const CURRENT_RELEASE = '6.2.0';
/** /**
* The minimally supported version of Gutenberg by the plugin. * The minimally supported version of Gutenberg by the plugin.
* *
* @var string * @var string
*/ */
const MINIMUM_SUPPORTED = '6.1.1'; const MINIMUM_SUPPORTED = '6.2.0';
/** /**
* Holds the current version. * Holds the current version.
......
...@@ -11,11 +11,15 @@ ...@@ -11,11 +11,15 @@
class WPSEO_Meta_Table_Accessible { class WPSEO_Meta_Table_Accessible {
/** /**
* Indicates that the table is accessible.
*
* @var string * @var string
*/ */
const ACCESSIBLE = '0'; const ACCESSIBLE = '0';
/** /**
* Indicates that the table is inaccessible.
*
* @var string * @var string
*/ */
const INACCESSBILE = '1'; const INACCESSBILE = '1';
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
class WPSEO_MyYoast_Route implements WPSEO_WordPress_Integration { class WPSEO_MyYoast_Route implements WPSEO_WordPress_Integration {
/** /**
* The identifier of the page in the My Yoast route.
*
* @var string * @var string
*/ */
const PAGE_IDENTIFIER = 'wpseo_myyoast'; const PAGE_IDENTIFIER = 'wpseo_myyoast';
......
...@@ -35,16 +35,18 @@ class WPSEO_Paper_Presenter { ...@@ -35,16 +35,18 @@ class WPSEO_Paper_Presenter {
* WPSEO_presenter_paper constructor. * WPSEO_presenter_paper constructor.
* *
* @param string $title The title of the paper. * @param string $title The title of the paper.
* @param string $view_file The path to the view file. * @param string $view_file Optional. The path to the view file. Use the content setting if you do not wish to use a view file.
* @param array $settings Optional. Settings for the paper. * @param array $settings Optional. Settings for the paper.
*/ */
public function __construct( $title, $view_file, array $settings = array() ) { public function __construct( $title, $view_file = null, array $settings = array() ) {
$defaults = array( $defaults = array(
'paper_id' => null, 'paper_id' => null,
'collapsible' => false, 'collapsible' => false,
'expanded' => false, 'expanded' => false,
'help_text' => '', 'help_text' => '',
'title_after' => '', 'title_after' => '',
'class' => '',
'content' => '',
'view_data' => array(), 'view_data' => array(),
); );
...@@ -59,7 +61,17 @@ class WPSEO_Paper_Presenter { ...@@ -59,7 +61,17 @@ class WPSEO_Paper_Presenter {
* @return string The rendered paper. * @return string The rendered paper.
*/ */
public function get_output() { public function get_output() {
extract( $this->get_view_variables(), EXTR_SKIP ); $view_variables = $this->get_view_variables();
extract( $view_variables, EXTR_SKIP );
$content = $this->settings['content'];
if ( $this->view_file !== null ) {
ob_start();
require $this->view_file;
$content = ob_get_clean();
}
ob_start(); ob_start();
require WPSEO_PATH . 'admin/views/paper-collapsible.php'; require WPSEO_PATH . 'admin/views/paper-collapsible.php';
...@@ -79,6 +91,7 @@ class WPSEO_Paper_Presenter { ...@@ -79,6 +91,7 @@ class WPSEO_Paper_Presenter {
} }
$view_variables = array( $view_variables = array(
'class' => $this->settings['class'],
'collapsible' => $this->settings['collapsible'], 'collapsible' => $this->settings['collapsible'],
'collapsible_config' => $this->collapsible_config(), 'collapsible_config' => $this->collapsible_config(),
'title_after' => $this->settings['title_after'], 'title_after' => $this->settings['title_after'],
......
...@@ -72,12 +72,11 @@ class WPSEO_Social_Admin extends WPSEO_Metabox { ...@@ -72,12 +72,11 @@ class WPSEO_Social_Admin extends WPSEO_Metabox {
/** /**
* Returns the metabox section for the social settings. * Returns the metabox section for the social settings.
* *
* @return WPSEO_Metabox_Tab_Section * @return WPSEO_Metabox_Collapsibles_Sections
*/ */
public function get_meta_section() { public function get_meta_section() {
$tabs = array(); $tabs = array();
$social_meta_fields = WPSEO_Meta::get_meta_field_defs( 'social' ); $social_meta_fields = WPSEO_Meta::get_meta_field_defs( 'social' );
$single = true;
$opengraph = WPSEO_Options::get( 'opengraph' ); $opengraph = WPSEO_Options::get( 'opengraph' );
$twitter = WPSEO_Options::get( 'twitter' ); $twitter = WPSEO_Options::get( 'twitter' );
...@@ -89,32 +88,22 @@ class WPSEO_Social_Admin extends WPSEO_Metabox { ...@@ -89,32 +88,22 @@ class WPSEO_Social_Admin extends WPSEO_Metabox {
wp_nonce_field( 'yoast_free_metabox_social', 'yoast_free_metabox_social_nonce' ); wp_nonce_field( 'yoast_free_metabox_social', 'yoast_free_metabox_social_nonce' );
if ( $opengraph === true ) { if ( $opengraph === true ) {
$tabs[] = new WPSEO_Metabox_Form_Tab( $tabs[] = new WPSEO_Metabox_Collapsible(
'facebook', 'facebook',
$this->get_social_tab_content( 'opengraph', $social_meta_fields ), $this->get_social_tab_content( 'opengraph', $social_meta_fields ),
'<span class="screen-reader-text">' . __( 'Facebook / Open Graph metadata', 'wordpress-seo' ) . '</span><span class="dashicons dashicons-facebook-alt"></span>', __( 'Facebook', 'wordpress-seo' )
array(
'link_aria_label' => __( 'Facebook / Open Graph metadata', 'wordpress-seo' ),
'link_class' => 'yoast-tooltip yoast-tooltip-se',
'single' => $single,
)
); );
} }
if ( $twitter === true ) { if ( $twitter === true ) {
$tabs[] = new WPSEO_Metabox_Form_Tab( $tabs[] = new WPSEO_Metabox_Collapsible(
'twitter', 'twitter',
$this->get_social_tab_content( 'twitter', $social_meta_fields ), $this->get_social_tab_content( 'twitter', $social_meta_fields ),
'<span class="screen-reader-text">' . __( 'Twitter metadata', 'wordpress-seo' ) . '</span><span class="dashicons dashicons-twitter"></span>', __( 'Twitter', 'wordpress-seo' )
array(
'link_aria_label' => __( 'Twitter metadata', 'wordpress-seo' ),
'link_class' => 'yoast-tooltip yoast-tooltip-se',
'single' => $single,
)
); );
} }
return new WPSEO_Metabox_Tab_Section( return new WPSEO_Metabox_Collapsibles_Sections(
'social', 'social',
'<span class="dashicons dashicons-share"></span>' . __( 'Social', 'wordpress-seo' ), '<span class="dashicons dashicons-share"></span>' . __( 'Social', 'wordpress-seo' ),
$tabs $tabs
...@@ -143,9 +132,29 @@ class WPSEO_Social_Admin extends WPSEO_Metabox { ...@@ -143,9 +132,29 @@ class WPSEO_Social_Admin extends WPSEO_Metabox {
$tab_content .= $this->do_meta_box( $meta_field_defs[ $field_name ], $field_name ); $tab_content .= $this->do_meta_box( $meta_field_defs[ $field_name ], $field_name );
} }
$features = new WPSEO_Features();
/**
* If premium hide the form to show the social preview instead, we still need the fields to be output because
* the values of the social preview are saved in the hidden field.
*/
if ( $features->is_premium() ) {
return $this->hide_form( $tab_content );
}
return $tab_content; return $tab_content;
} }
/**
* Hides the given output when rendered to HTML.
*
* @param string $tab_content The social tab content.
*
* @return string The content.
*/
public function hide_form( $tab_content ) {
return '<div class="hidden">' . $tab_content . '</div>';
}
/** /**
* Returns the Upgrade to Premium notice. * Returns the Upgrade to Premium notice.
* *
......
...@@ -18,6 +18,8 @@ class Yoast_Dashboard_Widget implements WPSEO_WordPress_Integration { ...@@ -18,6 +18,8 @@ class Yoast_Dashboard_Widget implements WPSEO_WordPress_Integration {
const CACHE_TRANSIENT_KEY = 'wpseo-dashboard-totals'; const CACHE_TRANSIENT_KEY = 'wpseo-dashboard-totals';
/** /**
* Holds an instance of the admin asset manager.
*
* @var WPSEO_Admin_Asset_Manager * @var WPSEO_Admin_Asset_Manager
*/ */
protected $asset_manager; protected $asset_manager;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
*/ */
/** /**
* @class WPSEO_Configuration_Wizard Loads the Yoast configuration wizard. * Loads the Yoast configuration wizard.
*/ */
class WPSEO_Configuration_Page { class WPSEO_Configuration_Page {
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
class WPSEO_Config_Component_Mailchimp_Signup implements WPSEO_Config_Component { class WPSEO_Config_Component_Mailchimp_Signup implements WPSEO_Config_Component {
/** /**
* The name of the mailchimp signup meta key.
*
* @var string * @var string
*/ */
const META_NAME = 'wpseo-has-mailchimp-signup'; const META_NAME = 'wpseo-has-mailchimp-signup';
......
...@@ -34,6 +34,8 @@ interface WPSEO_Config_Component { ...@@ -34,6 +34,8 @@ interface WPSEO_Config_Component {
public function set_data( $data ); public function set_data( $data );
/** /**
* Get onboarding wizard component field.
*
* @return WPSEO_Config_Field * @return WPSEO_Config_Field
*/ */
public function get_field(); public function get_field();
......
...@@ -11,16 +11,22 @@ ...@@ -11,16 +11,22 @@
class WPSEO_Endpoint_File_Size implements WPSEO_Endpoint { class WPSEO_Endpoint_File_Size implements WPSEO_Endpoint {
/** /**
* The namespace of the REST route.
*
* @var string * @var string
*/ */
const REST_NAMESPACE = 'yoast/v1'; const REST_NAMESPACE = 'yoast/v1';
/** /**
* The route of the endpoint to retrieve the file size.
*
* @var string * @var string
*/ */
const ENDPOINT_SINGULAR = 'file_size'; const ENDPOINT_SINGULAR = 'file_size';
/** /**
* The name of the capability needed to retrieve data using the endpoints.
*
* @var string * @var string
*/ */
const CAPABILITY_RETRIEVE = 'manage_options'; const CAPABILITY_RETRIEVE = 'manage_options';
......
...@@ -11,21 +11,29 @@ ...@@ -11,21 +11,29 @@
class WPSEO_Endpoint_Indexable implements WPSEO_Endpoint, WPSEO_Endpoint_Storable { class WPSEO_Endpoint_Indexable implements WPSEO_Endpoint, WPSEO_Endpoint_Storable {
/** /**
* The namespace of the REST route.
*
* @var string * @var string
*/ */
const REST_NAMESPACE = 'yoast/v1'; const REST_NAMESPACE = 'yoast/v1';
/** /**
* The route of the endpoint to retrieve or patch the indexable.
*
* @var string * @var string
*/ */
const ENDPOINT_SINGULAR = 'indexables/(?P<object_type>\w+)/(?P<object_id>\d+)'; const ENDPOINT_SINGULAR = 'indexables/(?P<object_type>\w+)/(?P<object_id>\d+)';
/** /**
* The name of the capability needed to retrieve data using the endpoints.
*
* @var string * @var string
*/ */
const CAPABILITY_RETRIEVE = 'manage_options'; const CAPABILITY_RETRIEVE = 'manage_options';
/** /**
* The name of the capability needed to store data using the endpoints.
*
* @var string * @var string
*/ */
const CAPABILITY_STORE = 'manage_options'; const CAPABILITY_STORE = 'manage_options';
......
...@@ -11,16 +11,22 @@ ...@@ -11,16 +11,22 @@
class WPSEO_Endpoint_Ryte implements WPSEO_Endpoint { class WPSEO_Endpoint_Ryte implements WPSEO_Endpoint {
/** /**
* The namespace of the REST route.
*
* @var string * @var string
*/ */
const REST_NAMESPACE = 'yoast/v1'; const REST_NAMESPACE = 'yoast/v1';
/** /**
* The route of the ryte endpoint.
*
* @var string * @var string
*/ */
const ENDPOINT_RETRIEVE = 'ryte'; const ENDPOINT_RETRIEVE = 'ryte';
/** /**
* The name of the capability needed to retrieve data using the endpoints.
*
* @var string * @var string
*/ */
const CAPABILITY_RETRIEVE = 'manage_options'; const CAPABILITY_RETRIEVE = 'manage_options';
......
...@@ -11,16 +11,22 @@ ...@@ -11,16 +11,22 @@
class WPSEO_Endpoint_Statistics implements WPSEO_Endpoint { class WPSEO_Endpoint_Statistics implements WPSEO_Endpoint {
/** /**
* The namespace of the REST route.
*
* @var string * @var string
*/ */
const REST_NAMESPACE = 'yoast/v1'; const REST_NAMESPACE = 'yoast/v1';
/** /**
* The route of the statistics endpoint.
*
* @var string * @var string
*/ */
const ENDPOINT_RETRIEVE = 'statistics'; const ENDPOINT_RETRIEVE = 'statistics';
/** /**
* The name of the capability needed to retrieve data using the endpoints.
*
* @var string * @var string
*/ */
const CAPABILITY_RETRIEVE = 'read'; const CAPABILITY_RETRIEVE = 'read';
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
abstract class WPSEO_Abstract_Post_Filter implements WPSEO_WordPress_Integration { abstract class WPSEO_Abstract_Post_Filter implements WPSEO_WordPress_Integration {
/** /**
* The filter's query argument.
*
* @var string * @var string
*/ */
const FILTER_QUERY_ARG = 'yoast_filter'; const FILTER_QUERY_ARG = 'yoast_filter';
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
class WPSEO_Post_Metabox_Formatter implements WPSEO_Metabox_Formatter_Interface { class WPSEO_Post_Metabox_Formatter implements WPSEO_Metabox_Formatter_Interface {
/** /**
* Holds the WordPress Post.
*
* @var WP_Post * @var WP_Post
*/ */
private $post; private $post;
......
...@@ -11,11 +11,15 @@ ...@@ -11,11 +11,15 @@
class WPSEO_Term_Metabox_Formatter implements WPSEO_Metabox_Formatter_Interface { class WPSEO_Term_Metabox_Formatter implements WPSEO_Metabox_Formatter_Interface {
/** /**
* The term the metabox formatter is for.
*
* @var WP_Term|stdClass * @var WP_Term|stdClass
*/ */
private $term; private $term;
/** /**
* The term's taxonomy.
*
* @var stdClass * @var stdClass
*/ */
private $taxonomy; private $taxonomy;
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
class WPSEO_GSC_Config { class WPSEO_GSC_Config {
/** /**
* The Google search console configuration.
*
* @var array * @var array
*/ */
public static $gsc = array( public static $gsc = array(
......
...@@ -25,6 +25,8 @@ class WPSEO_GSC_Count { ...@@ -25,6 +25,8 @@ class WPSEO_GSC_Count {
const OPTION_CI_COUNTS = 'wpseo_gsc_issues_counts'; const OPTION_CI_COUNTS = 'wpseo_gsc_issues_counts';
/** /**
* Service that fetches data from GSC API.
*
* @var WPSEO_GSC_Service * @var WPSEO_GSC_Service
*/ */
private $service; private $service;
......
...@@ -11,21 +11,29 @@ ...@@ -11,21 +11,29 @@
class WPSEO_GSC_Issue { class WPSEO_GSC_Issue {
/** /**
* The URL of the Google Search Console issue.
*
* @var string * @var string
*/ */
private $url; private $url;
/** /**
* The time of the first discovery of the Google Search Console issue.
*
* @var DateTime * @var DateTime
*/ */
private $first_detected; private $first_detected;
/** /**
* The time of the last crawl of the URL.
*
* @var DateTime * @var DateTime
*/ */
private $last_crawled; private $last_crawled;
/** /**
* The HTTP response code of the URL.
*
* @var string * @var string
*/ */
private $response_code; private $response_code;
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
class WPSEO_GSC_Issues { class WPSEO_GSC_Issues {
/** /**
* Holds the option name.
*
* @var string * @var string
*/ */
private $option_name = ''; private $option_name = '';
......
...@@ -11,26 +11,36 @@ ...@@ -11,26 +11,36 @@
class WPSEO_GSC_Marker { class WPSEO_GSC_Marker {
/** /**
* Holds the craw issues instance.
*
* @var WPSEO_GSC_Issues * @var WPSEO_GSC_Issues
*/ */
private $crawl_issues; private $crawl_issues;
/** /**
* Holds the URL.
*
* @var string * @var string
*/ */
private $url = ''; private $url = '';
/** /**
* Holds the platform (desktop, mobile, feature phone).
*
* @var string * @var string
*/ */
private $platform; private $platform;
/** /**
* Holds the category.
*
* @var string * @var string
*/ */
private $category; private $category;
/** /**
* Holds the result.
*
* @var string * @var string
*/ */
private $result; private $result;
......
...@@ -11,16 +11,22 @@ ...@@ -11,16 +11,22 @@
class WPSEO_GSC_Modal { class WPSEO_GSC_Modal {
/** /**
* Path to the modal view.
*
* @var string * @var string
*/ */
protected $view; protected $view;
/** /**
* The modal height.
*
* @var int * @var int
*/ */
protected $height; protected $height;
/** /**
* Variables to be passed to the view.
*
* @var array * @var array
*/ */
protected $view_vars; protected $view_vars;
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
class WPSEO_GSC_Platform_Tabs { class WPSEO_GSC_Platform_Tabs {
/** /**
* The current active tab.
*
* @var string * @var string
*/ */
private $current_tab; private $current_tab;
......
...@@ -11,11 +11,15 @@ ...@@ -11,11 +11,15 @@
class WPSEO_GSC_Service { class WPSEO_GSC_Service {
/** /**
* Client to connect to the google API.
*
* @var Yoast_Api_Google_Client * @var Yoast_Api_Google_Client
*/ */
private $client; private $client;
/** /**
* The google search console profile.
*
* @var string * @var string
*/ */
private $profile; private $profile;
......
...@@ -15,11 +15,15 @@ if ( ! class_exists( 'WP_List_Table' ) ) { ...@@ -15,11 +15,15 @@ if ( ! class_exists( 'WP_List_Table' ) ) {
class WPSEO_GSC_Table extends WP_List_Table { class WPSEO_GSC_Table extends WP_List_Table {
/** /**
* Modal height.
*
* @var int * @var int
*/ */
const FREE_MODAL_HEIGHT = 140; const FREE_MODAL_HEIGHT = 140;
/** /**
* The search phrase.
*
* @var string * @var string
*/ */
private $search_string; private $search_string;
...@@ -39,6 +43,8 @@ class WPSEO_GSC_Table extends WP_List_Table { ...@@ -39,6 +43,8 @@ class WPSEO_GSC_Table extends WP_List_Table {
private $per_page = 50; private $per_page = 50;
/** /**
* Current page.
*
* @var integer * @var integer
*/ */
private $current_page = 1; private $current_page = 1;
......
...@@ -18,16 +18,22 @@ class WPSEO_GSC implements WPSEO_WordPress_Integration { ...@@ -18,16 +18,22 @@ class WPSEO_GSC implements WPSEO_WordPress_Integration {
const OPTION_WPSEO_GSC = 'wpseo-gsc'; const OPTION_WPSEO_GSC = 'wpseo-gsc';
/** /**
* Holds the service instance.
*
* @var WPSEO_GSC_Service * @var WPSEO_GSC_Service
*/ */
private $service; private $service;
/** /**
* Holds the category filter instance.
*
* @var WPSEO_GSC_Category_Filters * @var WPSEO_GSC_Category_Filters
*/ */
protected $category_filter; protected $category_filter;
/** /**
* Holds the issues instance.
*
* @var WPSEO_GSC_Issues * @var WPSEO_GSC_Issues
*/ */
protected $issue_fetch; protected $issue_fetch;
......
...@@ -13,11 +13,15 @@ ...@@ -13,11 +13,15 @@
class WPSEO_Import_Plugin { class WPSEO_Import_Plugin {
/** /**
* Holds the status of and message about imports.
*
* @var WPSEO_Import_Status * @var WPSEO_Import_Status
*/ */
public $status; public $status;
/** /**
* Class with functionality to import meta data from other plugins.
*
* @var WPSEO_Plugin_Importer * @var WPSEO_Plugin_Importer
*/ */
protected $importer; protected $importer;
......
...@@ -20,11 +20,15 @@ class WPSEO_Import_Settings { ...@@ -20,11 +20,15 @@ class WPSEO_Import_Settings {
const NONCE_ACTION = 'wpseo-import-settings'; const NONCE_ACTION = 'wpseo-import-settings';
/** /**
* Holds the import status instance.
*
* @var WPSEO_Import_Status * @var WPSEO_Import_Status
*/ */
public $status; public $status;
/** /**
* Holds the old WPSEO version.
*
* @var string * @var string
*/ */
private $old_wpseo_version; private $old_wpseo_version;
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
class WPSEO_Link_Column_Count { class WPSEO_Link_Column_Count {
/** /**
* The link counts for each post id on the current page.
*
* @var array * @var array
*/ */
protected $count = array(); protected $count = array();
......
...@@ -25,6 +25,8 @@ class WPSEO_Link_Columns { ...@@ -25,6 +25,8 @@ class WPSEO_Link_Columns {
const COLUMN_LINKS = 'links'; const COLUMN_LINKS = 'links';
/** /**
* Holds the link column count instance.
*
* @var WPSEO_Link_Column_Count * @var WPSEO_Link_Column_Count
*/ */
protected $link_count; protected $link_count;
...@@ -214,7 +216,7 @@ class WPSEO_Link_Columns { ...@@ -214,7 +216,7 @@ class WPSEO_Link_Columns {
public function set_count_objects() { public function set_count_objects() {
global $wp_query; global $wp_query;
$posts = $wp_query->get_posts(); $posts = empty( $wp_query->posts ) ? $wp_query->get_posts() : $wp_query->posts;
$post_ids = array(); $post_ids = array();
// Post lists return a list of objects. // Post lists return a list of objects.
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
class WPSEO_Link_Compatibility_Notifier { class WPSEO_Link_Compatibility_Notifier {
/** /**
* Notification id.
*
* @var string * @var string
*/ */
const NOTIFICATION_ID = 'wpseo-links-compatibility'; const NOTIFICATION_ID = 'wpseo-links-compatibility';
......
...@@ -12,11 +12,15 @@ ...@@ -12,11 +12,15 @@
class WPSEO_Link_Content_Processor { class WPSEO_Link_Content_Processor {
/** /**
* Holds the link storage instance.
*
* @var WPSEO_Link_Storage * @var WPSEO_Link_Storage
*/ */
protected $storage; protected $storage;
/** /**
* Holds the meta storage instance.
*
* @var WPSEO_Meta_Storage * @var WPSEO_Meta_Storage
*/ */
private $count_storage; private $count_storage;
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
class WPSEO_Link_Extractor { class WPSEO_Link_Extractor {
/** /**
* The content to extract the links from.
*
* @var string * @var string
*/ */
protected $content; protected $content;
......
...@@ -11,16 +11,22 @@ ...@@ -11,16 +11,22 @@
class WPSEO_Link_Factory { class WPSEO_Link_Factory {
/** /**
* Represents the classifier for a link. Determines of a link is an outbound or internal one.
*
* @var WPSEO_Link_Type_Classifier * @var WPSEO_Link_Type_Classifier
*/ */
protected $classifier; protected $classifier;
/** /**
* Represents the internal link lookup. This class tries get the postid for a given internal link.
*
* @var WPSEO_Link_Internal_Lookup * @var WPSEO_Link_Internal_Lookup
*/ */
protected $internal_lookup; protected $internal_lookup;
/** /**
* Represents the filter for filtering links.
*
* @var WPSEO_Link_Filter * @var WPSEO_Link_Filter
*/ */
protected $filter; protected $filter;
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
class WPSEO_Link_Filter { class WPSEO_Link_Filter {
/** /**
* Path to the current page.
*
* @var string|null * @var string|null
*/ */
protected $current_page_path; protected $current_page_path;
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
class WPSEO_Link_Installer { class WPSEO_Link_Installer {
/** /**
* Installable objects.
*
* @var WPSEO_Installable[] * @var WPSEO_Installable[]
*/ */
protected $installables = array(); protected $installables = array();
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
class WPSEO_Link_Notifier { class WPSEO_Link_Notifier {
/** /**
* The ID of the link indexing notification.
*
* @var string * @var string
*/ */
const NOTIFICATION_ID = 'wpseo-reindex-links'; const NOTIFICATION_ID = 'wpseo-reindex-links';
......
...@@ -11,21 +11,29 @@ ...@@ -11,21 +11,29 @@
class WPSEO_Link_Reindex_Post_Endpoint { class WPSEO_Link_Reindex_Post_Endpoint {
/** /**
* Holds the namespace of the rest route.
*
* @var string * @var string
*/ */
const REST_NAMESPACE = 'yoast/v1'; const REST_NAMESPACE = 'yoast/v1';
/** /**
* Holds the route of the endpoint to reindex the posts.
*
* @var string * @var string
*/ */
const ENDPOINT_QUERY = 'reindex_posts'; const ENDPOINT_QUERY = 'reindex_posts';
/** /**
* Holds the name of the capability needed to reindex the posts.
*
* @var string * @var string
*/ */
const CAPABILITY_RETRIEVE = 'edit_posts'; const CAPABILITY_RETRIEVE = 'edit_posts';
/** /**
* Holds the link reindex post service instance.
*
* @var WPSEO_Link_Reindex_Post_Service * @var WPSEO_Link_Reindex_Post_Service
*/ */
protected $service; protected $service;
......
...@@ -18,11 +18,15 @@ class WPSEO_Link_Storage implements WPSEO_Installable { ...@@ -18,11 +18,15 @@ class WPSEO_Link_Storage implements WPSEO_Installable {
const TABLE_NAME = 'yoast_seo_links'; const TABLE_NAME = 'yoast_seo_links';
/** /**
* An instance of the database proxy class.
*
* @var WPSEO_Database_Proxy * @var WPSEO_Database_Proxy
*/ */
protected $database_proxy; protected $database_proxy;
/** /**
* Holds the prefix of the database table.
*
* @deprecated 7.4 * @deprecated 7.4
* *
* @var null|string * @var null|string
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
class WPSEO_Link_Table_Accessible_Notifier { class WPSEO_Link_Table_Accessible_Notifier {
/** /**
* Notification id.
*
* @var string * @var string
*/ */
const NOTIFICATION_ID = 'wpseo-links-table-not-accessible'; const NOTIFICATION_ID = 'wpseo-links-table-not-accessible';
......
...@@ -11,11 +11,15 @@ ...@@ -11,11 +11,15 @@
class WPSEO_Link_Table_Accessible { class WPSEO_Link_Table_Accessible {
/** /**
* Constant used to determine whether the link table is accessible.
*
* @var string * @var string
*/ */
const ACCESSIBLE = '0'; const ACCESSIBLE = '0';
/** /**
* Constant used to determine whether the link table is inaccessible.
*
* @var string * @var string
*/ */
const INACCESSBILE = '1'; const INACCESSBILE = '1';
......
...@@ -11,11 +11,15 @@ ...@@ -11,11 +11,15 @@
class WPSEO_Link_Type_Classifier { class WPSEO_Link_Type_Classifier {
/** /**
* Host of the URL.
*
* @var string * @var string
*/ */
protected $base_host = ''; protected $base_host = '';
/** /**
* Path of the URL.
*
* @var string * @var string
*/ */
protected $base_path = ''; protected $base_path = '';
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
class WPSEO_Link_Watcher { class WPSEO_Link_Watcher {
/** /**
* Represents the content processor. It will extract links from the content and saves them for the given post id.
*
* @var WPSEO_Link_Content_Processor * @var WPSEO_Link_Content_Processor
*/ */
protected $content_processor; protected $content_processor;
......
...@@ -11,26 +11,36 @@ ...@@ -11,26 +11,36 @@
class WPSEO_Link { class WPSEO_Link {
/** /**
* Indicates that the link is external.
*
* @var string * @var string
*/ */
const TYPE_EXTERNAL = 'external'; const TYPE_EXTERNAL = 'external';
/** /**
* Indicates that the link is internal.
*
* @var string * @var string
*/ */
const TYPE_INTERNAL = 'internal'; const TYPE_INTERNAL = 'internal';
/** /**
* Holds the url.
*
* @var string * @var string
*/ */
protected $url; protected $url;
/** /**
* Holds the post ID of the target.
*
* @var int * @var int
*/ */
protected $target_post_id; protected $target_post_id;
/** /**
* Holds the link type.
*
* @var string * @var string
*/ */
protected $type; protected $type;
......
...@@ -92,6 +92,8 @@ class WPSEO_Replacevar_Editor { ...@@ -92,6 +92,8 @@ class WPSEO_Replacevar_Editor {
} }
/** /**
* Validates the replacement variable editor arguments.
*
* @param array $arguments The arguments to validate. * @param array $arguments The arguments to validate.
* *
* @throws InvalidArgumentException Thrown when not all required arguments are present. * @throws InvalidArgumentException Thrown when not all required arguments are present.
......
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin
*/
/**
* Base class for metabox that consist of multiple sections.
*/
abstract class WPSEO_Abstract_Metabox_Tab_With_Sections implements WPSEO_Metabox_Section {
/**
* Holds the name of the tab.
*
* @var string
*/
public $name;
/**
* Holds the HTML of the tab header.
*
* @var string
*/
protected $link_content;
/**
* Holds the name of the tab header.
*
* @var string
*/
protected $link_title;
/**
* Holds the classname of the tab header.
*
* @var string
*/
protected $link_class;
/**
* Holds the aria label of the tab header.
*
* @var string
*/
protected $link_aria_label;
/**
* Constructor.
*
* @param string $name The name of the section, used as an identifier in the html.
* Can only contain URL safe characters.
* @param string $link_content The text content of the section link.
* @param array $options Optional link attributes.
*/
public function __construct( $name, $link_content, array $options = array() ) {
$default_options = array(
'link_title' => '',
'link_class' => '',
'link_aria_label' => '',
);
$options = array_merge( $default_options, $options );
$this->name = $name;
$this->link_content = $link_content;
$this->link_title = $options['link_title'];
$this->link_class = $options['link_class'];
$this->link_aria_label = $options['link_aria_label'];
}
/**
* Outputs the section link if any section has been added.
*/
public function display_link() {
if ( $this->has_sections() ) {
printf(
'<li role="presentation"><a role="tab" href="#wpseo-meta-section-%1$s" id="wpseo-meta-tab-%1$s" aria-controls="wpseo-meta-section-%1$s" class="wpseo-meta-section-link %2$s"%3$s%4$s>%5$s</a></li>',
esc_attr( $this->name ),
esc_attr( $this->link_class ),
( '' !== $this->link_title ) ? ' title="' . esc_attr( $this->link_title ) . '"' : '',
( '' !== $this->link_aria_label ) ? ' aria-label="' . esc_attr( $this->link_aria_label ) . '"' : '',
$this->link_content
);
}
}
/**
* Checks whether the tab has any sections.
*
* @return bool Whether the tab has any sections
*/
abstract protected function has_sections();
}
...@@ -33,7 +33,7 @@ class WPSEO_Metabox_Addon_Tab_Section extends WPSEO_Metabox_Tab_Section { ...@@ -33,7 +33,7 @@ class WPSEO_Metabox_Addon_Tab_Section extends WPSEO_Metabox_Tab_Section {
* *
* @return bool * @return bool
*/ */
protected function has_tabs() { protected function has_sections() {
return true; return true;
} }
} }
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin
*/
/**
* Generates the HTML for a metabox tab.
*/
class WPSEO_Metabox_Collapsible implements WPSEO_Metabox_Tab {
/**
* The collapsible's unique identifier.
*
* @var string
*/
private $name;
/**
* The content to be displayed inside the collapsible.
*
* @var string
*/
private $content;
/**
* The label.
*
* @var string
*/
private $link_content;
/**
* Constructor.
*
* @param string $name The name of the tab, used as an identifier in the html.
* @param string $content The tab content.
* @param string $link_content The text content of the tab link.
*/
public function __construct( $name, $content, $link_content ) {
$this->name = $name;
$this->content = $content;
$this->link_content = $link_content;
}
/**
* Returns the html for the tab link.
*
* @return string
*/
public function link() {
return $this->link_content;
}
/**
* Returns the html for the tab content.
*
* @return string
*/
public function content() {
$collapsible_paper = new WPSEO_Paper_Presenter(
$this->link(),
null,
array(
'content' => $this->content,
'collapsible' => true,
'class' => 'metabox wpseo-form wpseo-collapsible-container',
'paper_id' => 'collapsible-' . $this->name,
)
);
return $collapsible_paper->get_output();
}
/**
* Returns the collapsible's unique identifier.
*
* @return string
*/
public function get_name() {
return $this->name;
}
}
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin
*/
/**
* Generates and displays a metabox tab that consists of collapsible sections.
*/
class WPSEO_Metabox_Collapsibles_Sections extends WPSEO_Abstract_Metabox_Tab_With_Sections {
/**
* Holds the tab's collapsibles.
*
* @var WPSEO_Metabox_Collapsible[]
*/
private $collapsibles = array();
/**
* Constructor.
*
* @param string $name The name of the section, used as an identifier in the html.
* Can only contain URL safe characters.
* @param string $link_content The text content of the section link.
* @param array $collapsibles The metabox collapsibles (`WPSEO_Metabox_Collapsible[]`) to be included in the section.
* @param array $options Optional link attributes.
*/
public function __construct( $name, $link_content, array $collapsibles = array(), array $options = array() ) {
parent::__construct( $name, $link_content, $options );
$this->collapsibles = $collapsibles;
}
/**
* Outputs the section content if any tab has been added.
*/
public function display_content() {
if ( $this->has_sections() ) {
printf( '<div id="%1$s" class="wpseo-meta-section">', esc_attr( 'wpseo-meta-section-' . $this->name ) );
echo '<div class="wpseo_content_wrapper">';
foreach ( $this->collapsibles as $collapsible ) {
echo $collapsible->content();
}
echo '</div></div>';
}
}
/**
* Checks whether the tab has any sections.
*
* @return bool Whether the tab has any sections
*/
protected function has_sections() {
return ! empty( $this->collapsibles );
}
}
...@@ -29,7 +29,6 @@ class WPSEO_Metabox_Editor { ...@@ -29,7 +29,6 @@ class WPSEO_Metabox_Editor {
public function add_css_inside_editor( $css_files ) { public function add_css_inside_editor( $css_files ) {
$asset_manager = new WPSEO_Admin_Asset_Manager(); $asset_manager = new WPSEO_Admin_Asset_Manager();
$styles = $asset_manager->special_styles(); $styles = $asset_manager->special_styles();
/** @var WPSEO_Admin_Asset $inside_editor */
$inside_editor = $styles['inside-editor']; $inside_editor = $styles['inside-editor'];
$asset_location = new WPSEO_Admin_Asset_SEO_Location( WPSEO_FILE ); $asset_location = new WPSEO_Admin_Asset_SEO_Location( WPSEO_FILE );
......
...@@ -11,41 +11,57 @@ ...@@ -11,41 +11,57 @@
class WPSEO_Metabox_Form_Tab implements WPSEO_Metabox_Tab { class WPSEO_Metabox_Form_Tab implements WPSEO_Metabox_Tab {
/** /**
* The tab identifier.
*
* @var string * @var string
*/ */
private $name; private $name;
/** /**
* The tab content.
*
* @var string * @var string
*/ */
private $content; private $content;
/** /**
* The tab link content.
*
* @var string * @var string
*/ */
private $link_content; private $link_content;
/** /**
* Additional tab content class.
*
* @var string * @var string
*/ */
private $tab_class; private $tab_class;
/** /**
* Additional tab link class.
*
* @var string * @var string
*/ */
private $link_class; private $link_class;
/** /**
* Title attribute on the link span.
*
* @var string * @var string
*/ */
private $link_title; private $link_title;
/** /**
* Arial label attribute on the link span.
*
* @var string * @var string
*/ */
private $link_aria_label; private $link_aria_label;
/** /**
* Does it contain a single tab.
*
* @var boolean * @var boolean
*/ */
private $single; private $single;
......
...@@ -45,6 +45,13 @@ class WPSEO_Metabox_Section_React implements WPSEO_Metabox_Section { ...@@ -45,6 +45,13 @@ class WPSEO_Metabox_Section_React implements WPSEO_Metabox_Section {
*/ */
private $link_aria_label; private $link_aria_label;
/**
* Additional html content to be displayed within the section.
*
* @var string
*/
private $html_after;
/** /**
* Constructor. * Constructor.
* *
...@@ -61,6 +68,7 @@ class WPSEO_Metabox_Section_React implements WPSEO_Metabox_Section { ...@@ -61,6 +68,7 @@ class WPSEO_Metabox_Section_React implements WPSEO_Metabox_Section {
$default_options = array( $default_options = array(
'link_class' => '', 'link_class' => '',
'link_aria_label' => '', 'link_aria_label' => '',
'html_after' => '',
); );
$options = wp_parse_args( $options, $default_options ); $options = wp_parse_args( $options, $default_options );
...@@ -68,6 +76,7 @@ class WPSEO_Metabox_Section_React implements WPSEO_Metabox_Section { ...@@ -68,6 +76,7 @@ class WPSEO_Metabox_Section_React implements WPSEO_Metabox_Section {
$this->link_content = $link_content; $this->link_content = $link_content;
$this->link_class = $options['link_class']; $this->link_class = $options['link_class'];
$this->link_aria_label = $options['link_aria_label']; $this->link_aria_label = $options['link_aria_label'];
$this->html_after = $options['html_after'];
} }
/** /**
...@@ -97,6 +106,7 @@ class WPSEO_Metabox_Section_React implements WPSEO_Metabox_Section { ...@@ -97,6 +106,7 @@ class WPSEO_Metabox_Section_React implements WPSEO_Metabox_Section {
); );
$html .= $this->content; $html .= $this->content;
$html .= '<div id="wpseo-metabox-root" class="wpseo-metabox-root"></div>'; $html .= '<div id="wpseo-metabox-root" class="wpseo-metabox-root"></div>';
$html .= $this->html_after;
$html .= '</div>'; $html .= '</div>';
echo $html; echo $html;
......
...@@ -8,38 +8,15 @@ ...@@ -8,38 +8,15 @@
/** /**
* Generates and displays the HTML for a metabox section. * Generates and displays the HTML for a metabox section.
*/ */
class WPSEO_Metabox_Tab_Section implements WPSEO_Metabox_Section { class WPSEO_Metabox_Tab_Section extends WPSEO_Abstract_Metabox_Tab_With_Sections {
/** /**
* An instance of the Metabox Tab class.
*
* @var WPSEO_Metabox_Tab[] * @var WPSEO_Metabox_Tab[]
*/ */
public $tabs = array(); public $tabs = array();
/**
* @var string
*/
public $name;
/**
* @var string
*/
private $link_content;
/**
* @var string
*/
private $link_title;
/**
* @var string
*/
private $link_class;
/**
* @var string
*/
private $link_aria_label;
/** /**
* Constructor. * Constructor.
* *
...@@ -50,15 +27,7 @@ class WPSEO_Metabox_Tab_Section implements WPSEO_Metabox_Section { ...@@ -50,15 +27,7 @@ class WPSEO_Metabox_Tab_Section implements WPSEO_Metabox_Section {
* @param array $options Optional link attributes. * @param array $options Optional link attributes.
*/ */
public function __construct( $name, $link_content, array $tabs = array(), array $options = array() ) { public function __construct( $name, $link_content, array $tabs = array(), array $options = array() ) {
$default_options = array( parent::__construct( $name, $link_content, $options );
'link_title' => '',
'link_class' => '',
'link_aria_label' => '',
);
$options = array_merge( $default_options, $options );
$this->name = $name;
// Filter out invalid tab instances. // Filter out invalid tab instances.
$valid_tabs = array_filter( $tabs, array( $this, 'is_valid_tab' ) ); $valid_tabs = array_filter( $tabs, array( $this, 'is_valid_tab' ) );
...@@ -66,10 +35,6 @@ class WPSEO_Metabox_Tab_Section implements WPSEO_Metabox_Section { ...@@ -66,10 +35,6 @@ class WPSEO_Metabox_Tab_Section implements WPSEO_Metabox_Section {
foreach ( $valid_tabs as $tab ) { foreach ( $valid_tabs as $tab ) {
$this->add_tab( $tab ); $this->add_tab( $tab );
} }
$this->link_content = $link_content;
$this->link_title = $options['link_title'];
$this->link_class = $options['link_class'];
$this->link_aria_label = $options['link_aria_label'];
} }
/** /**
...@@ -87,27 +52,11 @@ class WPSEO_Metabox_Tab_Section implements WPSEO_Metabox_Section { ...@@ -87,27 +52,11 @@ class WPSEO_Metabox_Tab_Section implements WPSEO_Metabox_Section {
return false; return false;
} }
/**
* Outputs the section link if any tab has been added.
*/
public function display_link() {
if ( $this->has_tabs() ) {
printf(
'<li role="presentation"><a role="tab" href="#wpseo-meta-section-%1$s" id="wpseo-meta-tab-%1$s" aria-controls="wpseo-meta-section-%1$s" class="wpseo-meta-section-link %2$s"%3$s%4$s>%5$s</a></li>',
esc_attr( $this->name ),
esc_attr( $this->link_class ),
( '' !== $this->link_title ) ? ' title="' . esc_attr( $this->link_title ) . '"' : '',
( '' !== $this->link_aria_label ) ? ' aria-label="' . esc_attr( $this->link_aria_label ) . '"' : '',
$this->link_content
);
}
}
/** /**
* Outputs the section content if any tab has been added. * Outputs the section content if any tab has been added.
*/ */
public function display_content() { public function display_content() {
if ( $this->has_tabs() ) { if ( $this->has_sections() ) {
$html = '<div role="tabpanel" id="wpseo-meta-section-%1$s" aria-labelledby="wpseo-meta-tab-%1$s" tabindex="0" class="wpseo-meta-section">'; $html = '<div role="tabpanel" id="wpseo-meta-section-%1$s" aria-labelledby="wpseo-meta-tab-%1$s" tabindex="0" class="wpseo-meta-section">';
$html .= '<div class="wpseo-metabox-tabs-div">'; $html .= '<div class="wpseo-metabox-tabs-div">';
$html .= '<ul class="wpseo-metabox-tabs %2$s">%3$s</ul>%4$s'; $html .= '<ul class="wpseo-metabox-tabs %2$s">%3$s</ul>%4$s';
...@@ -137,7 +86,7 @@ class WPSEO_Metabox_Tab_Section implements WPSEO_Metabox_Section { ...@@ -137,7 +86,7 @@ class WPSEO_Metabox_Tab_Section implements WPSEO_Metabox_Section {
* *
* @return bool * @return bool
*/ */
protected function has_tabs() { protected function has_sections() {
return ! empty( $this->tabs ); return ! empty( $this->tabs );
} }
......
...@@ -11,16 +11,22 @@ ...@@ -11,16 +11,22 @@
class WPSEO_Metabox extends WPSEO_Meta { class WPSEO_Metabox extends WPSEO_Meta {
/** /**
* An instance of the Social Admin class.
*
* @var WPSEO_Social_Admin * @var WPSEO_Social_Admin
*/ */
protected $social_admin; protected $social_admin;
/** /**
* An instance of the Metabox Analysis SEO class.
*
* @var WPSEO_Metabox_Analysis_SEO * @var WPSEO_Metabox_Analysis_SEO
*/ */
protected $analysis_seo; protected $analysis_seo;
/** /**
* An instance of the Metabox Analysis Readability class.
*
* @var WPSEO_Metabox_Analysis_Readability * @var WPSEO_Metabox_Analysis_Readability
*/ */
protected $analysis_readability; protected $analysis_readability;
...@@ -258,7 +264,7 @@ class WPSEO_Metabox extends WPSEO_Meta { ...@@ -258,7 +264,7 @@ class WPSEO_Metabox extends WPSEO_Meta {
*/ */
public function do_tab( $id, $heading, $content ) { public function do_tab( $id, $heading, $content ) {
?> ?>
<div id="<?php echo esc_attr( 'wpseo_' . $id ); ?>" class="wpseotab <?php echo esc_attr( $id ); ?>"> <div id="<?php echo esc_attr( 'wpseo_' . $id ); ?>" class="wpseotab wpseo-form <?php echo esc_attr( $id ); ?>">
<?php echo $content; ?> <?php echo $content; ?>
</div> </div>
<?php <?php
...@@ -309,10 +315,6 @@ class WPSEO_Metabox extends WPSEO_Meta { ...@@ -309,10 +315,6 @@ class WPSEO_Metabox extends WPSEO_Meta {
$content_sections[] = $this->social_admin->get_meta_section(); $content_sections[] = $this->social_admin->get_meta_section();
} }
if ( WPSEO_Capability_Utils::current_user_can( 'wpseo_edit_advanced_metadata' ) || WPSEO_Options::get( 'disableadvanced_meta' ) === false ) {
$content_sections[] = $this->get_advanced_meta_section();
}
if ( has_action( 'wpseo_tab_header' ) || has_action( 'wpseo_tab_content' ) ) { if ( has_action( 'wpseo_tab_header' ) || has_action( 'wpseo_tab_content' ) ) {
$content_sections[] = $this->get_addons_meta_section(); $content_sections[] = $this->get_addons_meta_section();
} }
...@@ -335,6 +337,23 @@ class WPSEO_Metabox extends WPSEO_Meta { ...@@ -335,6 +337,23 @@ class WPSEO_Metabox extends WPSEO_Meta {
$label = '<span class="wpseo-score-icon-container" id="wpseo-seo-score-icon"></span>' . $label; $label = '<span class="wpseo-score-icon-container" id="wpseo-seo-score-icon"></span>' . $label;
} }
$html_after = '';
if ( WPSEO_Capability_Utils::current_user_can( 'wpseo_edit_advanced_metadata' ) || WPSEO_Options::get( 'disableadvanced_meta' ) === false ) {
$advanced_collapsible = new WPSEO_Paper_Presenter(
__( 'Advanced', 'wordpress-seo' ),
null,
array(
'collapsible' => true,
'class' => 'metabox wpseo-form wpseo-collapsible-container',
'content' => $this->get_tab_content( 'advanced' ),
'paper_id' => 'collapsible-advanced-settings',
)
);
$html_after = '<div class="wpseo_content_wrapper">' . $advanced_collapsible->get_output() . '</div>';
}
/** /**
* Filter: 'wpseo_content_meta_section_content' - Allow filtering the metabox content before outputting. * Filter: 'wpseo_content_meta_section_content' - Allow filtering the metabox content before outputting.
* *
...@@ -345,7 +364,10 @@ class WPSEO_Metabox extends WPSEO_Meta { ...@@ -345,7 +364,10 @@ class WPSEO_Metabox extends WPSEO_Meta {
return new WPSEO_Metabox_Section_React( return new WPSEO_Metabox_Section_React(
'content', 'content',
$label, $label,
$content $content,
array(
'html_after' => $html_after,
)
); );
} }
...@@ -358,28 +380,6 @@ class WPSEO_Metabox extends WPSEO_Meta { ...@@ -358,28 +380,6 @@ class WPSEO_Metabox extends WPSEO_Meta {
return new WPSEO_Metabox_Section_Readability(); return new WPSEO_Metabox_Section_Readability();
} }
/**
* Returns the metabox section for the advanced settings.
*
* @return WPSEO_Metabox_Section
*/
private function get_advanced_meta_section() {
$content = $this->get_tab_content( 'advanced' );
$tab = new WPSEO_Metabox_Form_Tab(
'advanced',
$content,
__( 'Advanced', 'wordpress-seo' ),
array( 'single' => true )
);
return new WPSEO_Metabox_Tab_Section(
'advanced',
'<span class="dashicons dashicons-admin-generic"></span>' . __( 'Advanced', 'wordpress-seo' ),
array( $tab )
);
}
/** /**
* Returns a metabox section dedicated to hosting metabox tabs that have been added by other plugins through the * Returns a metabox section dedicated to hosting metabox tabs that have been added by other plugins through the
* `wpseo_tab_header` and `wpseo_tab_content` actions. * `wpseo_tab_header` and `wpseo_tab_content` actions.
...@@ -738,10 +738,14 @@ class WPSEO_Metabox extends WPSEO_Meta { ...@@ -738,10 +738,14 @@ class WPSEO_Metabox extends WPSEO_Meta {
$asset_manager->enqueue_script( 'metabox' ); $asset_manager->enqueue_script( 'metabox' );
$asset_manager->enqueue_script( 'admin-media' ); $asset_manager->enqueue_script( 'admin-media' );
$asset_manager->enqueue_script( 'post-scraper' ); $asset_manager->enqueue_script( 'post-scraper' );
$asset_manager->enqueue_script( 'replacevar-plugin' ); $asset_manager->enqueue_script( 'replacevar-plugin' );
$asset_manager->enqueue_script( 'shortcode-plugin' ); $asset_manager->enqueue_script( 'shortcode-plugin' );
$asset_manager->enqueue_script( 'admin-script' );
$asset_manager->enqueue_style( 'admin-css' );
wp_localize_script( WPSEO_Admin_Asset_Manager::PREFIX . 'admin-media', 'wpseoMediaL10n', $this->localize_media_script() ); wp_localize_script( WPSEO_Admin_Asset_Manager::PREFIX . 'admin-media', 'wpseoMediaL10n', $this->localize_media_script() );
wp_localize_script( WPSEO_Admin_Asset_Manager::PREFIX . 'post-scraper', 'wpseoPostScraperL10n', $this->localize_post_scraper_script() ); wp_localize_script( WPSEO_Admin_Asset_Manager::PREFIX . 'post-scraper', 'wpseoPostScraperL10n', $this->localize_post_scraper_script() );
$yoast_components_l10n = new WPSEO_Admin_Asset_Yoast_Components_L10n(); $yoast_components_l10n = new WPSEO_Admin_Asset_Yoast_Components_L10n();
...@@ -951,6 +955,8 @@ class WPSEO_Metabox extends WPSEO_Meta { ...@@ -951,6 +955,8 @@ class WPSEO_Metabox extends WPSEO_Meta {
} }
/** /**
* Checks if the page is the post overview page.
*
* @param string $page The page to check for the post overview page. * @param string $page The page to check for the post overview page.
* *
* @return bool Whether or not the given page is the post overview page. * @return bool Whether or not the given page is the post overview page.
...@@ -960,6 +966,8 @@ class WPSEO_Metabox extends WPSEO_Meta { ...@@ -960,6 +966,8 @@ class WPSEO_Metabox extends WPSEO_Meta {
} }
/** /**
* Checks if the page is the post edit page.
*
* @param string $page The page to check for the post edit page. * @param string $page The page to check for the post edit page.
* *
* @return bool Whether or not the given page is the post edit page. * @return bool Whether or not the given page is the post edit page.
......
...@@ -11,16 +11,22 @@ ...@@ -11,16 +11,22 @@
class WPSEO_Configuration_Notifier implements WPSEO_Listener { class WPSEO_Configuration_Notifier implements WPSEO_Listener {
/** /**
* Option name use to determine whether the notice has been dismissed.
*
* @var string * @var string
*/ */
const META_NAME = 'wpseo-dismiss-configuration-notice'; const META_NAME = 'wpseo-dismiss-configuration-notice';
/** /**
* Default value.
*
* @var string * @var string
*/ */
const META_VALUE = 'yes'; const META_VALUE = 'yes';
/** /**
* Should the notification be shown.
*
* @var bool * @var bool
*/ */
protected $show_notification; protected $show_notification;
......
...@@ -11,21 +11,29 @@ ...@@ -11,21 +11,29 @@
class WPSEO_OnPage_Option { class WPSEO_OnPage_Option {
/** /**
* Indicates the data is not fetched.
*
* @var int * @var int
*/ */
const NOT_FETCHED = 99; const NOT_FETCHED = 99;
/** /**
* Indicates the option is indexable.
*
* @var int * @var int
*/ */
const IS_INDEXABLE = 1; const IS_INDEXABLE = 1;
/** /**
* Indicates the option is not indexable.
*
* @var int * @var int
*/ */
const IS_NOT_INDEXABLE = 0; const IS_NOT_INDEXABLE = 0;
/** /**
* Indicates the data could not be fetched.
*
* @var int * @var int
*/ */
const CANNOT_FETCH = -1; const CANNOT_FETCH = -1;
......
...@@ -13,7 +13,9 @@ ...@@ -13,7 +13,9 @@
class WPSEO_OnPage_Request { class WPSEO_OnPage_Request {
/** /**
* @var string The endpoint where the request will be send to. * The endpoint where the request will be send to.
*
* @var string
*/ */
private $onpage_endpoint = 'https://indexability.yoast.onpage.org/'; private $onpage_endpoint = 'https://indexability.yoast.onpage.org/';
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
class WPSEO_Ryte_Service { class WPSEO_Ryte_Service {
/** /**
* This class handles the data for the option where the Ryte data is stored.
*
* @var WPSEO_OnPage_Option * @var WPSEO_OnPage_Option
*/ */
protected $option; protected $option;
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
abstract class WPSEO_Recalculate { abstract class WPSEO_Recalculate {
/** /**
* Recalculations per page.
*
* @var int * @var int
*/ */
protected $items_per_page = 20; protected $items_per_page = 20;
......
...@@ -11,16 +11,22 @@ ...@@ -11,16 +11,22 @@
class WPSEO_Statistics_Service { class WPSEO_Statistics_Service {
/** /**
* Cache transient id.
*
* @var string * @var string
*/ */
const CACHE_TRANSIENT_KEY = 'wpseo-statistics-totals'; const CACHE_TRANSIENT_KEY = 'wpseo-statistics-totals';
/** /**
* Class that generates interesting statistics about things.
*
* @var WPSEO_Statistics * @var WPSEO_Statistics
*/ */
protected $statistics; protected $statistics;
/** /**
* Statistics labels.
*
* @var string[] * @var string[]
*/ */
protected $labels; protected $labels;
......
...@@ -11,11 +11,15 @@ ...@@ -11,11 +11,15 @@
class WPSEO_Taxonomy_Columns { class WPSEO_Taxonomy_Columns {
/** /**
* The SEO analysis.
*
* @var WPSEO_Metabox_Analysis_SEO * @var WPSEO_Metabox_Analysis_SEO
*/ */
private $analysis_seo; private $analysis_seo;
/** /**
* The readability analysis.
*
* @var WPSEO_Metabox_Analysis_Readability * @var WPSEO_Metabox_Analysis_Readability
*/ */
private $analysis_readability; private $analysis_readability;
......
...@@ -18,6 +18,8 @@ class WPSEO_Taxonomy_Fields_Presenter { ...@@ -18,6 +18,8 @@ class WPSEO_Taxonomy_Fields_Presenter {
private $tax_meta; private $tax_meta;
/** /**
* Constructs the WPSEO_Taxonomy_Fields_Presenter class.
*
* @param stdClass $term The current term. * @param stdClass $term The current term.
*/ */
public function __construct( $term ) { public function __construct( $term ) {
......
...@@ -11,26 +11,36 @@ ...@@ -11,26 +11,36 @@
class WPSEO_Taxonomy_Metabox { class WPSEO_Taxonomy_Metabox {
/** /**
* The term currently being edited.
*
* @var WP_Term * @var WP_Term
*/ */
private $term; private $term;
/** /**
* The term's taxonomy.
*
* @var string * @var string
*/ */
private $taxonomy; private $taxonomy;
/** /**
* Renders the taxonomy field.
*
* @var WPSEO_Taxonomy_Fields_Presenter * @var WPSEO_Taxonomy_Fields_Presenter
*/ */
private $taxonomy_tab_content; private $taxonomy_tab_content;
/** /**
* Renders the taxonomy social fields.
*
* @var WPSEO_Taxonomy_Social_Fields * @var WPSEO_Taxonomy_Social_Fields
*/ */
private $taxonomy_social_fields; private $taxonomy_social_fields;
/** /**
* This class adds the Social tab to the Yoast SEO metabox and makes sure the settings are saved.
*
* @var WPSEO_Social_Admin * @var WPSEO_Social_Admin
*/ */
private $social_admin; private $social_admin;
...@@ -98,7 +108,6 @@ class WPSEO_Taxonomy_Metabox { ...@@ -98,7 +108,6 @@ class WPSEO_Taxonomy_Metabox {
} }
$content_sections[] = $this->get_social_meta_section(); $content_sections[] = $this->get_social_meta_section();
$content_sections[] = $this->get_settings_meta_section();
return $content_sections; return $content_sections;
} }
...@@ -119,10 +128,32 @@ class WPSEO_Taxonomy_Metabox { ...@@ -119,10 +128,32 @@ class WPSEO_Taxonomy_Metabox {
$label = '<span class="wpseo-score-icon-container" id="wpseo-seo-score-icon"></span>' . $label; $label = '<span class="wpseo-score-icon-container" id="wpseo-seo-score-icon"></span>' . $label;
} }
$html_after = '';
if ( WPSEO_Capability_Utils::current_user_can( 'wpseo_edit_advanced_metadata' ) || WPSEO_Options::get( 'disableadvanced_meta' ) === false ) {
$taxonomy_settings_fields = new WPSEO_Taxonomy_Settings_Fields( $this->term );
$advanced_collapsible = new WPSEO_Paper_Presenter(
__( 'Advanced', 'wordpress-seo' ),
null,
array(
'collapsible' => true,
'class' => 'metabox wpseo-form wpseo-collapsible-container',
'content' => $this->taxonomy_tab_content->html( $taxonomy_settings_fields->get() ),
'paper_id' => 'collapsible-advanced-settings',
)
);
$html_after = '<div class="wpseo_content_wrapper">' . $advanced_collapsible->get_output() . '</div>';
}
return new WPSEO_Metabox_Section_React( return new WPSEO_Metabox_Section_React(
'content', 'content',
$label, $label,
$content $content,
array(
'html_after' => $html_after,
)
); );
} }
...@@ -135,31 +166,6 @@ class WPSEO_Taxonomy_Metabox { ...@@ -135,31 +166,6 @@ class WPSEO_Taxonomy_Metabox {
return new WPSEO_Metabox_Section_Readability(); return new WPSEO_Metabox_Section_Readability();
} }
/**
* Returns the metabox section for the settings.
*
* @return WPSEO_Metabox_Section
*/
private function get_settings_meta_section() {
$taxonomy_settings_fields = new WPSEO_Taxonomy_Settings_Fields( $this->term );
$content = $this->taxonomy_tab_content->html( $taxonomy_settings_fields->get() );
$tab = new WPSEO_Metabox_Form_Tab(
'settings',
$content,
__( 'Settings', 'wordpress-seo' ),
array(
'single' => true,
)
);
return new WPSEO_Metabox_Tab_Section(
'settings',
'<span class="dashicons dashicons-admin-generic"></span>' . __( 'Settings', 'wordpress-seo' ),
array( $tab )
);
}
/** /**
* Returns the metabox section for the social settings. * Returns the metabox section for the social settings.
* *
...@@ -169,14 +175,14 @@ class WPSEO_Taxonomy_Metabox { ...@@ -169,14 +175,14 @@ class WPSEO_Taxonomy_Metabox {
$this->taxonomy_social_fields = new WPSEO_Taxonomy_Social_Fields( $this->term ); $this->taxonomy_social_fields = new WPSEO_Taxonomy_Social_Fields( $this->term );
$this->social_admin = new WPSEO_Social_Admin(); $this->social_admin = new WPSEO_Social_Admin();
$tabs = array(); $collapsibles = array();
$tabs[] = $this->create_tab( 'facebook', 'opengraph', 'facebook-alt', __( 'Facebook / Open Graph metadata', 'wordpress-seo' ) ); $collapsibles[] = $this->create_collapsible( 'facebook', 'opengraph', 'facebook-alt', __( 'Facebook', 'wordpress-seo' ) );
$tabs[] = $this->create_tab( 'twitter', 'twitter', 'twitter', __( 'Twitter metadata', 'wordpress-seo' ) ); $collapsibles[] = $this->create_collapsible( 'twitter', 'twitter', 'twitter', __( 'Twitter', 'wordpress-seo' ) );
return new WPSEO_Metabox_Tab_Section( return new WPSEO_Metabox_Collapsibles_Sections(
'social', 'social',
'<span class="dashicons dashicons-share"></span>' . __( 'Social', 'wordpress-seo' ), '<span class="dashicons dashicons-share"></span>' . __( 'Social', 'wordpress-seo' ),
$tabs $collapsibles
); );
} }
...@@ -188,33 +194,21 @@ class WPSEO_Taxonomy_Metabox { ...@@ -188,33 +194,21 @@ class WPSEO_Taxonomy_Metabox {
* @param string $icon The icon for the tab. * @param string $icon The icon for the tab.
* @param string $label The label for the tab. * @param string $label The label for the tab.
* *
* @return WPSEO_Metabox_Form_Tab A WPSEO_Metabox_Form_Tab instance. * @return WPSEO_Metabox_Tab A WPSEO_Metabox_Tab instance.
*/ */
private function create_tab( $name, $network, $icon, $label ) { private function create_collapsible( $name, $network, $icon, $label ) {
if ( WPSEO_Options::get( $network ) !== true ) { if ( WPSEO_Options::get( $network ) !== true ) {
return new WPSEO_Metabox_Null_Tab(); return new WPSEO_Metabox_Null_Tab();
} }
$meta_fields = $this->taxonomy_social_fields->get_by_network( $network ); $meta_fields = $this->taxonomy_social_fields->get_by_network( $network );
$tab_settings = new WPSEO_Metabox_Form_Tab( $tab_settings = new WPSEO_Metabox_Collapsible(
$name, $name,
$this->social_admin->get_premium_notice( $network ) . $this->taxonomy_tab_content->html( $meta_fields ), $this->social_admin->get_premium_notice( $network ) . $this->taxonomy_tab_content->html( $meta_fields ),
'<span class="screen-reader-text">' . $label . '</span><span class="dashicons dashicons-' . $icon . '"></span>', $label
array(
'single' => $this->has_single_social_tab(),
)
); );
return $tab_settings; return $tab_settings;
} }
/**
* Determine whether we only show one social network or two.
*
* @return bool
*/
private function has_single_social_tab() {
return ( WPSEO_Options::get( 'opengraph' ) === false || WPSEO_Options::get( 'twitter' ) === false );
}
} }
...@@ -18,7 +18,9 @@ class WPSEO_Taxonomy_Settings_Fields extends WPSEO_Taxonomy_Fields { ...@@ -18,7 +18,9 @@ class WPSEO_Taxonomy_Settings_Fields extends WPSEO_Taxonomy_Fields {
private $no_index_options = array(); private $no_index_options = array();
/** /**
* @param stdClass $term The currenct taxonomy. * The WPSEO_Taxonomy_Settings_Fields class constructor.
*
* @param stdClass $term The current taxonomy.
*/ */
public function __construct( $term ) { public function __construct( $term ) {
parent::__construct( $term ); parent::__construct( $term );
......
...@@ -18,11 +18,15 @@ class WPSEO_Taxonomy { ...@@ -18,11 +18,15 @@ class WPSEO_Taxonomy {
private $taxonomy = ''; private $taxonomy = '';
/** /**
* Holds the metabox SEO analysis instance.
*
* @var WPSEO_Metabox_Analysis_SEO * @var WPSEO_Metabox_Analysis_SEO
*/ */
private $analysis_seo; private $analysis_seo;
/** /**
* Holds the metabox readability analysis instance.
*
* @var WPSEO_Metabox_Analysis_Readability * @var WPSEO_Metabox_Analysis_Readability
*/ */
private $analysis_readability; private $analysis_readability;
...@@ -103,6 +107,7 @@ class WPSEO_Taxonomy { ...@@ -103,6 +107,7 @@ class WPSEO_Taxonomy {
$asset_manager->enqueue_style( 'scoring' ); $asset_manager->enqueue_style( 'scoring' );
$asset_manager->enqueue_script( 'metabox' ); $asset_manager->enqueue_script( 'metabox' );
$asset_manager->enqueue_script( 'term-scraper' ); $asset_manager->enqueue_script( 'term-scraper' );
$asset_manager->enqueue_script( 'admin-script' );
wp_localize_script( WPSEO_Admin_Asset_Manager::PREFIX . 'term-scraper', 'wpseoTermScraperL10n', $this->localize_term_scraper_script() ); wp_localize_script( WPSEO_Admin_Asset_Manager::PREFIX . 'term-scraper', 'wpseoTermScraperL10n', $this->localize_term_scraper_script() );
$yoast_components_l10n = new WPSEO_Admin_Asset_Yoast_Components_L10n(); $yoast_components_l10n = new WPSEO_Admin_Asset_Yoast_Components_L10n();
...@@ -275,6 +280,8 @@ class WPSEO_Taxonomy { ...@@ -275,6 +280,8 @@ class WPSEO_Taxonomy {
} }
/** /**
* Determines if a given page is the term overview page.
*
* @param string $page The string to check for the term overview page. * @param string $page The string to check for the term overview page.
* *
* @return bool * @return bool
...@@ -284,6 +291,8 @@ class WPSEO_Taxonomy { ...@@ -284,6 +291,8 @@ class WPSEO_Taxonomy {
} }
/** /**
* Determines if a given page is the term edit page.
*
* @param string $page The string to check for the term edit page. * @param string $page The string to check for the term edit page.
* *
* @return bool * @return bool
......
...@@ -11,16 +11,22 @@ ...@@ -11,16 +11,22 @@
class WPSEO_Tracking { class WPSEO_Tracking {
/** /**
* The tracking option name.
*
* @var string * @var string
*/ */
protected $option_name = 'wpseo_tracking_last_request'; protected $option_name = 'wpseo_tracking_last_request';
/** /**
* The limit or the option.
*
* @var int * @var int
*/ */
protected $threshold = 0; protected $threshold = 0;
/** /**
* The endpoint to send the data to.
*
* @var string * @var string
*/ */
protected $endpoint = ''; protected $endpoint = '';
......
...@@ -11,16 +11,22 @@ ...@@ -11,16 +11,22 @@
class Yoast_Input_Select { class Yoast_Input_Select {
/** /**
* The id attribute value.
*
* @var string * @var string
*/ */
private $select_id; private $select_id;
/** /**
* The name attribute value.
*
* @var string * @var string
*/ */
private $select_name; private $select_name;
/** /**
* Additional select attributes.
*
* @var array * @var array
*/ */
private $select_attributes = array(); private $select_attributes = array();
......
...@@ -20,26 +20,45 @@ if ( ! defined( 'WPSEO_VERSION' ) ) { ...@@ -20,26 +20,45 @@ if ( ! defined( 'WPSEO_VERSION' ) ) {
} }
?> ?>
<div class="paper tab-block"<?php echo ( $paper_id ) ? ' id="' . esc_attr( 'wpseo-' . $paper_id ) . '"' : ''; ?>> <div class="<?php echo esc_attr( 'paper tab-block ' . $class ); ?>"<?php echo ( $paper_id ) ? ' id="' . esc_attr( 'wpseo-' . $paper_id ) . '"' : ''; ?>>
<?php <?php
if ( ! empty( $title ) ) { if ( ! empty( $title ) ) {
if ( ! empty( $collapsible ) ) { if ( ! empty( $collapsible ) ) {
$button_id_attr = '';
if ( ! empty( $paper_id ) ) {
$button_id_attr = sprintf( ' id="%s"', esc_attr( 'wpseo-' . $paper_id . '-button' ) );
}
printf( printf(
'<h2 class="help-button-inline"><button type="button" class="toggleable-container-trigger" aria-expanded="%3$s">%1$s <span class="toggleable-container-icon dashicons %2$s" aria-hidden="true"></span></button></h2>', '<h2 class="collapsible-header"><button%4$s type="button" class="toggleable-container-trigger" aria-expanded="%3$s">%1$s <span class="toggleable-container-icon dashicons %2$s" aria-hidden="true"></span></button></h2>',
esc_html( $title ) . $title_after . $help_text->get_button_html(), esc_html( $title ) . $title_after . $help_text->get_button_html(),
$collapsible_config['toggle_icon'], $collapsible_config['toggle_icon'],
$collapsible_config['expanded'] $collapsible_config['expanded'],
$button_id_attr
); );
} }
else { else {
printf( '<h2 class="help-button-inline">' . esc_html( $title ) . $title_after . $help_text->get_button_html() . '</h2>' ); printf( '<div class="paper-title"><h2 class="help-button-inline">' . esc_html( $title ) . $title_after . $help_text->get_button_html() . '</h2></div>' );
} }
} }
?> ?>
<?php echo $help_text->get_panel_html(); ?> <?php
<div class="<?php echo esc_attr( $collapsible_config['class'] ); ?>">
<?php require $view_file; ?> echo $help_text->get_panel_html();
</div>
$container_id_attr = '';
if ( ! empty( $paper_id ) ) {
$container_id_attr = sprintf( ' id="%s"', esc_attr( 'wpseo-' . $paper_id . '-container' ) );
}
printf(
'<div%1$s class="%2$s">%3$s</div>',
$container_id_attr,
esc_attr( 'paper-container ' . $collapsible_config['class'] ),
$content
);
?>
</div> </div>
...@@ -5,7 +5,13 @@ ...@@ -5,7 +5,13 @@
* @package WPSEO\Admin * @package WPSEO\Admin
*/ */
/** @noinspection PhpUnusedLocalVariableInspection */ /**
* Alerts template variables.
*
* @noinspection PhpUnusedLocalVariableInspection
*
* @var array
*/
$alerts_data = Yoast_Alerts::get_template_variables(); $alerts_data = Yoast_Alerts::get_template_variables();
$notifier = new WPSEO_Configuration_Notifier(); $notifier = new WPSEO_Configuration_Notifier();
......
...@@ -45,6 +45,7 @@ foreach ( $wpseo_archives as $wpseo_archive_index => $wpseo_archive ) { ...@@ -45,6 +45,7 @@ foreach ( $wpseo_archives as $wpseo_archive_index => $wpseo_archive ) {
'paper_id' => $wpseo_archive['paper_id'], 'paper_id' => $wpseo_archive['paper_id'],
'recommended_replace_vars' => $recommended_replace_vars, 'recommended_replace_vars' => $recommended_replace_vars,
'editor_specific_replace_vars' => $editor_specific_replace_vars, 'editor_specific_replace_vars' => $editor_specific_replace_vars,
'class' => 'search-appearance',
) )
); );
......
...@@ -16,6 +16,7 @@ $wpseo_breadcrumbs_presenter = new WPSEO_Paper_Presenter( ...@@ -16,6 +16,7 @@ $wpseo_breadcrumbs_presenter = new WPSEO_Paper_Presenter(
dirname( __FILE__ ) . '/paper-content/breadcrumbs-content.php', dirname( __FILE__ ) . '/paper-content/breadcrumbs-content.php',
array( array(
'paper_id' => 'settings-breadcrumbs', 'paper_id' => 'settings-breadcrumbs',
'class' => 'search-appearance',
) )
); );
echo $wpseo_breadcrumbs_presenter->get_output(); echo $wpseo_breadcrumbs_presenter->get_output();
...@@ -16,6 +16,7 @@ $wpseo_general_presenter = new WPSEO_Paper_Presenter( ...@@ -16,6 +16,7 @@ $wpseo_general_presenter = new WPSEO_Paper_Presenter(
dirname( __FILE__ ) . '/paper-content/general-content.php', dirname( __FILE__ ) . '/paper-content/general-content.php',
array( array(
'paper_id' => 'settings-general', 'paper_id' => 'settings-general',
'class' => 'search-appearance',
) )
); );
......
...@@ -22,6 +22,7 @@ $wpseo_media_presenter = new WPSEO_Paper_Presenter( ...@@ -22,6 +22,7 @@ $wpseo_media_presenter = new WPSEO_Paper_Presenter(
'has-wrapper' 'has-wrapper'
), ),
'paper_id' => 'settings-media-attachment-url', 'paper_id' => 'settings-media-attachment-url',
'class' => 'search-appearance',
) )
); );
......
...@@ -46,6 +46,7 @@ if ( is_array( $wpseo_post_types ) && $wpseo_post_types !== array() ) { ...@@ -46,6 +46,7 @@ if ( is_array( $wpseo_post_types ) && $wpseo_post_types !== array() ) {
), ),
'title' => $post_type->labels->name, 'title' => $post_type->labels->name,
'title_after' => ' (<code>' . esc_html( $post_type->name ) . '</code>)', 'title_after' => ' (<code>' . esc_html( $post_type->name ) . '</code>)',
'class' => 'search-appearance',
) )
); );
......
...@@ -22,6 +22,7 @@ $wpseo_rss_presenter = new WPSEO_Paper_Presenter( ...@@ -22,6 +22,7 @@ $wpseo_rss_presenter = new WPSEO_Paper_Presenter(
'has-wrapper' 'has-wrapper'
), ),
'paper_id' => 'settings-rss-feed', 'paper_id' => 'settings-rss-feed',
'class' => 'search-appearance',
) )
); );
......
...@@ -35,6 +35,7 @@ if ( is_array( $wpseo_taxonomies ) && $wpseo_taxonomies !== array() ) { ...@@ -35,6 +35,7 @@ if ( is_array( $wpseo_taxonomies ) && $wpseo_taxonomies !== array() ) {
'editor_specific_replace_vars' => $editor_specific_replace_vars, 'editor_specific_replace_vars' => $editor_specific_replace_vars,
), ),
'title_after' => ' (<code>' . esc_html( $wpseo_taxonomy->name ) . '</code>)', 'title_after' => ' (<code>' . esc_html( $wpseo_taxonomy->name ) . '</code>)',
'class' => 'search-appearance',
) )
); );
echo $wpseo_taxonomy_presenter->get_output(); echo $wpseo_taxonomy_presenter->get_output();
......
<?php
/**
* Yoast SEO Plugin File.
*
* @package Yoast\YoastSEO\Composer
*/
namespace Yoast\WP\Free\Composer;
use Composer\Script\Event;
use Yoast\WP\Free\Dependency_Injection\Container_Compiler;
/**
* Class to handle Composer actions and events.
*/
class Actions {
/**
* Prefixes dependencies if composer install is ran with dev mode.
*
* Used in composer in the post-install script hook.
*
* @codeCoverageIgnore
*
* @param \Composer\Script\Event $event Composer event that triggered this script.
*
* @return void
*/
public static function prefix_dependencies( Event $event ) {
$io = $event->getIO();
if ( ! $event->isDevMode() ) {
$io->write( 'Not prefixing dependencies.' );
return;
}
$io->write( 'Prefixing dependencies...' );
$event_dispatcher = $event->getComposer()->getEventDispatcher();
$event_dispatcher->dispatchScript( 'prefix-dependencies', $event->isDevMode() );
}
/**
* Compiles the dependency injection container.
*
* Used the composer compile-dependency-injection-container command.
*
* @codeCoverageIgnore
*
* @param \Composer\Script\Event $event Composer event that triggered this script.
*
* @return void
*/
public static function compile_dependency_injection_container( Event $event ) {
$io = $event->getIO();
$io->write( 'Compiling the dependency injection container...' );
// Pas true as debug to force a recheck of the container.
Container_Compiler::compile( true );
$io->write( 'The dependency injection container has been compiled.' );
}
}
<?php
/**
* Yoast SEO Plugin File.
*
* @package Yoast\YoastSEO\Dependency_Injection
*/
namespace Yoast\WP\Free\Dependency_Injection;
use Symfony\Component\Config\ConfigCache;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
/**
* This class is responsible for compiling the dependency injection container.
*/
class Container_Compiler {
/**
* Compiles the dependency injection container.
*
* @param boolean $debug If false the container will only be re-compiled if it does not yet already exist.
*
* @throws \Exception If compiling the container fails.
*
* @return void
*/
public static function compile( $debug ) {
$file = __DIR__ . '/../../src/generated/container.php';
$cache = new ConfigCache( $file, $debug );
if ( ! $cache->isFresh() ) {
$container_builder = new ContainerBuilder();
$container_builder->addCompilerPass( new Loader_Pass() );
$loader = new Custom_Loader( $container_builder );
$loader->load( 'config/dependency-injection/services.php' );
$container_builder->compile();
$dumper = new PhpDumper( $container_builder );
$code = $dumper->dump(
[
'class' => 'Cached_Container',
'namespace' => 'Yoast\WP\Free\Generated',
]
);
$code = str_replace( 'Symfony\\Component\\DependencyInjection', 'YoastSEO_Vendor\\Symfony\\Component\\DependencyInjection', $code );
$code = str_replace( 'Symfony\\\\Component\\\\DependencyInjection', 'YoastSEO_Vendor\\\\Symfony\\\\Component\\\\DependencyInjection', $code );
$cache->write( $code, $container_builder->getResources() );
}
}
}
<?php
/**
* Yoast SEO Plugin File.
*
* @package Yoast\YoastSEO\Dependency_Injection
*/
namespace Yoast\WP\Free\Dependency_Injection;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
use Symfony\Component\Config\Resource\GlobResource;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\Definition;
/**
* This class is mostly a direct copy-paste of the symfony PhpFileLoader class.
* It's been adapted to allow automatic discovery based on not just PSR-4 but also the Yoast standards.
*/
class Custom_Loader extends PhpFileLoader {
/**
* Custom_Loader constructor.
*
* @param ContainerBuilder $container The ContainerBuilder to load classes for.
*/
public function __construct( ContainerBuilder $container ) {
parent::__construct( $container, new FileLocator( __DIR__ . '/../..' ) );
}
/**
* Transforms a path to a class name using the class map.
*
* @param string $path The path of the class.
*
* @return bool|string The classname.
*/
private function getClassFromClassMap( $path ) {
static $class_map;
if ( ! $class_map ) {
$class_map = require __DIR__ . '/../../vendor/composer/autoload_classmap.php';
}
foreach ( $class_map as $class => $class_path ) {
if ( $path === $class_path ) {
return $class;
}
}
return false;
}
/**
* Registers a set of classes as services using PSR-4 for discovery.
*
* @param Definition $prototype A definition to use as template.
* @param string $namespace The namespace prefix of classes in the scanned directory.
* @param string $resource The directory to look for classes, glob-patterns allowed.
* @param string $exclude A globed path of files to exclude.
*
* @throws InvalidArgumentException If invalid arguments are supplied.
*
* @return void
*/
public function registerClasses( Definition $prototype, $namespace, $resource, $exclude = null ) {
if ( '\\' !== substr( $namespace, -1 ) ) {
throw new InvalidArgumentException( sprintf( 'Namespace prefix must end with a "\\": %s.', $namespace ) );
}
if ( ! preg_match( '/^(?:[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+\\\\)++$/', $namespace ) ) {
throw new InvalidArgumentException( sprintf( 'Namespace is not a valid PSR-4 prefix: %s.', $namespace ) );
}
$classes = $this->findClasses( $namespace, $resource, $exclude );
// Prepare for deep cloning.
$serialized_prototype = serialize( $prototype );
$interfaces = [];
$singly_implemented = [];
foreach ( $classes as $class => $error_message ) {
if ( interface_exists( $class, false ) ) {
$interfaces[] = $class;
}
else {
$this->setDefinition( $class, $definition = unserialize( $serialized_prototype ) );
if ( null !== $error_message ) {
$definition->addError( $error_message );
continue;
}
foreach ( class_implements( $class, false ) as $interface ) {
$singly_implemented[ $interface ] = isset( $singly_implemented[ $interface ] ) ? false : $class;
}
}
}
foreach ( $interfaces as $interface ) {
if ( ! empty( $singly_implemented[ $interface ] ) ) {
$this->container->setAlias( $interface, $singly_implemented[ $interface ] )
->setPublic( false );
}
}
}
/**
* Registers a definition in the container with its instanceof-conditionals.
*
* @param string $id The ID of the definition.
* @param Definition $definition The definition.
*
* @throws InvalidArgumentException If invalid arguments were supplied.
*
* @return void
*/
protected function setDefinition( $id, Definition $definition ) {
$this->container->removeBindings( $id );
// @codingStandardsIgnoreLine WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar This is from an inherited class not abiding by that standard.
if ( $this->isLoadingInstanceof ) {
if ( ! $definition instanceof ChildDefinition ) {
throw new InvalidArgumentException( sprintf( 'Invalid type definition "%s": ChildDefinition expected, "%s" given.', $id, \get_class( $definition ) ) );
}
$this->instanceof[ $id ] = $definition;
}
else {
$this->container->setDefinition( $id, ( $definition instanceof ChildDefinition ) ? $definition : $definition->setInstanceofConditionals( $this->instanceof ) );
}
}
/**
* Finds classes based on a given pattern and exclude pattern.
*
* @param string $namespace The namespace prefix of classes in the scanned directory.
* @param string $pattern The directory to look for classes, glob-patterns allowed.
* @param string $exclude A globed path of files to exclude.
*
* @throws InvalidArgumentException If invalid arguments were supplied.
*
* @return array The found classes.
*/
private function findClasses( $namespace, $pattern, $exclude ) {
$parameter_bag = $this->container->getParameterBag();
$exclude_paths = [];
$exclude_prefix = null;
if ( $exclude ) {
$exclude = $parameter_bag->unescapeValue( $parameter_bag->resolveValue( $exclude ) );
foreach ( $this->glob( $exclude, true, $resource ) as $path => $info ) {
if ( null === $exclude_prefix ) {
$exclude_prefix = $resource->getPrefix();
}
// Normalize Windows slashes.
$exclude_paths[ str_replace( '\\', '/', $path ) ] = true;
}
}
$pattern = $parameter_bag->unescapeValue( $parameter_bag->resolveValue( $pattern ) );
$classes = [];
$ext_regexp = \defined( 'HHVM_VERSION' ) ? '/\\.(?:php|hh)$/' : '/\\.php$/';
$prefix_len = null;
foreach ( $this->glob( $pattern, true, $resource ) as $path => $info ) {
if ( null === $prefix_len ) {
$prefix_len = \strlen( $resource->getPrefix() );
if ( $exclude_prefix && 0 !== strpos( $exclude_prefix, $resource->getPrefix() ) ) {
throw new InvalidArgumentException( sprintf( 'Invalid "exclude" pattern when importing classes for "%s": make sure your "exclude" pattern (%s) is a subset of the "resource" pattern (%s)', $namespace, $exclude, $pattern ) );
}
}
if ( isset( $exclude_paths[ str_replace( '\\', '/', $path ) ] ) ) {
continue;
}
if ( ! preg_match( $ext_regexp, $path, $m ) || ! $info->isReadable() ) {
continue;
}
$class = $this->getClassFromClassMap( $path );
if ( ! $class || ! preg_match( '/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+(?:\\\\[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+)*+$/', $class ) ) {
continue;
}
try {
$r = $this->container->getReflectionClass( $class );
} catch ( \ReflectionException $e ) {
$classes[ $class ] = sprintf(
'While discovering services from namespace "%s", an error was thrown when processing the class "%s": "%s".',
$namespace,
$class,
$e->getMessage()
);
continue;
}
// Check to make sure the expected class exists.
if ( ! $r ) {
throw new InvalidArgumentException( sprintf( 'Expected to find class "%s" in file "%s" while importing services from resource "%s", but it was not found! Check the namespace prefix used with the resource.', $class, $path, $pattern ) );
}
if ( $r->isInstantiable() || $r->isInterface() ) {
$classes[ $class ] = null;
}
}
// Track only for new & removed files.
if ( $resource instanceof GlobResource ) {
$this->container->addResource( $resource );
}
else {
foreach ( $resource as $path ) {
$this->container->fileExists( $path, false );
}
}
return $classes;
}
}
<?php
/**
* Yoast SEO Plugin File.
*
* @package Yoast\YoastSEO\Dependency_Injection
*/
namespace Yoast\WP\Free\Dependency_Injection;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
use Yoast\WP\Free\Conditionals\Conditional;
use Yoast\WP\Free\Loader;
use Yoast\WP\Free\WordPress\Initializer;
use Yoast\WP\Free\WordPress\Integration;
/**
* A pass is a step in the compilation process of the container.
*
* This step will automatically ensure all classes implementing the Integration interface
* are registered with the Loader class.
*/
class Loader_Pass implements CompilerPassInterface {
/**
* Checks all definitions to ensure all classes implementing the Integration interface
* are registered with the Loader class.
*
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container The container.
*/
public function process( ContainerBuilder $container ) {
if ( ! $container->hasDefinition( Loader::class ) ) {
return;
}
$loader_definition = $container->getDefinition( Loader::class );
$loader_definition->setArgument( 0, new Reference( 'service_container' ) );
$loader_definition->setPublic( true );
$definitions = $container->getDefinitions();
foreach ( $definitions as $definition ) {
$this->process_definition( $definition, $loader_definition );
}
}
/**
* Processes a definition in the container.
*
* @param \Symfony\Component\DependencyInjection\Definition $definition The definition to process.
* @param \Symfony\Component\DependencyInjection\Definition $loader_definition The loader definition.
*/
private function process_definition( Definition $definition, Definition $loader_definition ) {
$class = $definition->getClass();
if ( is_subclass_of( $class, Initializer::class ) ) {
$loader_definition->addMethodCall( 'register_initializer', [ $class ] );
$definition->setPublic( true );
}
if ( is_subclass_of( $class, Integration::class ) ) {
$loader_definition->addMethodCall( 'register_integration', [ $class ] );
$definition->setPublic( true );
}
if ( is_subclass_of( $class, Conditional::class ) ) {
$definition->setPublic( true );
}
}
}
<?php
/**
* Yoast SEO Plugin File.
*
* @package Yoast\YoastSEO\Dependency_Injection
*/
namespace Yoast\WP\Free\Dependency_Injection;
use Symfony\Component\DependencyInjection\Definition;
use Yoast\WP\Free\Repositories\Indexable_Repository;
use Yoast\WP\Free\Repositories\Primary_Term_Repository;
use Yoast\WP\Free\Repositories\SEO_Links_Repository;
use Yoast\WP\Free\Repositories\SEO_Meta_Repository;
use Yoast\WP\Free\WordPress\Wrapper;
/* @var $container \Symfony\Component\DependencyInjection\ContainerBuilder */
// WordPress factory functions.
$container->register( 'wpdb', 'wpdb' )->setFactory( [ Wrapper::class, 'get_wpdb' ] );
$container->register( 'wp_query', 'WP_Query' )->setFactory( [ Wrapper::class, 'get_wp_query' ] );
// Model repository factory functions.
$container->register( Indexable_Repository::class, Indexable_Repository::class )->setFactory( [ Indexable_Repository::class, 'get_instance' ] )->setAutowired( true );
$container->register( Primary_Term_Repository::class, Primary_Term_Repository::class )->setFactory( [ Primary_Term_Repository::class, 'get_instance' ] )->setAutowired( true );
$container->register( SEO_Meta_Repository::class, SEO_Meta_Repository::class )->setFactory( [ SEO_Meta_Repository::class, 'get_instance' ] )->setAutowired( true );
$container->register( SEO_Links_Repository::class, SEO_Links_Repository::class )->setFactory( [ SEO_Links_Repository::class, 'get_instance' ] )->setAutowired( true );
$excluded_files = [
'main.php',
];
$excluded_directories = [
'models',
'loaders',
'wordpress',
'generated',
'orm',
];
$excluded = implode( ',', array_merge( $excluded_directories, $excluded_files ) );
$base_definition = new Definition();
$base_definition
->setAutowired( true )
->setAutoconfigured( true )
->setPublic( false );
/* @var $loader \Yoast\WP\Free\Dependency_Injection\Custom_Loader */
$loader->registerClasses( $base_definition, 'Yoast\\WP\\Free\\', 'src/*', 'src/{' . $excluded . '}' );
if ( file_exists( __DIR__ . '/../../premium/config/dependency-injection/services.php' ) ) {
include __DIR__ . '/../../premium/config/dependency-injection/services.php';
}
<?php
declare( strict_types=1 );
use Isolated\Symfony\Component\Finder\Finder;
return array(
/*
* By default when running php-scoper add-prefix, it will prefix all relevant code found in the current working
* directory. You can however define which files should be scoped by defining a collection of Finders in the
* following configuration key.
*
* For more see: https://github.com/humbug/php-scoper#finders-and-paths
*/
'finders' => [
Finder::create()->files()->in( 'vendor/symfony/dependency-injection' )->name( [
'Container.php', 'ContainerInterface.php', 'ResettableContainerInterface.php', 'LICENSE', 'composer.json'
] ),
Finder::create()->files()->in( 'vendor/symfony/dependency-injection/Argument' )->name( [ 'RewindableGenerator.php' ] ),
Finder::create()->files()->in( 'vendor/symfony/dependency-injection/Exception' )->name( [
'InvalidArgumentException.php', 'LogicException.php', 'RuntimeException.php',
'ServiceCircularReferenceException.php', 'ServiceNotFoundException.php', 'EnvNotFoundException.php',
'ParameterCircularReferenceException.php', 'ExceptionInterface.php'
] ),
Finder::create()->files()->in( 'vendor/symfony/dependency-injection/ParameterBag' )->name( [
'FrozenParameterBag.php', 'ParameterBagInterface.php', 'EnvPlaceholderParameterBag.php'
] ),
],
/*
* When scoping PHP files, there will be scenarios where some of the code being scoped indirectly references the
* original namespace. These will include, for example, strings or string manipulations. PHP-Scoper has limited
* support for prefixing such strings. To circumvent that, you can define patchers to manipulate the file to your
* heart contents.
*
* For more see: https://github.com/humbug/php-scoper#patchers
*/
'patchers' => [],
);
<?php
declare( strict_types=1 );
use Isolated\Symfony\Component\Finder\Finder;
return array(
/*
* By default when running php-scoper add-prefix, it will prefix all relevant code found in the current working
* directory. You can however define which files should be scoped by defining a collection of Finders in the
* following configuration key.
*
* For more see: https://github.com/humbug/php-scoper#finders-and-paths
*/
'finders' => [
Finder::create()->files()->in( 'vendor/guzzlehttp/guzzle' )->name( [ '*.php', 'LICENSE', 'composer.json' ] ),
Finder::create()->files()->in( 'vendor/guzzlehttp/promises' )->name( [ '*.php', 'LICENSE', 'composer.json' ] ),
Finder::create()->files()->in( 'vendor/guzzlehttp/psr7' )->name( [ '*.php', 'LICENSE', 'composer.json' ] ),
],
/*
* When scoping PHP files, there will be scenarios where some of the code being scoped indirectly references the
* original namespace. These will include, for example, strings or string manipulations. PHP-Scoper has limited
* support for prefixing such strings. To circumvent that, you can define patchers to manipulate the file to your
* heart contents.
*
* For more see: https://github.com/humbug/php-scoper#patchers
*/
'patchers' => [],
);
<?php
declare(strict_types = 1);
use Isolated\Symfony\Component\Finder\Finder;
return array(
/*
* By default when running php-scoper add-prefix, it will prefix all relevant code found in the current working
* directory. You can however define which files should be scoped by defining a collection of Finders in the
* following configuration key.
*
* For more see: https://github.com/humbug/php-scoper#finders-and-paths
*/
'finders' => array(
Finder::create()->files()->in( 'vendor/j4mie/idiorm' )->name( [ 'idiorm.php', 'LICENSE', 'composer.json' ] ),
),
/*
* When scoping PHP files, there will be scenarios where some of the code being scoped indirectly references the
* original namespace. These will include, for example, strings or string manipulations. PHP-Scoper has limited
* support for prefixing such strings. To circumvent that, you can define patchers to manipulate the file to your
* heart contents.
*
* For more see: https://github.com/humbug/php-scoper#patchers
*/
'patchers' => array(),
/*
* By default, PHP-Scoper only prefixes code where the namespace is non-global. In other words, non-namespaced
* code is not prefixed. This leaves the majority of classes, functions and constants in PHP - and most extensions,
* untouched.
*
* This is not necessarily a desirable outcome for vendor dependencies which are also not namespaced. To ensure
* they are isolated, you can configure the following which can be a list of strings or callables taking a string
* (the class name) as an argument and return a boolean (true meaning the class is going to prefixed).
*
* For more, see https://github.com/humbug/php-scoper#global-namespace-whitelisting
*/
'global_namespace_whitelist' => array(
'ORM',
function( $class_name ) {
return strpos( $class_name, 'Idiorm' ) === 0;
},
),
);
<?php
declare( strict_types=1 );
use Isolated\Symfony\Component\Finder\Finder;
return array(
/*
* By default when running php-scoper add-prefix, it will prefix all relevant code found in the current working
* directory. You can however define which files should be scoped by defining a collection of Finders in the
* following configuration key.
*
* For more see: https://github.com/humbug/php-scoper#finders-and-paths
*/
'finders' => [
Finder::create()->files()->in( 'vendor/league/oauth2-client' )->name( [ '*.php', 'LICENSE', 'composer.json' ] ),
],
/*
* When scoping PHP files, there will be scenarios where some of the code being scoped indirectly references the
* original namespace. These will include, for example, strings or string manipulations. PHP-Scoper has limited
* support for prefixing such strings. To circumvent that, you can define patchers to manipulate the file to your
* heart contents.
*
* For more see: https://github.com/humbug/php-scoper#patchers
*/
'patchers' => [
/**
* Replaces the Adapter string references with the prefixed versions.
*
* @param string $filePath The path of the current file.
* @param string $prefix The prefix to be used.
* @param string $content The content of the specific file.
*
* @return string The modified content.
*/
function( $file_path, $prefix, $content ) {
// 26 is the length of the GrantFactory.php file path.
if ( substr( $file_path, -26 ) !== 'src/Grant/GrantFactory.php' ) {
return $content;
}
$replaced = str_replace(
'$class = \'League\\\\OAuth2\\\\Client\\\\Grant\\\\\' . $class;',
sprintf( '$class = \'%s\\\\League\\\\OAuth2\\\\Client\\\\Grant\\\\\' . $class;', $prefix ),
$content
);
return $replaced;
},
],
);
<?php
declare( strict_types=1 );
use Isolated\Symfony\Component\Finder\Finder;
return array(
/*
* By default when running php-scoper add-prefix, it will prefix all relevant code found in the current working
* directory. You can however define which files should be scoped by defining a collection of Finders in the
* following configuration key.
*
* For more see: https://github.com/humbug/php-scoper#finders-and-paths
*/
'finders' => [
Finder::create()->files()->in( 'vendor/psr/container' )->name( [ '*.php', 'LICENSE', 'composer.json' ] ),
Finder::create()->files()->in( 'vendor/psr/http-message' )->name( [ '*.php', 'LICENSE', 'composer.json' ] ),
Finder::create()->files()->in( 'vendor/psr/log' )->exclude( 'Test' )->name( [ '*.php', 'LICENSE', 'composer.json' ] ),
],
/*
* When scoping PHP files, there will be scenarios where some of the code being scoped indirectly references the
* original namespace. These will include, for example, strings or string manipulations. PHP-Scoper has limited
* support for prefixing such strings. To circumvent that, you can define patchers to manipulate the file to your
* heart contents.
*
* For more see: https://github.com/humbug/php-scoper#patchers
*/
'patchers' => [],
);
<?php
declare( strict_types=1 );
use Isolated\Symfony\Component\Finder\Finder;
return array(
/*
* By default when running php-scoper add-prefix, it will prefix all relevant code found in the current working
* directory. You can however define which files should be scoped by defining a collection of Finders in the
* following configuration key.
*
* For more see: https://github.com/humbug/php-scoper#finders-and-paths
*/
'finders' => array(
Finder::create()->files()->in( 'vendor/ruckusing/ruckusing-migrations' )
->exclude( [ 'config', 'tests', 'lib/Task/Hello' ] )
->name( [ '*.php', 'LICENSE', 'composer.json' ] ),
),
/*
* When scoping PHP files, there will be scenarios where some of the code being scoped indirectly references the
* original namespace. These will include, for example, strings or string manipulations. PHP-Scoper has limited
* support for prefixing such strings. To circumvent that, you can define patchers to manipulate the file to your
* heart contents.
*
* For more see: https://github.com/humbug/php-scoper#patchers
*/
'patchers' => array(
/**
* Replaces the Adapter string references with the prefixed versions.
*
* @param string $filePath The path of the current file.
* @param string $prefix The prefix to be used.
* @param string $content The content of the specific file.
*
* @return string The modified content.
*/
function( $file_path, $prefix, $content ) {
if ( substr( $file_path, -33 ) !== 'lib/Ruckusing/FrameworkRunner.php' ) {
return $content;
}
$replaced = preg_replace(
'/\$adapter_class = "Ruckusing_Adapter_(MySQL|PgSQL|Sqlite3)_Base"/',
sprintf( '$adapter_class = "\%s\Ruckusing_Adapter_\\1_Base"', $prefix ),
$content
);
$replaced = str_replace(
"\set_error_handler(array('Ruckusing_Exception', 'errorHandler'), \E_ALL);",
sprintf( '\set_error_handler(array(\'\%s\Ruckusing_Exception\', \'errorHandler\'), \E_ALL);', $prefix ),
$replaced
);
$replaced = str_replace(
"\set_exception_handler(array('Ruckusing_Exception', 'exceptionHandler'));",
sprintf( '\set_exception_handler(array(\'\%s\Ruckusing_Exception\', \'exceptionHandler\'));', $prefix ),
$replaced
);
return $replaced;
},
/**
* Replaces a string reference to a class with the prefixed version.
*
* @param string $file_path The path of the current file.
* @param string $prefix The prefix to be used.
* @param string $content The content of the specific file.
*
* @return string The modified content.
*/
function( $file_path, $prefix, $content ) {
if ( substr( $file_path, -27 ) !== 'Ruckusing/Util/Migrator.php' ) {
return $content;
}
$replaced = str_replace(
'"Ruckusing_Util_Migrator"',
sprintf( '"\%s\Ruckusing_Util_Migrator"', $prefix ),
$content
);
return $replaced;
},
/**
* Prefixes the Namespace prefix define.
*
* @param string $file_path The path of the current file.
* @param string $prefix The prefix to be used.
* @param string $content The content of the specific file.
*
* @return string The modified content.
*/
function( $file_path, $prefix, $content ) {
if ( substr( $file_path, -25 ) !== 'Ruckusing/Util/Naming.php' ) {
return $content;
}
$replaced = str_replace(
'const CLASS_NS_PREFIX = \'Task_\'',
sprintf( 'const CLASS_NS_PREFIX = \'\%s\Task_\'', $prefix ),
$content
);
return $replaced;
},
/**
* Escapes the namespace for use in a regex match.
*
* @param string $file_path The path of the current file.
* @param string $prefix The prefix to be used.
* @param string $content The content of the specific file.
*
* @return string The modified content.
*/
function( $file_path, $prefix, $content ) {
if ( substr( $file_path, -25 ) !== 'Ruckusing/Util/Naming.php' ) {
return $content;
}
$replaced = str_replace(
'preg_match(\'/\' . self::CLASS_NS_PREFIX . \'/\'',
'preg_match(\'/\' . preg_quote(self::CLASS_NS_PREFIX) . \'/\'',
$content
);
return $replaced;
},
/**
* Prefix generally used defines.
*
* @param string $file_path The path of the current file.
* @param string $prefix The prefix to be used.
* @param string $content The content of the specific file.
*
* @return string The modified content.
*/
function( $file_path, $prefix, $content ) {
return str_replace(
array( 'define(\'', 'defined(\'' ),
array(
'define(__NAMESPACE__ . \'\\',
'defined(__NAMESPACE__ . \'\\',
),
$content
);
},
),
/*
* By default, PHP-Scoper only prefixes code where the namespace is non-global. In other words, non-namespaced
* code is not prefixed. This leaves the majority of classes, functions and constants in PHP - and most extensions,
* untouched.
*
* This is not necessarily a desirable outcome for vendor dependencies which are also not namespaced. To ensure
* they are isolated, you can configure the following which can be a list of strings or callables taking a string
* (the class name) as an argument and return a boolean (true meaning the class is going to prefixed).
*
* For more, see https://github.com/humbug/php-scoper#global-namespace-whitelisting
*/
'global_namespace_whitelist' => array(
/**
* @param string $class_name The class name that is being parsed.
*/
function( $class_name ) {
return strpos( $class_name, 'Ruckusing' ) === 0;
},
/**
* @param string $class_name The class name that is being parsed.
*/
function( $class_name ) {
return strpos( $class_name, 'Task_' ) === 0;
},
),
);
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment