Skip to content

Commit

Permalink
Merge pull request #2536 from semperfiwebdesign/3.0
Browse files Browse the repository at this point in the history
3.0 to master
  • Loading branch information
michaeltorbert authored May 30, 2019
2 parents 1eb7452 + dc9a2cc commit 523cefc
Show file tree
Hide file tree
Showing 95 changed files with 9,201 additions and 3,603 deletions.
19 changes: 15 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ language: php
matrix:
fast_finish: true
global:
- env: PHPUNIT=global
- env: PHPUNIT=global GRUNT=no
include:
- php: 7.2
env: PHPUNIT=local
Expand All @@ -17,9 +17,13 @@ matrix:
dist: precise
- php: 5.2
dist: precise
- env: WP_VERSION=latest
- env: WP_VERSION=4.5
- env: WP_VERSION=latest PHPUNIT=local
- env: WP_VERSION=4.6 PHPUNIT=local
- env: WP_MULTISITE=1
- language: node_js
node_js:
- "8.11.3"
env: GRUNT=yes
allow_failures:
- env: WP_MULTISITE=1
- php: 5.3
Expand All @@ -38,8 +42,15 @@ branches:

install:
- if [[ $PHPUNIT = "local" ]]; then composer install; fi
- if [[ $GRUNT = "yes" && "$TRAVIS_PULL_REQUEST" != "false" ]]; then chmod +x bin/init-grunt.sh; . bin/init-grunt.sh; fi

before_script:
- bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION

script: if [[ $PHPUNIT = "local" ]]; then ./vendor/bin/phpunit; else phpunit; fi
script:
- if [[ $GRUNT = "yes" && "$TRAVIS_PULL_REQUEST" != "false" ]]; then grunt; fi
- if [[ $PHPUNIT = "local" ]]; then ./vendor/bin/phpunit; else phpunit; fi

after_failure:
- cat "logs/phpcs.log"
- cat "logs/jslogs.log"
2 changes: 1 addition & 1 deletion PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ _Put an `x` in the boxes that apply. You can also fill these out after creating
- Don't assume the tester knows the entire backstory of the issue, and don't force him/her to decipher the code to try and figure out what -it's doing or how to test it.
- Do provide step by step instructions on how to test.
- Do note things to watch out for.
- Do not what aspects the tester should try and break.
- Do note what aspects the tester should try and break.

## Further comments

