Skip to content

Commit

Permalink
Merge branch 'development' into awesomemotive#1423
Browse files Browse the repository at this point in the history
  • Loading branch information
contactashish13 committed Feb 9, 2018
2 parents e87ce81 + 72bb77f commit f609288
Show file tree
Hide file tree
Showing 13 changed files with 260 additions and 86 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ rules:
# Best Practices
accessor-pairs: 2
block-scoped-var: 0
complexity: [2, 6]
complexity: 0
consistent-return: 0
curly: 0
default-case: 0
Expand Down
55 changes: 20 additions & 35 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,32 @@
language: php

notifications:
email:
on_success: never
on_failure: change

branches:
only:
- development

php:
- 5.3
- 5.6

env:
- WP_VERSION=latest WP_MULTISITE=0
- WP_VERSION=3.3 WP_MULTISITE=0
- WP_VERSION=4.5 WP_MULTISITE=0

matrix:
fast_finish: true
include:
- php: 7.2
- php: 7.1
- php: 7.0
env: WP_VERSION=master WP_MULTISITE=1 PHPLINT=1 PHPCS=1 CHECKJS=1 COVERAGE=1
- php: 5.2
env: WP_VERSION=4.5 WP_MULTISITE=1 PHPLINT=1
- php: 7.0
env: WP_VERSION=4.5
- php: 7.0
env: WP_VERSION=4.4
- php: 7.0
env: WP_VERSION=4.3
- php: 5.6
env: WP_VERSION=4.2
- php: 5.6
env: WP_VERSION=4.5
- php: 5.5
env: WP_VERSION=4.5
- php: 5.4
env: WP_VERSION=4.5
- php: 5.3
env: WP_VERSION=4.5
- php: hhvm
env: WP_VERSION=4.5
dist: precise
- php: 5.2
dist: precise
- env: WP_VERSION=latest
- env: WP_VERSION=4.0
- env: WP_MULTISITE=1
allow_failures:
- env: WP_MULTISITE=1

notifications:
email:
on_success: never
on_failure: change

branches:
except:
- "/^*-v[0-9]/"

before_script:
- bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
Expand Down
26 changes: 17 additions & 9 deletions admin/aioseop_module_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2190,15 +2190,16 @@ function get_option_html( $args ) {
return apply_filters( "{$prefix}output_option", '', $args );
}
if ( in_array( $options['type'], array(
'multiselect',
'select',
'multicheckbox',
'radio',
'checkbox',
'textarea',
'text',
'submit',
'hidden',
'multiselect',
'select',
'multicheckbox',
'radio',
'checkbox',
'textarea',
'text',
'submit',
'hidden',
'date',
) ) && is_string( $value )
) {
$value = esc_attr( $value );
Expand All @@ -2213,6 +2214,9 @@ function get_option_html( $args ) {
if ( isset( $opts['id'] ) ) {
$attr .= " id=\"{$opts['id']}\" ";
}
if ( isset( $options['required'] ) && true === $options['required'] ) {
$attr .= ' required';
}
switch ( $options['type'] ) {
case 'multiselect':
$attr .= ' MULTIPLE';
Expand Down Expand Up @@ -2249,6 +2253,10 @@ function get_option_html( $args ) {
case 'esc_html':
$buf .= "<pre>" . esc_html( $value ) . "</pre>\n";
break;
case 'date':
// firefox and IE < 11 do not have support for HTML5 date, so we will fall back to the datepicker.
wp_enqueue_script( 'jquery-ui-datepicker' );
// fall through.
default:
$buf .= "<input name='$name' type='{$options['type']}' $attr value='$value'>\n";
}
Expand Down
6 changes: 3 additions & 3 deletions aioseop_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1405,7 +1405,7 @@ function get_page_snippet_info() {
$url = apply_filters( 'aioseop_canonical_url', $url );
}
if ( ! $url ) {
$url = get_permalink();
$url = aioseop_get_permalink();
}

$title = $this->apply_cf_fields( $title );
Expand Down Expand Up @@ -2675,7 +2675,7 @@ function aiosp_mrt_get_url( $query, $show_page = true ) {
return false;
}
} elseif ( $query->is_home && ( get_option( 'show_on_front' ) == 'page' ) && ( $pageid = get_option( 'page_for_posts' ) ) ) {
$link = get_permalink( $pageid );
$link = aioseop_get_permalink( $pageid );
} elseif ( is_front_page() || ( $query->is_home && ( get_option( 'show_on_front' ) != 'page' || ! get_option( 'page_for_posts' ) ) ) ) {
if ( function_exists( 'icl_get_home_url' ) ) {
$link = icl_get_home_url();
Expand All @@ -2684,7 +2684,7 @@ function aiosp_mrt_get_url( $query, $show_page = true ) {
}
} elseif ( ( $query->is_single || $query->is_page ) && $haspost ) {
$post = $query->posts[0];
$link = get_permalink( $post->ID );
$link = aioseop_get_permalink( $post->ID );
} elseif ( $query->is_author && $haspost ) {
$author = get_userdata( get_query_var( 'author' ) );
if ( false === $author ) {
Expand Down
77 changes: 52 additions & 25 deletions inc/aioseop_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@
* @version 2.3.13
*/

if ( ! function_exists( 'aioseop_get_permalink' ) ) {
/**
* Support UTF8 URLs.
*
* @param int|object|null $post_id The post.
*/
function aioseop_get_permalink( $post_id = null ) {
if ( is_null( $post_id ) ) {
global $post;
$post_id = $post;
}

return urldecode( get_permalink( $post_id ) );
}
}

if ( ! function_exists( 'aioseop_load_modules' ) ) {
/**
* Load the module manager.
Expand Down Expand Up @@ -406,39 +422,50 @@ function aioseop_ajax_update_oembed() {
if ( ! function_exists( 'aioseop_ajax_save_url' ) ) {

function aioseop_ajax_save_url() {
$valid = true;
aioseop_ajax_init();
$options = Array();
parse_str( $_POST['options'], $options );
foreach ( $options as $k => $v ) {
// all values are mandatory while adding to the sitemap.
// this should work in the same way for news and video sitemaps too, but tackling only regular sitemaps for now.
if ( 'sitemap_addl_pages' === $_POST['settings'] && empty( $v ) ) {
$valid = false;
break;
}
$_POST[ $k ] = $v;
}
$_POST['action'] = 'aiosp_update_module';
global $aiosp, $aioseop_modules;
aioseop_load_modules();
$aiosp->admin_menu();
if ( ! empty( $_POST['settings'] ) && ( $_POST['settings'] === 'video_sitemap_addl_pages' ) ) {
$module = $aioseop_modules->return_module( 'All_in_One_SEO_Pack_Video_Sitemap' );
} elseif ( ! empty( $_POST['settings'] ) && ( $_POST['settings'] === 'news_sitemap_addl_pages' ) ) {
$module = $aioseop_modules->return_module( 'All_in_One_SEO_Pack_News_Sitemap' );
if ( $valid ) {
$_POST['action'] = 'aiosp_update_module';
global $aiosp, $aioseop_modules;
aioseop_load_modules();
$aiosp->admin_menu();
if ( ! empty( $_POST['settings'] ) && ( $_POST['settings'] === 'video_sitemap_addl_pages' ) ) {
$module = $aioseop_modules->return_module( 'All_in_One_SEO_Pack_Video_Sitemap' );
} elseif ( ! empty( $_POST['settings'] ) && ( $_POST['settings'] === 'news_sitemap_addl_pages' ) ) {
$module = $aioseop_modules->return_module( 'All_in_One_SEO_Pack_News_Sitemap' );
} else {
$module = $aioseop_modules->return_module( 'All_in_One_SEO_Pack_Sitemap' );
}
$_POST['location'] = null;
$_POST['Submit'] = 'ajax';
$module->add_page_hooks();
$prefix = $module->get_prefix();
$_POST = $module->get_current_options( $_POST, null );
$module->handle_settings_updates( null );
$options = $module->get_current_options( Array(), null );
$output = $module->display_custom_options( '', Array(
'name' => $prefix . 'addl_pages',
'type' => 'custom',
'save' => true,
'value' => $options[ $prefix . 'addl_pages' ],
'attr' => '',
) );
$output = str_replace( "'", "\'", $output );
$output = str_replace( "\n", '\n', $output );
} else {
$module = $aioseop_modules->return_module( 'All_in_One_SEO_Pack_Sitemap' );
$output = __( 'All values are mandatory.', 'all-in-one-seo-pack' );
}
$_POST['location'] = null;
$_POST['Submit'] = 'ajax';
$module->add_page_hooks();
$prefix = $module->get_prefix();
$_POST = $module->get_current_options( $_POST, null );
$module->handle_settings_updates( null );
$options = $module->get_current_options( Array(), null );
$output = $module->display_custom_options( '', Array(
'name' => $prefix . 'addl_pages',
'type' => 'custom',
'save' => true,
'value' => $options[ $prefix . 'addl_pages' ],
'attr' => '',
) );
$output = str_replace( "'", "\'", $output );
$output = str_replace( "\n", '\n', $output );
die( sprintf( AIOSEOP_AJAX_MSG_TMPL, $output ) );
}
}
Expand Down
14 changes: 14 additions & 0 deletions js/modules/aioseop_module.js
Original file line number Diff line number Diff line change
Expand Up @@ -708,3 +708,17 @@ jQuery( document ).ready(function() {
return false;
});
});


jQuery(document).ready( function() {
// TODO: consider moving EVERYTHING that needs ready() to this function
initAll(jQuery);
});

function initAll($){
if($('.aiseop-date').eq(0).prop('type').toLowerCase() === 'text'){
$('.aiseop-date').datepicker({
dateFormat: "yy-mm-dd"
});
}
}
8 changes: 4 additions & 4 deletions modules/aioseop_opengraph.php
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ function force_fb_refresh_transition( $new_status, $old_status, $post ) {

// Only ping Facebook if Social SEO is enabled on this post type.
if ( $this->option_isset( 'types' ) && is_array( $this->options['aiosp_opengraph_types'] ) && in_array( $current_post_type, $this->options['aiosp_opengraph_types'] ) ) {
$post_url = get_permalink( $post->ID );
$post_url = aioseop_get_permalink( $post->ID );
$endpoint = sprintf( 'https://graph.facebook.com/?%s', http_build_query( array(
'id' => $post_url,
'scrape' => true,
Expand All @@ -652,19 +652,19 @@ function force_fb_refresh_transition( $new_status, $old_status, $post ) {
/**
* Forces FaceBook OpenGraph refresh on update.
*
* @param $post_ID
* @param $post_id
* @param $post_after
*
* @see https://developers.facebook.com/docs/sharing/opengraph/using-objects#update
* @since 2.3.11
*/
function force_fb_refresh_update( $post_ID, $post_after ) {
function force_fb_refresh_update( $post_id, $post_after ) {

$current_post_type = get_post_type();

// Only ping Facebook if Social SEO is enabled on this post type.
if ( 'publish' === $post_after->post_status && $this->option_isset( 'types' ) && is_array( $this->options['aiosp_opengraph_types'] ) && in_array( $current_post_type, $this->options['aiosp_opengraph_types'] ) ) {
$post_url = get_permalink( $post_ID );
$post_url = aioseop_get_permalink( $post_id );
$endpoint = sprintf( 'https://graph.facebook.com/?%s', http_build_query( array(
'id' => $post_url,
'scrape' => true,
Expand Down
20 changes: 17 additions & 3 deletions modules/aioseop_sitemap.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ function __construct() {
'type' => 'text',
'label' => 'top',
'save' => false,
'required' => true,
),
'addl_prio' => array(
'name' => __( 'Page Priority', 'all-in-one-seo-pack' ),
Expand All @@ -248,9 +249,11 @@ function __construct() {
),
'addl_mod' => array(
'name' => __( 'Last Modified', 'all-in-one-seo-pack' ),
'type' => 'text',
'type' => 'date',
'label' => 'top',
'save' => false,
'class' => 'aiseop-date',
'required' => true,
),
'addl_pages' => array(
'name' => __( 'Additional Pages', 'all-in-one-seo-pack' ),
Expand Down Expand Up @@ -1248,6 +1251,8 @@ function sitemap_output_hook( $query ) {
// Always follow and noindex the sitemap.
header( 'X-Robots-Tag: noindex, follow', true );

do_action( $this->prefix . 'add_headers', $query, $this->options );

if ( $gzipped ) {
ob_start();
}
Expand Down Expand Up @@ -2727,6 +2732,7 @@ private function get_images_from_term( $term ) {
* @return array
*/
private function get_images_from_post( $post ) {
global $wp_version;

if ( ! aiosp_include_images() ) {
return array();
Expand Down Expand Up @@ -2756,8 +2762,16 @@ private function get_images_from_post( $post ) {
return $images;
}

$attached_url = false;
// Check featured image.
$attached_url = get_the_post_thumbnail_url( $post->ID );
if ( version_compare( $wp_version, '4.4.0', '>=' ) ) {
$attached_url = get_the_post_thumbnail_url( $post->ID );
} else {
$post_thumbnail_id = get_post_thumbnail_id( $post->ID );
if ( $post_thumbnail_id ) {
$attached_url = wp_get_attachment_image_src( $post_thumbnail_id );
}
}
if ( false !== $attached_url ) {
$images[] = $attached_url;
}
Expand Down Expand Up @@ -3084,7 +3098,7 @@ function get_permalink( $post ) {
$start = false;
}

return get_permalink( $post );
return aioseop_get_permalink( $post );
}

/**
Expand Down
3 changes: 1 addition & 2 deletions public/front.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,14 @@ public function noindex_follow_rss() {
* @since 2.3.9
*/
function redirect_attachment() {

global $aioseop_options;
if ( ! isset( $aioseop_options['aiosp_redirect_attachement_parent'] ) || $aioseop_options['aiosp_redirect_attachement_parent'] !== 'on' ) {
return false;
}

global $post;
if ( is_attachment() && ( ( is_object( $post ) && isset( $post->post_parent ) ) && ( is_numeric( $post->post_parent ) && $post->post_parent != 0 ) ) ) {
wp_safe_redirect( get_permalink( $post->post_parent ), 301 );
wp_safe_redirect( aioseop_get_permalink( $post->post_parent ), 301 );
exit;
}
}
Expand Down
2 changes: 1 addition & 1 deletion public/google-analytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function google_analytics() {
) ) {
$autotrack = apply_filters(
'aiosp_google_autotrack',
'https://cdnjs.cloudflare.com/ajax/libs/autotrack/2.4.0/autotrack.js'
AIOSEOP_PLUGIN_URL . 'public/js/autotrack.js'
);
?><script async src="<?php echo $autotrack ?>"></script>
<?php // Requested indent #921
Expand Down
Loading

0 comments on commit f609288

Please sign in to comment.