Expand Down
156 changes: 76 additions & 80 deletions admin/aioseop_module_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,6 @@ function default_bad_bots() {
'EmailSiphon',
'EmailWolf',
'EroCrawler',
'Exabot',
'ExtractorPro',
'Fasterfox',
'FeedBooster',
Expand Down Expand Up @@ -839,7 +838,11 @@ function get_term_labels( $post_objs ) {
* @return array
*/
function get_post_type_titles( $args = array() ) {
return $this->get_object_labels( get_post_types( $args, 'objects' ) );
$object_labels = $this->get_object_labels( get_post_types( $args, 'objects' ) );
if ( isset( $object_labels['attachment'] ) ) {
$object_labels['attachment'] = __( 'Media / Attachments', 'all-in-one-seo-pack' );
}
return $object_labels;
}

/**
Expand All @@ -852,12 +855,19 @@ function get_taxonomy_titles( $args = array() ) {
}

/**
* @param array $args
* Gets the category titles.
*
* @since 3.0 Changed function name from `get_category_titles` to `get_term_titles`. (#240)
* @since 3.0 Changed `get_categories()` to `get_terms()` to fetch all (custom) terms. (#240)
*
* @see WP_Term_Query::__constructor()
* @link https://developer.wordpress.org/reference/classes/wp_term_query/__construct/
*
* @param array $args An array for arguments to query by. See WP_Term_Query::__constructor() for more info.
* @return array
*/
function get_category_titles( $args = array() ) {
return $this->get_term_labels( get_categories( $args ) );
function get_term_titles( $args = array() ) {
return $this->get_term_labels( get_terms( $args ) );
}

/**
Expand Down Expand Up @@ -1204,8 +1214,8 @@ function load_file( $filename, $use_include_path = false, $context = null, $offs
* @return bool
*/
function save_file( $filename, $contents ) {
$failed_str = sprintf( __( "Failed to write file %s!\n", 'all-in-one-seo-pack' ), $filename );
$readonly_str = sprintf( __( "File %s isn't writable!\n", 'all-in-one-seo-pack' ), $filename );
$failed_str = sprintf( __( 'Failed to write file %s!', 'all-in-one-seo-pack' ) . "\n", $filename );
$readonly_str = sprintf( __( 'File %s isn\'t writable!', 'all-in-one-seo-pack' ) . "\n", $filename );
$wpfs = $this->get_filesystem_object();
if ( is_object( $wpfs ) ) {
$file_exists = $wpfs->exists( $filename );
Expand Down Expand Up @@ -1235,12 +1245,12 @@ function delete_file( $filename ) {
if ( is_object( $wpfs ) ) {
if ( $wpfs->exists( $filename ) ) {
if ( $wpfs->delete( $filename ) === false ) {
$this->output_error( sprintf( __( "Failed to delete file %s!\n", 'all-in-one-seo-pack' ), $filename ) );
$this->output_error( sprintf( __( 'Failed to delete file %s!', 'all-in-one-seo-pack' ) . "\n", $filename ) );
} else {
return true;
}
} else {
$this->output_error( sprintf( __( "File %s doesn't exist!\n", 'all-in-one-seo-pack' ), $filename ) );
$this->output_error( sprintf( __( "File %s doesn't exist!", 'all-in-one-seo-pack' ) . "\n", $filename ) );
}
}

Expand All @@ -1262,15 +1272,15 @@ function rename_file( $filename, $newname ) {
$newfile_exists = $wpfs->exists( $newname );
if ( $file_exists && ! $newfile_exists ) {
if ( $wpfs->move( $filename, $newname ) === false ) {
$this->output_error( sprintf( __( "Failed to rename file %s!\n", 'all-in-one-seo-pack' ), $filename ) );
$this->output_error( sprintf( __( 'Failed to rename file %s!', 'all-in-one-seo-pack' ) . "\n", $filename ) );
} else {
return true;
}
} else {
if ( ! $file_exists ) {
$this->output_error( sprintf( __( "File %s doesn't exist!\n", 'all-in-one-seo-pack' ), $filename ) );
$this->output_error( sprintf( __( "File %s doesn't exist!", 'all-in-one-seo-pack' ) . "\n", $filename ) );
} elseif ( $newfile_exists ) {
$this->output_error( sprintf( __( "File %s already exists!\n", 'all-in-one-seo-pack' ), $newname ) );
$this->output_error( sprintf( __( 'File %s already exists!', 'all-in-one-seo-pack' ) . "\n", $newname ) );
}
}
}
Expand Down Expand Up @@ -1658,58 +1668,6 @@ function get_the_image_by_scan( $p = null ) {
return false;
}


/**
* @param $default_options
* @param $options
* @param string $help_link
*/
function help_text_helper( &$default_options, $options, $help_link = '' ) {
foreach ( $options as $o ) {
$ht = '';
if ( ! empty( $this->help_text[ $o ] ) ) {
$ht = $this->help_text[ $o ];
} elseif ( ! empty( $default_options[ $o ]['help_text'] ) ) {
$ht = $default_options[ $o ]['help_text'];
}
if ( $ht && ! is_array( $ht ) ) {
$ha = '';
$hl = $help_link;
if ( strpos( $o, 'ga_' ) === 0 ) { // special case -- pdb
$hl = 'https://semperplugins.com/documentation/advanced-google-analytics-settings/';
}
if ( ! empty( $this->help_anchors[ $o ] ) ) {
$ha = $this->help_anchors[ $o ];
}
if ( ! empty( $ha ) && ( $pos = strrpos( $hl, '#' ) ) ) {
$hl = substr( $hl, 0, $pos );
}
if ( ! empty( $ha ) && ( $ha[0] == 'h' ) ) {
$hl = '';
}
if ( ! empty( $ha ) || ! isset( $this->help_anchors[ $o ] ) ) {
$ht .= "<br /><a href='" . $hl . $ha . "' target='_blank'>" . __( 'Click here for documentation on this setting', 'all-in-one-seo-pack' ) . '</a>';
}
$default_options[ $o ]['help_text'] = $ht;
}
}
}

function add_help_text_links() {
if ( ! empty( $this->help_text ) ) {
foreach ( $this->layout as $k => $v ) {
$this->help_text_helper( $this->default_options, $v['options'], $v['help_link'] );
}
if ( ! empty( $this->locations ) ) {
foreach ( $this->locations as $k => $v ) {
if ( ! empty( $v['default_options'] ) && ! empty( $v['options'] ) ) {
$this->help_text_helper( $this->locations[ $k ]['default_options'], $v['options'], $v['help_link'] );
}
}
}
}
}

/**
* Load scripts and styles for metaboxes.
* edit-tags exists only for pre 4.5 support... remove when we drop 4.5 support.
Expand Down Expand Up @@ -1771,9 +1729,12 @@ function enqueue_metabox_scripts() {
* Add hook in \All_in_One_SEO_Pack_Module::add_page_hooks - Function itself is hooked based on the screen_id/page.
*
* @since 2.9
* @since 3.0 Added jQuery UI CSS missing from WP. #1850
*
* @see 'admin_enqueue_scripts' hook
* @link https://developer.wordpress.org/reference/hooks/admin_enqueue_scripts/
* @uses wp_scripts() Gets the Instance of WP Scripts.
* @link https://developer.wordpress.org/reference/functions/wp_scripts/
*
* @param string $hook_suffix
*/
Expand All @@ -1786,6 +1747,18 @@ function admin_enqueue_styles( $hook_suffix ) {
if ( function_exists( 'is_rtl' ) && is_rtl() ) {
wp_enqueue_style( 'aioseop-module-style-rtl', AIOSEOP_PLUGIN_URL . 'css/modules/aioseop_module-rtl.css', array( 'aioseop-module-style' ), AIOSEOP_VERSION );
}

// Uses WP Scripts to load the current platform version of jQuery UI CSS.
if ( ! wp_style_is( 'aioseop-jquery-ui', 'registered' ) && ! wp_style_is( 'aioseop-jquery-ui', 'enqueued' ) ) {
$wp_scripts = wp_scripts();
wp_enqueue_style(
'aioseop-jquery-ui',
'//ajax.googleapis.com/ajax/libs/jqueryui/' . $wp_scripts->registered['jquery-ui-core']->ver . '/themes/smoothness/jquery-ui.min.css',
false,
AIOSEOP_VERSION,
false
);
}
}

/**
Expand All @@ -1799,6 +1772,7 @@ function admin_enqueue_styles( $hook_suffix ) {
* @since ?
* @since 2.3.12.3 Add missing wp_enqueue_media.
* @since 2.9 Switch to admin_enqueue_scripts; both the hook and function name.
* @since 3.0 Add enqueue footer JS for jQuery UI Compatability. #1850
*
* @see 'admin_enqueue_scripts' hook
* @link https://developer.wordpress.org/reference/hooks/admin_enqueue_scripts/
Expand All @@ -1809,6 +1783,7 @@ function admin_enqueue_styles( $hook_suffix ) {
public function admin_enqueue_scripts( $hook_suffix ) {
wp_enqueue_script( 'sack' );
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'jquery-ui-tabs' );
wp_enqueue_script( 'media-upload' );
wp_enqueue_script( 'thickbox' );
wp_enqueue_script( 'common' );
Expand All @@ -1830,13 +1805,28 @@ public function admin_enqueue_scripts( $hook_suffix ) {
wp_enqueue_media();
}

$helper_dep = array(
'jquery',
'jquery-ui-core',
'jquery-ui-widget',
'jquery-ui-position',
'jquery-ui-tooltip',
);

// AIOSEOP Script enqueue.
wp_enqueue_script(
'aioseop-module-script',
AIOSEOP_PLUGIN_URL . 'js/modules/aioseop_module.js',
array(),
AIOSEOP_VERSION
);
wp_enqueue_script(
'aioseop-helper-js',
AIOSEOP_PLUGIN_URL . 'js/aioseop-helper.js',
$helper_dep,
AIOSEOP_VERSION,
true
);

// Localize aiosp_data in JS.
if ( ! empty( $this->script_data ) ) {
Expand Down Expand Up @@ -2351,7 +2341,7 @@ function get_option_html( $args ) {
$buf .= '<input class="aioseop_upload_image_checker" type="hidden" name="' . $name . '_checker" value="0">' .
"<input class='aioseop_upload_image_button button-primary' type='button' value='";
$buf .= __( 'Upload Image', 'all-in-one-seo-pack' );
$buf .= "' style='float:left;' />" .
$buf .= "' />" .
"<input class='aioseop_upload_image_label' name='" . esc_attr( $name ) . "' type='text' " . esc_html( $attr ) . " value='" . esc_attr( $value ) . "' size=57 style='float:left;clear:left;'>\n";
break;
case 'html':
Expand Down Expand Up @@ -2399,23 +2389,23 @@ function get_option_html( $args ) {
return $buf;
}

const DISPLAY_HELP_START = '<a class="aioseop_help_text_link" style="cursor:pointer;" title="%s" onclick="toggleVisibility(\'%s_tip\');"><label class="aioseop_label textinput">%s</label></a>';
const DISPLAY_HELP_END = '<div class="aioseop_help_text_div" style="display:none" id="%s_tip"><label class="aioseop_help_text">%s</label></div>';
const DISPLAY_LABEL_FORMAT = '<span class="aioseop_option_label" style="text-align:%s;vertical-align:top;">%s</span>';
const DISPLAY_TOP_LABEL = "</div>\n<div class='aioseop_input aioseop_top_label'>\n";
const DISPLAY_ROW_TEMPLATE = '<div class="aioseop_wrapper%s" id="%s_wrapper"><div class="aioseop_input">%s<span class="aioseop_option_input"><div class="aioseop_option_div" %s>%s</div>%s</span><p style="clear:left"></p></div></div>';

/**
* Format a row for an option on a settings page.
*
* @since ?
* @since 3.0 Added Helper Class for jQuery Tooltips. #1850
*
* @param $name
* @param $opts
* @param $args
*
* @return string
*/
function get_option_row( $name, $opts, $args ) {
$label_text = $input_attr = $help_text_2 = $id_attr = '';
$label_text = $input_attr = $id_attr = '';

require_once( AIOSEOP_PLUGIN_DIR . 'admin/class-aioseop-helper.php' );
$info = new AIOSEOP_Helper( get_class( $this ) );

$align = 'right';
if ( $opts['label'] == 'top' ) {
Expand All @@ -2425,22 +2415,28 @@ function get_option_row( $name, $opts, $args ) {
$id_attr .= " id=\"{$opts['id']}_div\" ";
}
if ( $opts['label'] != 'none' ) {
if ( isset( $opts['help_text'] ) ) {
$help_text = sprintf( All_in_One_SEO_Pack_Module::DISPLAY_HELP_START, __( 'Click for Help!', 'all-in-one-seo-pack' ), $name, $opts['name'] );
$help_text_2 = sprintf( All_in_One_SEO_Pack_Module::DISPLAY_HELP_END, $name, $opts['help_text'] );
$tmp_help_text = $info->get_help_text( $name );
if ( isset( $tmp_help_text ) && ! empty( $tmp_help_text ) ) {
$display_help = '<a class="aioseop_help_text_link" style="cursor: help;" title="%s"></a><label class="aioseop_label textinput">%s</label>';
$help_text = sprintf( $display_help, $info->get_help_text( $name ), $opts['name'] );
} else {
$help_text = $opts['name'];
}
$label_text = sprintf( All_in_One_SEO_Pack_Module::DISPLAY_LABEL_FORMAT, $align, $help_text );

// TODO Possible remove text align.
// Currently aligns to the right when everything is being aligned to the left; which is usually a workaround.
$display_label_format = '<span class="aioseop_option_label" style="text-align:%s;vertical-align:top;">%s</span>';
$label_text = sprintf( $display_label_format, $align, $help_text );
} else {
$input_attr .= ' aioseop_no_label ';
}
if ( $opts['label'] == 'top' ) {
$label_text .= All_in_One_SEO_Pack_Module::DISPLAY_TOP_LABEL;
$label_text .= "</div><div class='aioseop_input aioseop_top_label'>";
}
$input_attr .= " aioseop_{$opts['type']}_type";

return sprintf( All_in_One_SEO_Pack_Module::DISPLAY_ROW_TEMPLATE, $input_attr, $name, $label_text, $id_attr, $this->get_option_html( $args ), $help_text_2 );
$display_row_template = '<div class="aioseop_wrapper%s" id="%s_wrapper"><div class="aioseop_input">%s<span class="aioseop_option_input"><div class="aioseop_option_div" %s>%s</div></span><p style="clear:left"></p></div></div>';
return sprintf( $display_row_template, $input_attr, $name, $label_text, $id_attr, $this->get_option_html( $args ) );
}

/**
Expand Down Expand Up @@ -2741,12 +2737,12 @@ function display_settings_page( $location = null ) {
'page_options' => array( 'type' => 'hidden', 'value' => 'aiosp_home_description' ),
'Submit' => array(
'type' => 'submit',
'class' => 'button-primary',
'class' => 'aioseop_update_options_button button-primary',
'value' => __( 'Update Options', 'all-in-one-seo-pack' ) . ' &raquo;',
),
'Submit_Default' => array(
'type' => 'submit',
'class' => 'button-secondary',
'class' => 'aioseop_reset_settings_button button-secondary',
'value' => sprintf( __( 'Reset %s Settings to Defaults', 'all-in-one-seo-pack' ), $name ) . ' &raquo;',
),
);
Expand Down
Loading

0 comments on commit 523cefc

Please sign in to comment.