Commit ac5488bd authored by Simon's avatar Simon

in progress

parent c2e69507
......@@ -48,6 +48,11 @@ class JsonDataCollector
'name' => 'type_name'
]
],
'member' => [
'slug' => 'manager_id',
'name' => 'manager_name',
'__primary' => true,
],
];
// Yoast SEO properties
......
......@@ -283,31 +283,35 @@ class Pods implements Iterator {
public function __construct( $pod = null, $id = null ) {
if ( null === $pod ) {
$queried_object = get_queried_object();
$pod = get_queried_object();
}
if ( $queried_object ) {
if ( $pod && ! is_string( $pod ) ) {
if ( $pod instanceof WP_Post ) {
// Post Type Singular.
$pod = $pod->post_type;
$id_lookup = true;
} elseif ( $pod instanceof WP_Term ) {
// Term Archive.
$pod = $pod->taxonomy;
$id_lookup = true;
} elseif ( $pod instanceof WP_User ) {
// Author Archive.
$pod = 'user';
$id_lookup = true;
} elseif ( $pod instanceof WP_Post_Type ) {
// Post Type Archive.
$pod = $pod->name;
$id_lookup = false;
} else {
// Unsupported pod object.
$pod = null;
$id_lookup = false;
}
if ( $queried_object instanceof WP_Post ) {
// Post Type Singular.
$pod = $queried_object->post_type;
} elseif ( $queried_object instanceof WP_Term ) {
// Term Archive.
$pod = $queried_object->taxonomy;
} elseif ( $queried_object instanceof WP_User ) {
// Author Archive.
$pod = 'user';
} elseif ( $queried_object instanceof WP_Post_Type ) {
// Post Type Archive.
$pod = $queried_object->name;
$id_lookup = false;
}
if ( null === $id && $id_lookup ) {
$id = get_queried_object_id();
}
}//end if
if ( null === $id && $id_lookup ) {
$id = get_queried_object_id();
}
}//end if
$this->api = pods_api( $pod );
......@@ -1062,6 +1066,37 @@ class Pods implements Iterator {
} else {
return null;
}
} elseif ( 'avatar' === $first_field && 'user' === $pod_type ) {
// User avatar.
$size = null;
$get_avatar = true;
if ( $is_traversal ) {
if ( $is_field_set ) {
// This is a registered field.
if ( isset( $traverse_fields[1] ) && is_numeric( $traverse_fields[1] ) ) {
$size = (int) $traverse_fields[1];
} else {
// Traverse through attachment post.
$get_avatar = false;
}
} else {
if ( isset( $traverse_fields[1] ) ) {
$size = (int) $traverse_fields[1];
}
}
}
if ( $get_avatar ) {
$object_field_found = true;
if ( 0 < $size ) {
$value = get_avatar( $this->id(), $size );
} else {
$value = get_avatar( $this->id() );
}
}
} elseif ( ! $is_field_set ) {
$image_fields = array(
......@@ -1075,26 +1110,7 @@ class Pods implements Iterator {
}
// Handle special field tags.
if ( 'avatar' === $first_field && 'user' === $pod_type ) {
$object_field_found = true;
// User avatar.
$size = null;
if ( 0 === strpos( $params->name, 'avatar.' ) ) {
$field_names = explode( '.', $params->name );
if ( isset( $field_names[1] ) ) {
$size = (int) $field_names[1];
}
}
if ( 0 < $size ) {
$value = get_avatar( $this->id(), $size );
} else {
$value = get_avatar( $this->id() );
}
} elseif ( in_array( $first_field, $image_fields, true ) ) {
if ( in_array( $first_field, $image_fields, true ) ) {
// Default image field handlers.
$object_field_found = true;
......@@ -1124,22 +1140,27 @@ class Pods implements Iterator {
}
if ( $attachment_id ) {
$is_image = wp_attachment_is_image( $attachment_id );
$size = 'thumbnail';
if ( isset( $traverse_params[0] ) ) {
$size = $traverse_params[0];
$sizes = get_intermediate_image_sizes();
// Not shown by default.
$sizes[] = 'full';
$sizes[] = 'original';
if ( ! in_array( $size, $sizes, true ) ) {
$size = $traverse_params[0];
if ( pods_is_image_size( $size ) ) {
// Force image request since a valid size parameter is passed.
$is_image = true;
} else {
// No valid image size found.
$size = false;
}
}
if ( $url ) {
$value = pods_image_url( $attachment_id, $size, 0, true );
if ( $is_image ) {
$value = pods_image_url( $attachment_id, $size, 0, true );
} else {
$value = wp_get_attachment_url( $attachment_id );
}
} elseif ( $size ) {
// Pods will auto-get the thumbnail ID if this isn't an attachment.
$value = pods_image( $attachment_id, $size, 0, null, true );
......@@ -1719,7 +1740,7 @@ class Pods implements Iterator {
// @todo Refactor the above condition statement.
$size = 'full';
if ( false === strpos( 'image', get_post_mime_type( $item_id ) ) ) {
if ( ! wp_attachment_is_image( $item_id ) ) {
// No default sizes for non-images.
// When a size is defined this will be overwritten.
$size = null;
......@@ -1734,7 +1755,7 @@ class Pods implements Iterator {
}
if ( $size ) {
$value_url = pods_image_url( $item_id, $size );
$value_url = pods_image_url( $item_id, $size, 0, true );
} else {
$value_url = wp_get_attachment_url( $item_id );
}
......@@ -1766,7 +1787,7 @@ class Pods implements Iterator {
$size = substr( $full_field, 5 );
}
$value[] = pods_image( $item_id, $size );
$value[] = pods_image( $item_id, $size, 0, array(), true );
$params->raw_display = true;
} elseif ( in_array( $field, array(
......@@ -4184,6 +4205,17 @@ class Pods implements Iterator {
$value = $this->display( $field_name );
}
// Process special magic tags but allow "empty" values for numbers.
if (
! $value
&& ! is_numeric( $value )
&& pods_shortcode_allow_evaluate_tags()
&& ! $this->fields( $field_name )
) {
// Do not pass before and after tags (key 2 and 3) or these get processed twice.
$value = pods_evaluate_tag( implode( ',', array_slice( $tag, 0, 2 ) ) );
}
if ( ! empty( $tag[2] ) ) {
$before = $tag[2];
}
......
......@@ -9254,7 +9254,7 @@ class PodsAPI {
return pods_error( __( 'Invalid submission', 'pods' ), $this );
}
$uid = @session_id();
$uid = pods_session_id();
if ( is_user_logged_in() ) {
$uid = 'user_' . get_current_user_id();
......
......@@ -573,6 +573,15 @@ class PodsAdmin {
if ( empty( $all_pods ) ) {
unset( $admin_menus['pods'] );
if ( 'pods' === pods_v( 'page', 'get' ) ) {
// Replace `pods` page param with first existing pod page and redirect.
$url = add_query_arg( 'page', key( $admin_menus ) );
$url = get_site_url( null, $url );
wp_safe_redirect( $url );
die();
}
}
add_filter( 'parent_file', array( $this, 'parent_file' ) );
......
......@@ -715,14 +715,7 @@ class PodsData {
// Debug purposes.
if ( ( 1 === (int) pods_v( 'pods_debug_sql', 'get', 0 ) || 1 === (int) pods_v( 'pods_debug_sql_all', 'get', 0 ) ) && pods_is_admin( array( 'pods' ) ) ) {
echo '<textarea cols="100" rows="24">' . esc_textarea(
str_replace(
array(
'@wp_users',
'@wp_',
), array( $wpdb->users, $wpdb->prefix ), $this->sql
)
) . '</textarea>';
echo '<textarea cols="100" rows="24">' . esc_textarea( $this->get_sql() ) . '</textarea>';
}
if ( empty( $this->sql ) ) {
......@@ -1806,7 +1799,9 @@ class PodsData {
$sql .= ' IF NOT EXISTS';
}
$sql .= " `{$wpdb->prefix}" . self::$prefix . "{$table}` ({$fields})";
$pods_prefix = self::get_pods_prefix();
$sql .= " `{$pods_prefix}{$table}` ({$fields})";
if ( ! empty( $wpdb->charset ) ) {
$sql .= " DEFAULT CHARACTER SET {$wpdb->charset}";
......@@ -1833,12 +1828,9 @@ class PodsData {
*/
public static function table_alter( $table, $changes ) {
/**
* @var $wpdb wpdb
*/
global $wpdb;
$pods_prefix = self::get_pods_prefix();
$sql = "ALTER TABLE `{$wpdb->prefix}" . self::$prefix . "{$table}` {$changes}";
$sql = "ALTER TABLE `{$pods_prefix}{$table}` {$changes}";
return self::query( $sql );
}
......@@ -1856,12 +1848,9 @@ class PodsData {
*/
public static function table_truncate( $table ) {
/**
* @var $wpdb wpdb
*/
global $wpdb;
$pods_prefix = self::get_pods_prefix();
$sql = "TRUNCATE TABLE `{$wpdb->prefix}" . self::$prefix . "{$table}`";
$sql = "TRUNCATE TABLE `{$pods_prefix}{$table}`";
return self::query( $sql );
}
......@@ -1881,12 +1870,9 @@ class PodsData {
*/
public static function table_drop( $table ) {
/**
* @var $wpdb wpdb
*/
global $wpdb;
$pods_prefix = self::get_pods_prefix();
$sql = "DROP TABLE `{$wpdb->prefix}" . self::$prefix . "{$table}`";
$sql = "DROP TABLE `{$pods_prefix}{$table}`";
return self::query( $sql );
}
......@@ -2201,7 +2187,7 @@ class PodsData {
if ( 'table' === $this->pod_data['storage'] && false !== $get_table_data && is_numeric( $current_row_id ) ) {
$params = array(
'table' => $wpdb->prefix . 'pods_',
'table' => self::get_pods_prefix(),
'where' => "`t`.`id` = {$current_row_id}",
'orderby' => '`t`.`id` DESC',
'page' => 1,
......@@ -2336,15 +2322,9 @@ class PodsData {
}
if ( 1 === (int) pods_v( 'pods_debug_sql_all', 'get', 0 ) && pods_is_admin( array( 'pods' ) ) ) {
echo '<textarea cols="100" rows="24">' . esc_textarea(
str_replace(
array(
'@wp_users',
'@wp_',
), array( $wpdb->users, $wpdb->prefix ), $params->sql
)
) . '</textarea>';
echo '<textarea cols="100" rows="24">' . esc_textarea( pods_data()->get_sql( $params->sql ) ) . '</textarea>';
}
}//end if
$params->sql = trim( $params->sql );
......@@ -2409,7 +2389,7 @@ class PodsData {
$finalTables = array();
foreach ( $showTables as $table ) {
if ( ! $pods_tables && 0 === ( strpos( $table[0], $wpdb->prefix . rtrim( self::$prefix, '_' ) ) ) ) {
if ( ! $pods_tables && 0 === ( strpos( $table[0], rtrim( self::get_pods_prefix(), '_' ) ) ) ) {
// don't include pods tables.
continue;
} elseif ( ! $wp_core && in_array( $table[0], $core_wp_tables, true ) ) {
......@@ -3055,7 +3035,14 @@ class PodsData {
if ( 0 === $traverse_recurse['depth'] && ! empty( $traverse_recurse['pod'] ) && ! empty( $traverse_recurse ['last_table_info'] ) && isset( $traverse_recurse ['last_table_info']['id'] ) ) {
$pod_data = $traverse_recurse ['last_table_info'];
} elseif ( empty( $traverse_recurse['pod'] ) ) {
if ( ! empty( $traverse_recurse['params'] ) && ! empty( $traverse_recurse['params']->table ) && 0 === strpos( $traverse_recurse['params']->table, $wpdb->prefix ) ) {
if (
! empty( $traverse_recurse['params'] )
&& ! empty( $traverse_recurse['params']->table )
&& (
! $wpdb->prefix // Make sure there is a prefix.
|| 0 === strpos( $traverse_recurse['params']->table, $wpdb->prefix )
)
) {
if ( $wpdb->posts === $traverse_recurse['params']->table ) {
$traverse_recurse['pod'] = 'post_type';
} elseif ( $wpdb->terms === $traverse_recurse['params']->table ) {
......@@ -3519,6 +3506,20 @@ class PodsData {
return pods_do_hook( 'data', $name, $args );
}
/**
* Get full prefix for Pods tables.
*
* @since 2.7.23
*
* @return string
*/
public static function get_pods_prefix() {
global $wpdb;
return $wpdb->prefix . self::$prefix;
}
/**
* Get the complete sql
*
......
......@@ -36,9 +36,7 @@ final class PodsI18n {
self::$instance = $this;
// Hook all enqueue scripts actions
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
add_action( 'login_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
add_action( 'pods_before_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
// Polylang
add_filter( 'pll_get_post_types', array( $this, 'pll_get_post_types' ), 10, 2 );
......@@ -102,7 +100,7 @@ final class PodsI18n {
self::register( $key, $str );
}
// Some other stuff we need to pass through
// Some other stuff we need to pass through.
$i18n_base = array(
'debug' => ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG == true ) ? true : false,
);
......@@ -146,6 +144,7 @@ final class PodsI18n {
return array(
// Translators: %s stands for a name/identifier.
'%s is required.' => __( '%s is required.', 'pods' ),
'This field is required.' => __( 'This field is required.', 'pods' ),
......@@ -176,6 +175,9 @@ final class PodsI18n {
'Search' => __( 'Search', 'pods' ),
// Translators: %s stands for a name/identifier.
'Search %s' => __( 'Search %s', 'pods' ),
'Navigating away from this page will discard any changes you have made.' => __( 'Navigating away from this page will discard any changes you have made.', 'pods' ),
'Some fields have changes that were not saved yet, please save them or cancel the changes before saving the Pod.' => __( 'Some fields have changes that were not saved yet, please save them or cancel the changes before saving the Pod.', 'pods' ),
......@@ -192,10 +194,18 @@ final class PodsI18n {
'You can only select' => __( 'You can only select', 'pods' ),
// Translators: %s stands for a number.
'%s item' => __( '%s item', 'pods' ),
// Translators: %s stands for a number.
'%s items' => __( '%s items', 'pods' ),
// Translators: %s stands for a number.
'You can only select %s item' => __( 'You can only select %s item', 'pods' ),
// Translators: %s stands for a number.
'You can only select %s items' => __( 'You can only select %s items', 'pods' ),
'Icon' => __( 'Icon', 'pods' ),
);
......
......@@ -476,7 +476,16 @@ class PodsInit {
*/
public function register_assets() {
$maybe_min = SCRIPT_DEBUG ? '' : '.min';
$suffix_min = SCRIPT_DEBUG ? '' : '.min';
/**
* Fires before Pods assets are registered.
*
* @since 2.7.23
*
* @param bool $suffix_min Minimized script suffix.
*/
do_action( 'pods_before_enqueue_scripts', $suffix_min );
wp_register_script( 'pods-json', PODS_URL . 'ui/js/jquery.json.js', array( 'jquery' ), '2.3' );
......@@ -485,13 +494,17 @@ class PodsInit {
}
wp_register_script(
'pods', PODS_URL . 'ui/js/jquery.pods.js', array(
'pods',
PODS_URL . 'ui/js/jquery.pods.js',
array(
'jquery',
'pods-dfv',
'pods-i18n',
'pods-json',
'jquery-qtip2',
), PODS_VERSION, true
),
PODS_VERSION,
true
);
wp_register_script( 'pods-cleditor', PODS_URL . 'ui/js/jquery.cleditor.min.js', array( 'jquery' ), '1.3.0' );
......@@ -504,69 +517,136 @@ class PodsInit {
wp_register_script( 'pods-codemirror-mode-html', PODS_URL . 'ui/js/codemirror/mode/htmlmixed/htmlmixed.js', array( 'pods-codemirror' ), '4.8', true );
wp_register_script( 'pods-codemirror-mode-css', PODS_URL . 'ui/js/codemirror/mode/css/css.js', array( 'pods-codemirror' ), '4.8', true );
// jQuery Timepicker.
if ( ! wp_script_is( 'jquery-ui-slideraccess', 'registered' ) ) {
// No need to add dependencies. All managed by jquery-ui-timepicker.
wp_register_script( 'jquery-ui-slideraccess', PODS_URL . 'ui/js/timepicker/jquery-ui-sliderAccess.js', array(), '0.3' );
}
if ( ! wp_script_is( 'jquery-ui-timepicker', 'registered' ) ) {
wp_register_script(
'jquery-ui-timepicker', PODS_URL . 'ui/js/timepicker/jquery-ui-timepicker-addon.min.js', array(
'jquery-ui-timepicker',
PODS_URL . "ui/js/timepicker/jquery-ui-timepicker-addon{$suffix_min}.js",
array(
'jquery',
'jquery-ui-core',
'jquery-ui-datepicker',
'jquery-ui-slider',
'jquery-ui-slideraccess',
), '1.6.3'
),
'1.6.3',
true
);
}
if ( ! wp_style_is( 'jquery-ui-timepicker', 'registered' ) ) {
wp_register_style( 'jquery-ui-timepicker', PODS_URL . 'ui/js/timepicker/jquery-ui-timepicker-addon.min.css', array(), '1.6.3' );
wp_register_style(
'jquery-ui-timepicker',
PODS_URL . "ui/js/timepicker/jquery-ui-timepicker-addon{$suffix_min}.css",
array(),
'1.6.3'
);
}
wp_register_script(
'pods-select2', PODS_URL . "ui/js/selectWoo/selectWoo{$maybe_min}.js", array(
'jquery',
'pods-i18n',
), '1.0.1'
// Select2/SelectWoo.
wp_register_style(
'pods-select2',
PODS_URL . "ui/js/selectWoo/selectWoo{$suffix_min}.css",
array(),
'1.0.2'
);
wp_register_style( 'pods-select2', PODS_URL . "ui/js/selectWoo/selectWoo{$maybe_min}.css", array(), '1.0.2' );
// Marionette dependencies for MV fields
wp_register_script( 'backbone.radio', PODS_URL . 'ui/js/marionette/backbone.radio.min.js', array( 'backbone' ), '2.0.0', true );
$select2_locale = function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
$select2_i18n = false;
if ( file_exists( PODS_DIR . "ui/js/selectWoo/i18n/{$select2_locale}.js" ) ) {
// `en_EN` format.
$select2_i18n = PODS_URL . "ui/js/selectWoo/i18n/{$select2_locale}.js";
} else {
// `en` format.
$select2_locale = substr( $select2_locale, 0, 2 );
if ( file_exists( PODS_DIR . "ui/js/selectWoo/i18n/{$select2_locale}.js" ) ) {
$select2_i18n = PODS_URL . "ui/js/selectWoo/i18n/{$select2_locale}.js";
}
}
if ( $select2_i18n ) {
wp_register_script(
'pods-select2-core',
PODS_URL . "ui/js/selectWoo/selectWoo{$suffix_min}.js",
array(
'jquery',
'pods-i18n',
),
'1.0.1',
true
);
wp_register_script( 'pods-select2', $select2_i18n, array( 'pods-select2-core' ), '1.0.1', true );
} else {
wp_register_script(
'pods-select2',
PODS_URL . "ui/js/selectWoo/selectWoo{$suffix_min}.js",
array(
'jquery',
'pods-i18n',
),
'1.0.1',
true
);
}
// Marionette dependencies for DFV/MV fields.
wp_register_script(
'backbone.radio',
PODS_URL . "ui/js/marionette/backbone.radio{$suffix_min}.js",
array( 'backbone' ),
'2.0.0',
true
);
wp_register_script(
'marionette',
PODS_URL . 'ui/js/marionette/backbone.marionette.min.js',
'pods-marionette',
PODS_URL . "ui/js/marionette/backbone.marionette{$suffix_min}.js",
array(
'backbone',
'backbone.radio',
), '3.3.1', true
),
'3.3.1',
true
);
wp_add_inline_script(
'marionette',
'pods-marionette',
'PodsMn = Backbone.Marionette.noConflict();'
);
// MV stuff
// DFV/MV.
wp_register_script(
'pods-dfv', PODS_URL . 'ui/js/pods-dfv/pods-dfv.min.js', array(
'pods-dfv', PODS_URL . 'ui/js/pods-dfv/pods-dfv.min.js',
array(
'jquery',
'jquery-ui-core',
'jquery-ui-sortable',
'pods-i18n',
'marionette',
'pods-marionette',
'media-views',
'media-models',
), PODS_VERSION, true
),
PODS_VERSION,
true
);
// Check if Pod is a Modal Window
// Page builders.
if (
// @todo Finish Elementor & Divi support.
// doing_action( 'elementor/editor/before_enqueue_scripts' ) || // Elementor.
// null !== pods_v( 'et_fb', 'get' ) // Divi.
null !== pods_v( 'fl_builder', 'get' ) // Beaver Builder.
) {
add_filter( 'pods_enqueue_dfv_on_front', '__return_true' );
}
// Check if Pod is a Modal Window.
if ( pods_is_modal_window() ) {
add_filter( 'body_class', array( $this, 'add_classes_to_modal_body' ) );
add_filter( 'admin_body_class', array( $this, 'add_classes_to_modal_body' ) );
}
// Deal with specifics on admin pages
// Deal with specifics on admin pages.
if ( is_admin() && function_exists( 'get_current_screen' ) ) {
$screen = get_current_screen();
......@@ -598,6 +678,15 @@ class PodsInit {
wp_enqueue_script( 'pods-dfv' );
wp_enqueue_style( 'pods-form' );
}
/**
* Fires after Pods assets are registered.
*
* @since 2.7.23
*
* @param bool $suffix_min Minimized script suffix.
*/
do_action( 'pods_after_enqueue_scripts', $suffix_min );
}
/**
......@@ -1875,6 +1964,8 @@ class PodsInit {
add_action( 'wp_enqueue_scripts', array( $this, 'register_assets' ), 15 );
add_action( 'admin_enqueue_scripts', array( $this, 'register_assets' ), 15 );
add_action( 'login_enqueue_scripts', array( $this, 'register_assets' ), 15 );
// @todo Elementor Page Builder.
//add_action( 'elementor/editor/before_enqueue_scripts', array( $this, 'register_assets' ), 15 );
add_filter( 'post_updated_messages', array( $this, 'setup_updated_messages' ), 10, 1 );
add_action( 'delete_attachment', array( $this, 'delete_attachment' ) );
......
......@@ -132,7 +132,8 @@ class PodsField_Avatar extends PodsField_File {
}
if ( ! empty( $avatar_field ) ) {
$user_avatar = get_user_meta( $user_id, $avatar_field . '.ID', true );
$user_meta = get_user_meta( $user_id );
$user_avatar = ! empty( $user_meta[ $avatar_field ][0] ) ? $user_meta[ $avatar_field ][0] : false;
if ( ! empty( $user_avatar ) ) {
$attributes = array(
......@@ -144,7 +145,7 @@ class PodsField_Avatar extends PodsField_File {
$attributes['alt'] = $alt;
}
$user_avatar = pods_image( $user_avatar, array( $size, $size ), 0, $attributes );
$user_avatar = pods_image( $user_avatar, array( $size, $size, 1 ), 0, $attributes, true );
if ( ! empty( $user_avatar ) ) {
$avatar = $user_avatar;
......
......@@ -459,8 +459,7 @@ class PodsField_File extends PodsField {
if ( $is_user_logged_in ) {
$uid = 'user_' . get_current_user_id();
} else {
// @codingStandardsIgnoreLine
$uid = @session_id();
$uid = pods_session_id();
}
$pod_id = '0';
......@@ -562,10 +561,10 @@ class PodsField_File extends PodsField {
$data[] = array(
'id' => esc_html( $id ),
'icon' => esc_attr( $icon ),
'name' => esc_html( wp_kses_post( html_entity_decode( $title ) ) ),
'edit_link' => esc_url( $edit_link ),
'link' => esc_url( $link ),
'download' => esc_url( $download ),
'name' => wp_strip_all_tags( html_entity_decode( $title ) ),
'edit_link' => html_entity_decode( esc_url( $edit_link ) ),
'link' => html_entity_decode( esc_url( $link ) ),
'download' => html_entity_decode( esc_url( $download ) ),
);
}//end foreach
......@@ -729,6 +728,10 @@ class PodsField_File extends PodsField {
*/
public function do_wp_gallery( $value, $options ) {
if ( ! $value ) {
return '';
}
$shortcode_args = array();
if ( ! empty( $options[ static::$type . '_wp_gallery_columns' ] ) ) {
......@@ -752,7 +755,7 @@ class PodsField_File extends PodsField {
} else {
$images = array();
foreach ( $value as $v ) {
foreach ( (array) $value as $v ) {
if ( ! is_array( $v ) ) {
$images[] = (int) $v;
} elseif ( isset( $v['ID'] ) ) {
......@@ -944,7 +947,7 @@ class PodsField_File extends PodsField {
}
}
$uid = @session_id();
$uid = pods_session_id();
if ( $is_user_logged_in ) {
$uid = 'user_' . get_current_user_id();
......@@ -1103,17 +1106,18 @@ class PodsField_File extends PodsField {
$limit_types = array_filter( array_unique( $limit_types ) );
if ( ! empty( $limit_types ) ) {
$ok = false;
$file_info = pathinfo( $file['name'] );
$ok = false;
foreach ( $limit_types as $limit_type ) {
$limit_type = '.' . trim( $limit_type, ' .' );
if ( isset( $file_info['extension'] ) ) {
foreach ( $limit_types as $limit_type ) {
$limit_type = trim( $limit_type, ' .' );
$pos = ( strlen( $file['name'] ) - strlen( $limit_type ) );
if ( $limit_type === $file_info['extension'] ) {
$ok = true;
if ( stripos( $file['name'], $limit_type ) === $pos ) {
$ok = true;
break;
break;
}
}
}
......
......@@ -940,7 +940,7 @@ class PodsField_Pick extends PodsField {
if ( is_user_logged_in() ) {
$uid = 'user_' . get_current_user_id();
} else {
$uid = @session_id();
$uid = pods_session_id();
}
$uri_hash = wp_create_nonce( 'pods_uri_' . $_SERVER['REQUEST_URI'] );
......@@ -1395,9 +1395,9 @@ class PodsField_Pick extends PodsField {
$item = array(
'id' => esc_html( $item_id ),
'icon' => esc_attr( $icon ),
'name' => esc_html( wp_kses_post( html_entity_decode( $item_title ) ) ),
'edit_link' => esc_url( $edit_link ),
'link' => esc_url( $link ),
'name' => wp_strip_all_tags( html_entity_decode( $item_title ) ),
'edit_link' => html_entity_decode( esc_url( $edit_link ) ),
'link' => html_entity_decode( esc_url( $link ) ),
'selected' => $selected,
);
......@@ -2131,6 +2131,8 @@ class PodsField_Pick extends PodsField {
$search_data = pods_data();
$search_data->table( $options['table_info'] );
$default_field_index = $search_data->field_index;
if ( isset( $options['table_info']['pod'] ) && ! empty( $options['table_info']['pod'] ) && isset( $options['table_info']['pod']['name'] ) ) {
$search_data->pod = $options['table_info']['pod']['name'];
$search_data->fields = $options['table_info']['pod']['fields'];
......@@ -2171,7 +2173,7 @@ class PodsField_Pick extends PodsField {
if ( isset( $options['table_info']['pod']['object_fields'] ) && isset( $options['table_info']['pod']['object_fields'][ $display ] ) ) {
$search_data->field_index = $display;
$params['select'] = "`t`.`{$search_data->field_id}`, `t`.`{$search_data->field_index}`";
$params['select'] .= ", `t`.`{$search_data->field_index}`";
} else {
$search_data->field_index = sanitize_key( $display );
......@@ -2182,17 +2184,17 @@ class PodsField_Pick extends PodsField {
), true
)
) {
$params['select'] = "`t`.`{$search_data->field_id}`, `d`.`{$search_data->field_index}`";
$params['select'] .= ", `d`.`{$search_data->field_index}`";
} elseif ( 'meta' === $options['table_info']['pod']['storage'] ) {
$params['select'] = "`t`.`{$search_data->field_id}`, `{$search_data->field_index}`.`meta_value` AS {$search_data->field_index}";
$params['select'] .= ", `{$search_data->field_index}`.`meta_value` AS {$search_data->field_index}";
} else {
$params['select'] = "`t`.`{$search_data->field_id}`, `t`.`{$search_data->field_index}`";
$params['select'] .= ", `t`.`{$search_data->field_index}`";
}
}//end if
} elseif ( isset( $options['table_info']['object_fields'] ) && isset( $options['table_info']['object_fields'][ $display ] ) ) {
$search_data->field_index = $display;
$params['select'] = "`t`.`{$search_data->field_id}`, `t`.`{$search_data->field_index}`";
$params['select'] .= ", `t`.`{$search_data->field_index}`";
}//end if
}//end if
......@@ -2334,6 +2336,10 @@ class PodsField_Pick extends PodsField {
$ids = wp_list_pluck( $ids, $search_data->field_id );
}
if ( $params['limit'] < count( $ids ) ) {
$params['limit'] = count( $ids );
}
if ( is_array( $ids ) ) {
$ids = implode( ', ', $ids );
}
......@@ -2342,7 +2348,7 @@ class PodsField_Pick extends PodsField {
$params['where'] = implode( ' AND ', $params['where'] );
}
if ( ! empty( $params['where'] ) ) {
$params['where'] .= ' AND ';
$params['where'] = '(' . $params['where'] . ') AND ';
}
$params['where'] .= "`t`.`{$search_data->field_id}` IN ( {$ids} )";
......@@ -2377,13 +2383,18 @@ class PodsField_Pick extends PodsField {
$display_filter = pods_v( 'display_filter', pods_v( 'options', pods_v( $search_data->field_index, $search_data->pod_data['object_fields'] ) ) );
foreach ( $results as $result ) {
$result = get_object_vars( $result );
$result = get_object_vars( $result );
$field_id = $search_data->field_id;
$field_index = $search_data->field_index;
if ( ! isset( $result[ $search_data->field_id ], $result[ $search_data->field_index ] ) ) {
if ( ! isset( $result[ $field_index ] ) ) {
$field_index = $default_field_index;
}
if ( ! isset( $result[ $field_id ], $result[ $field_index ] ) ) {
continue;
}
$result[ $search_data->field_index ] = trim( $result[ $search_data->field_index ] );
$result[ $field_index ] = trim( $result[ $field_index ] );
$object = '';
$object_type = '';
......@@ -2397,11 +2408,11 @@ class PodsField_Pick extends PodsField {
}
if ( 0 < strlen( $display_filter ) ) {
$display_filter_args = pods_v( 'display_filter_args', pods_v( 'options', pods_v( $search_data->field_index, $search_data->pod_data['object_fields'] ) ) );
$display_filter_args = pods_v( 'display_filter_args', pods_v( 'options', pods_v( $field_index, $search_data->pod_data['object_fields'] ) ) );
$filter_args = array(
$display_filter,
$result[ $search_data->field_index ],
$result[ $field_index ],
);
if ( ! empty( $display_filter_args ) ) {
......@@ -2412,22 +2423,22 @@ class PodsField_Pick extends PodsField {
}
}
$result[ $search_data->field_index ] = call_user_func_array( 'apply_filters', $filter_args );
$result[ $field_index ] = call_user_func_array( 'apply_filters', $filter_args );
}
if ( in_array( $options[ static::$type . '_object' ], array( 'site', 'network' ), true ) ) {
$result[ $search_data->field_index ] = $result[ $search_data->field_index ] . $result['path'];
} elseif ( '' === $result[ $search_data->field_index ] ) {
$result[ $search_data->field_index ] = '(No Title)';
$result[ $field_index ] = $result[ $field_index ] . $result['path'];
} elseif ( '' === $result[ $field_index ] ) {
$result[ $field_index ] = '(No Title)';
}
if ( 'admin_ajax_relationship' === $context ) {
$items[] = $this->build_dfv_field_item_data_recurse_item( $result[ $search_data->field_id ], $result[ $search_data->field_index ], (object) $object_params );
$items[] = $this->build_dfv_field_item_data_recurse_item( $result[ $field_id ], $result[ $field_index ], (object) $object_params );
} else {
$data[ $result[ $search_data->field_id ] ] = $result[ $search_data->field_index ];
$data[ $result[ $field_id ] ] = $result[ $field_index ];
}
$ids[] = $result[ $search_data->field_id ];
$ids[] = $result[ $field_id ];
}//end foreach
}//end if
}//end if
......@@ -2542,7 +2553,7 @@ class PodsField_Pick extends PodsField {
$params = (object) $params;
$uid = @session_id();
$uid = pods_session_id();
if ( is_user_logged_in() ) {
$uid = 'user_' . get_current_user_id();
......
......@@ -327,15 +327,28 @@ function frontier_do_subtemplate( $atts, $content ) {
}//end foreach
} elseif ( 'file' == $field['type'] && 'attachment' == $field['options']['file_uploader'] ) {
$template = frontier_decode_template( $content, $atts );
$template = frontier_decode_template( $content, $atts );
$media_pod = pods( 'media' );
foreach ( $entries as $key => $entry ) {
$content = str_replace( '{_index}', $key, $template );
$content = str_replace( '{@_img', '{@image_attachment.' . $entry['ID'], $content );
$content = str_replace( '{@_src', '{@image_attachment_url.' . $entry['ID'], $content );
$content = str_replace( '{@' . $field_name . '}', '{@image_attachment.' . $entry['ID'] . '}', $content );
$content = frontier_pseudo_magic_tags( $content, $entry, $pod, true );
$out .= pods_do_shortcode( $pod->do_magic_tags( $content ), frontier_get_shortcodes() );
if ( $media_pod && $media_pod->valid() && $media_pod->fetch( $entry['ID'] ) ) {
$content = str_replace( '{@' . $field_name . '.', '{@', $content );
$entry_pod = $media_pod;
} else {
// Fix for lowercase ID's.
$entry['id'] = $entry['ID'];
// Allow array-like tags.
$content = frontier_pseudo_magic_tags( $content, $entry, $pod, true );
// Fallback to parent Pod so above tags still work.
$entry_pod = $pod;
}
$out .= pods_do_shortcode( $entry_pod->do_magic_tags( $content ), frontier_get_shortcodes() );
}
} elseif ( isset( $field['table_info'], $field['table_info']['pod'] ) ) {
// Relationship to something that is extended by Pods
......@@ -372,7 +385,6 @@ function frontier_do_subtemplate( $atts, $content ) {
}
/**
*
* Search and replace like Pods magic tags but with an array of data instead of a Pod
*
* @param Pod $pod
......
This diff is collapsed.
......@@ -922,11 +922,17 @@ function pods_shortcode_run( $tags, $content = null ) {
// id > slug (if both exist)
$id = null;
$evaluate_tags_args = array(
'sanitize' => true,
'fallback' => null,
'use_current_pod' => true,
);
if ( ! empty( $tags['slug'] ) ) {
$id = $tags['slug'];
if ( pods_shortcode_allow_evaluate_tags() ) {
$id = pods_evaluate_tags( $id, true );
$id = pods_evaluate_tags( $id, $evaluate_tags_args );
}
}
......@@ -934,7 +940,7 @@ function pods_shortcode_run( $tags, $content = null ) {
$id = $tags['id'];
if ( pods_shortcode_allow_evaluate_tags() ) {
$id = pods_evaluate_tags( $id, true );
$id = pods_evaluate_tags( $id, $evaluate_tags_args );
}
if ( is_numeric( $id ) ) {
......@@ -964,6 +970,12 @@ function pods_shortcode_run( $tags, $content = null ) {
$params = array();
if ( ! defined( 'PODS_DISABLE_SHORTCODE_SQL' ) || ! PODS_DISABLE_SHORTCODE_SQL ) {
$evaluate_tags_args = array(
'sanitize' => true,
'fallback' => '""',
'use_current_pod' => true,
);
if ( 0 < strlen( $tags['orderby'] ) ) {
$params['orderby'] = $tags['orderby'];
}
......@@ -972,7 +984,7 @@ function pods_shortcode_run( $tags, $content = null ) {
$params['where'] = $tags['where'];
if ( pods_shortcode_allow_evaluate_tags() ) {
$params['where'] = pods_evaluate_tags( html_entity_decode( $params['where'] ), true, '""' );
$params['where'] = pods_evaluate_tags_sql( html_entity_decode( $params['where'] ), $evaluate_tags_args );
}
}
......@@ -980,7 +992,7 @@ function pods_shortcode_run( $tags, $content = null ) {
$params['having'] = $tags['having'];
if ( pods_shortcode_allow_evaluate_tags() ) {
$params['having'] = pods_evaluate_tags( html_entity_decode( $params['having'] ), true, '""' );
$params['having'] = pods_evaluate_tags_sql( html_entity_decode( $params['having'] ), $evaluate_tags_args );
}
}
......@@ -1052,7 +1064,15 @@ function pods_shortcode_run( $tags, $content = null ) {
return $pod->form( $tags['fields'], $tags['label'], $tags['thank_you'] );
} elseif ( ! empty( $tags['field'] ) ) {
if ( empty( $tags['helper'] ) ) {
if ( $tags['template'] || $content ) {
$return = '';
$related = $pod->field( $tags['field'], array( 'output' => 'find' ) );
if ( $related instanceof Pods && $related->valid() ) {
// Content is null by default.
$return .= $related->template( $tags['template'], $content );
}
} elseif ( empty( $tags['helper'] ) ) {
$return = $pod->display( $tags['field'] );
} else {
$return = $pod->helper( $tags['helper'], $pod->field( $tags['field'] ), $tags['field'] );
......@@ -2572,6 +2592,9 @@ function pods_session_start() {
} elseif ( defined( 'PODS_SESSION_AUTO_START' ) && ! PODS_SESSION_AUTO_START ) {
// Allow for bypassing Pods session autostarting.
return false;
} elseif ( function_exists( 'session_status' ) && PHP_SESSION_DISABLED === session_status() ) {
// Sessions are disabled.
return false;
} elseif ( 0 === strpos( $save_path, 'tcp://' ) ) {
// Allow for non-file based sessions, like Memcache.
// This is OK, but we don't want to check if file_exists on next statement.
......@@ -2580,10 +2603,16 @@ function pods_session_start() {
return false;
}
if ( '' !== session_id() ) {
// Check if session ID is already set.
// In separate if clause, to also check for non-file based sessions.
return false;
// Check if session is already set.
// In separate if clause, to also check for non-file based sessions.
if ( function_exists( 'session_status' ) ) { // PHP >=5.4.
if ( PHP_SESSION_ACTIVE === session_status() ) {
return false;
}
} else { // PHP <5.4.
if ( pods_session_id() ) {
return false;
}
}
// Start session
......@@ -2593,6 +2622,26 @@ function pods_session_start() {
}
/**
* Get current session ID.
*
* @since 2.7.23
*
* @return string
*/
function pods_session_id() {
if ( defined( 'PODS_SESSION_AUTO_START' ) && ! PODS_SESSION_AUTO_START ) {
return '';
}
if ( function_exists( 'session_status' ) && PHP_SESSION_DISABLED === session_status() ) {
// Sessions are disabled.
return '';
}
return @session_id();
}
/**
* @todo : replace string literal with a defined constant
*
......
This diff is collapsed.
......@@ -3,11 +3,12 @@
Plugin Name: Pods - Custom Content Types and Fields
Plugin URI: https://pods.io/
Description: Pods is a framework for creating, managing, and deploying customized content types and fields
Version: 2.7.22
Version: 2.7.24
Author: Pods Framework Team
Author URI: https://pods.io/about/
Text Domain: pods
GitHub Plugin URI: https://github.com/pods-framework/pods
Primary Branch: main
Copyright 2009-2019 Pods Foundation, Inc (email : contact@podsfoundation.org)
......@@ -36,7 +37,7 @@ if ( defined( 'PODS_VERSION' ) || defined( 'PODS_DIR' ) ) {
add_action( 'init', 'pods_deactivate_pods_ui' );
} else {
// Current version
define( 'PODS_VERSION', '2.7.22' );
define( 'PODS_VERSION', '2.7.24' );
// Version tracking between DB updates themselves
define( 'PODS_DB_VERSION', '2.3.5' );
......
......@@ -3,9 +3,9 @@ Contributors: sc0ttkclark, pglewis, jimtrue, keraweb, quasel, jamesgol, ramoonus
Donate link: https://pods.io/friends-of-pods/
Tags: pods, custom post types, custom taxonomies, content types, custom fields, cck, database, user fields, comment fields, media fields, relationships, drupal
Requires at least: 4.5
Tested up to: 5.5
Tested up to: 5.5.2
Requires PHP: 5.3
Stable tag: 2.7.22
Stable tag: 2.7.24
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
......@@ -190,6 +190,47 @@ We are also available through our [Live Slack Chat](https://pods.io/chat/) to he
== Changelog ==
= 2.7.24 - November 5th 2020 =
**Bug Fixes**
* Fixed: Fix media `[each]` loop if no `media` Pod exists. #5882 (@JoryHogeveen)
* Fixed: Fallback to default display field if custom option is invalid for relationship fields. #5839 & #5859 (@JoryHogeveen)
* Fixed: Use `pathinfo` to properly validate file extension. #5876 (@JoryHogeveen)
= 2.7.23 - October 30th 2020 =
**New Features & Enhancements**
* Added: Support auto-templates for taxonomies, users and comments. #3962 & #5832 (@JoryHogeveen, @sc0ttkclark, @gwhitney)
* Added: Support template parameter and nested shortcode content for field shortcodes. #5801 (@JoryHogeveen)
* Added: Allow function calls in all tags, not just template tags. #4887 (@JoryHogeveen)
* Added: Support custom image sizes for all image field types in magic tags. #5870 (@JoryHogeveen)
* Added/Fixed: Support special magic tags in Pods Templates. #5697 (@JoryHogeveen)
* Added/Fixed: Support Pod related magic tags in shortcode query parameters. #5734 (@JoryHogeveen)
* Enhancement: Allow traversing in avatar attachment. #5870 (@JoryHogeveen)
* Enhancement: If the media Pod exists, use it's context to run media loops to support other fields and traversal. #5855 (@JoryHogeveen)
* Enhancement: Implement PHP 5.4 `session_status()` function. #5840 (@JoryHogeveen)
* Enhancement: Allow WP objects to be passed in `pods()`. #5845 (@JoryHogeveen)
* Compatibility: Enqueue DFV scripts when editing the page with Beaver Builder to fully support the media window. #5799 (@JoryHogeveen)
* Updated: Primary Branch header for GitHub Updater. #5847 (@afragen)
**Bug Fixes**
* Fixed: `.src` tags for PDF's now render the PDF file link instead of the thumbnail in templates `[each]` loops. #4040 (@JoryHogeveen)
* Fixed. HTML entities for relationship fields UI. #5843, #5835 & #5796 (@JoryHogeveen, @sc0ttkclark)
* Fixed: Select2/SelectWoo now also enqueue the locale files when available. #5860 (@JoryHogeveen)
* Fixed: Support lowercase ID's for magic tags in media loops #5852 (@JoryHogeveen, @sc0ttkclark)
* Fixed: Avatar should always return a square image. #2738 (@JoryHogeveen)
* Fixed: Selected items query for autocomplete relationships. #5542 & #5831 (@JoryHogeveen)
* Fixed: Prevent SQL errors on magic tags in some cases. #5797 (@JoryHogeveen, @sc0ttkclark)
* Fixed: Error if there is no DB prefix available. #5803 (@JoryHogeveen, @sc0ttkclark)
* Fixed: Fix edge case "No Access" error when all Pods were deleted. Redirect to next Pod admin page if needed. #4842 (@JoryHogeveen)
* Fixed: Removed empty filter in `ui/admin/setup-edit-field.php`. #5686 (@sc0ttkclark, @JoryHogeveen)
* Fixed: Prevent possible notice if image doesn't exist. #5866 (@JoryHogeveen)
* Fixed: Remove source maps from production builds. #5822 (@sc0ttkclark)
* Fixed: PHP warning in file field gallery view. #5809 (@JoryHogeveen)
= 2.7.22 - August 13th 2020 =
**Bug Fixes**
......
......@@ -42,7 +42,7 @@ if ( ! isset( $thank_you_alt ) ) {
$uri_hash = wp_create_nonce( 'pods_uri_' . $_SERVER['REQUEST_URI'] );
$field_hash = wp_create_nonce( 'pods_fields_' . implode( ',', array_keys( $submittable_fields ) ) );
$uid = @session_id();
$uid = pods_session_id();
if ( is_user_logged_in() ) {
$uid = 'user_' . get_current_user_id();
......
......@@ -63,7 +63,7 @@ if ( ! isset( $thank_you_alt ) ) {
$uri_hash = wp_create_nonce( 'pods_uri_' . $_SERVER['REQUEST_URI'] );
$field_hash = wp_create_nonce( 'pods_fields_' . implode( ',', array_keys( $submittable_fields ) ) );
$uid = @session_id();
$uid = pods_session_id();
if ( is_user_logged_in() ) {
$uid = 'user_' . get_current_user_id();
......
......@@ -19,7 +19,7 @@ if ( 'pod' == pods_v( 'pick_object', $field ) ) {
}
}
$ignored_pick_objects = apply_filters( '', array( 'table' ) );
$ignored_pick_objects = array( 'table' );
if ( ! in_array( pods_v( 'pick_object', $field ), $ignored_pick_objects, true ) ) {
// Set pick object
......
......@@ -19,7 +19,7 @@ $css_id = $attributes['id'];
$uri_hash = wp_create_nonce( 'pods_uri_' . $_SERVER['REQUEST_URI'] );
$uid = @session_id();
$uid = pods_session_id();
if ( is_user_logged_in() ) {
$uid = 'user_' . get_current_user_id();
......
......@@ -50,7 +50,7 @@ foreach ( $submittable_fields as $k => $field ) {
$uri_hash = wp_create_nonce( 'pods_uri_' . $_SERVER[ 'REQUEST_URI' ] );
$field_hash = wp_create_nonce( 'pods_fields_' . implode( ',', array_keys( $submittable_fields ) ) );
$uid = @session_id();
$uid = pods_session_id();
if ( is_user_logged_in() ) {
$uid = 'user_' . get_current_user_id();
......
......@@ -329,9 +329,9 @@ export const SelectView = PodsMn.CollectionView.extend( {
// for regular autocomplete. This function should be generic and not have to poke around with
// special properties like this for exception cases.
if ( fieldConfig.limitDisable ) {
placeholder = `${PodsI18n.__( 'You can only select' )} ${sprintf( PodsI18n._n( '%s item', '%s items', limit ), limit )}`;
placeholder = `${sprintf( PodsI18n._n( 'You can only select %s item', 'You can only select %s items', limit ), limit )}`;
} else {
placeholder = `${PodsI18n.__( 'Search' )} ${fieldConfig.label}...`;
placeholder = `${sprintf( PodsI18n.__( 'Search %s' ), fieldConfig.label )}...`;
}
select2Options = {
......
......@@ -75,7 +75,7 @@ class PLL_Frontend_Static_Pages extends PLL_Static_Pages {
*/
public function translate_page_on_front( $v ) {
// Don't attempt to translate in a 'switch_blog' action as there is a risk to call this function while initializing the languages cache
return isset( $this->curlang->page_on_front ) && ! doing_action( 'switch_blog' ) ? $this->curlang->page_on_front : $v;
return isset( $this->curlang->page_on_front ) && ( $this->curlang->page_on_front ) && ! doing_action( 'switch_blog' ) ? $this->curlang->page_on_front : $v;
}
/**
......
......@@ -24,6 +24,11 @@ class PLL_Filters {
$this->options = &$polylang->options;
$this->curlang = &$polylang->curlang;
// Deletes our cache for sticky posts when the list is updated.
add_action( 'update_option_sticky_posts', array( $this, 'delete_sticky_posts_cache' ) );
add_action( 'add_option_sticky_posts', array( $this, 'delete_sticky_posts_cache' ) );
add_action( 'delete_option_sticky_posts', array( $this, 'delete_sticky_posts_cache' ) );
// Filters the comments according to the current language
add_action( 'parse_comment_query', array( $this, 'parse_comment_query' ) );
add_filter( 'comments_clauses', array( $this, 'comments_clauses' ), 10, 2 );
......@@ -55,6 +60,15 @@ class PLL_Filters {
add_filter( 'wp_privacy_personal_data_exporters', array( $this, 'register_personal_data_exporter' ), 0 ); // Since WP 4.9.6
}
/**
* Deletes the cache for multilingual sticky posts.
*
* @since 2.8.4
*/
public function delete_sticky_posts_cache() {
wp_cache_delete( 'sticky_posts', 'options' );
}
/**
* Get the language to filter a comments query
*
......
......@@ -103,7 +103,7 @@ class PLL_Static_Pages {
*/
public function translate_page_for_posts( $v ) {
// Don't attempt to translate in a 'switch_blog' action as there is a risk to call this function while initializing the languages cache
return isset( $this->curlang->page_for_posts ) && ! doing_action( 'switch_blog' ) ? $this->curlang->page_for_posts : $v;
return isset( $this->curlang->page_for_posts ) && ( $this->curlang->page_for_posts ) && ! doing_action( 'switch_blog' ) ? $this->curlang->page_for_posts : $v;
}
/**
......
......@@ -411,9 +411,11 @@ class PLL_WPSEO {
break;
case 'post-type-archive':
$presentation->model->permalink = get_post_type_archive_link( $presentation->model->object_sub_type );
$presentation->model->title = WPSEO_Options::get( 'title-ptarchive-' . $presentation->model->object_sub_type );
$presentation->model->description = WPSEO_Options::get( 'metadesc-ptarchive-' . $presentation->model->object_sub_type );
if ( pll_is_translated_post_type( $presentation->model->object_sub_type ) ) {
$presentation->model->permalink = get_post_type_archive_link( $presentation->model->object_sub_type );
$presentation->model->title = WPSEO_Options::get( 'title-ptarchive-' . $presentation->model->object_sub_type );
$presentation->model->description = WPSEO_Options::get( 'metadesc-ptarchive-' . $presentation->model->object_sub_type );
}
break;
case 'user':
......@@ -447,8 +449,10 @@ class PLL_WPSEO {
break;
case 'post-type-archive':
$indexable->permalink = get_post_type_archive_link( $indexable->object_sub_type );
$indexable->breadcrumb_title = pll__( WPSEO_Options::get( 'bctitle-ptarchive-' . $indexable->object_sub_type ) );
if ( pll_is_translated_post_type( $indexable->object_sub_type ) ) {
$indexable->permalink = get_post_type_archive_link( $indexable->object_sub_type );
$indexable->breadcrumb_title = pll__( WPSEO_Options::get( 'bctitle-ptarchive-' . $indexable->object_sub_type ) );
}
break;
}
}
......
......@@ -183,18 +183,23 @@ class PLL_Multilingual_Sitemaps_Provider extends WP_Sitemaps_Provider {
* @return string The composed URL for a sitemap entry.
*/
public function get_sitemap_url( $name, $page ) {
// Check if a language was added in $name.
$pattern = '#(' . implode( '|', $this->model->get_languages_list( array( 'fields' => 'slug' ) ) ) . ')$#';
if ( preg_match( $pattern, $name, $matches ) ) {
$lang = $this->model->get_language( $matches[1] );
$name = preg_replace( '#(-?' . $lang->slug . ')$#', '', $name );
$url = $this->provider->get_sitemap_url( $name, $page );
$url = $this->links_model->add_language_to_link( $url, $lang );
} else {
// Untranslated post types and taxonomies.
return $this->links_model->add_language_to_link( $url, $lang );
}
// If no language is present in $name, we may attempt to get the current sitemap url (e.g. in redirect_canonical() ).
if ( get_query_var( 'lang' ) ) {
$lang = $this->model->get_language( get_query_var( 'lang' ) );
$url = $this->provider->get_sitemap_url( $name, $page );
return $this->links_model->add_language_to_link( $url, $lang );
}
return $url;
return $this->provider->get_sitemap_url( $name, $page );
}
/**
......
......@@ -73,6 +73,7 @@ class PLL_Sitemaps {
add_filter( 'wp_sitemaps_index_entry', array( $this, 'index_entry' ) );
add_filter( 'wp_sitemaps_stylesheet_url', array( $this->links_model, 'site_url' ) );
add_filter( 'wp_sitemaps_stylesheet_index_url', array( $this->links_model, 'site_url' ) );
add_filter( 'home_url', array( $this, 'sitemap_url' ) );
}
}
......@@ -169,4 +170,19 @@ class PLL_Sitemaps {
$sitemap_entry['loc'] = $this->links_model->site_url( $sitemap_entry['loc'] );
return $sitemap_entry;
}
/**
* Makes sure that the sitemap urls are always evaluated on the current domain.
*
* @since 2.8.4
*
* @param string $url A sitemap url.
* @return string
*/
public function sitemap_url( $url ) {
if ( false !== strpos( $url, '/wp-sitemap' ) ) {
$url = $this->links_model->site_url( $url );
}
return $url;
}
}
......@@ -83,7 +83,7 @@ if ( ! function_exists( 'icl_get_languages' ) ) {
'missing' => empty( $url ) ? 1 : 0,
'translated_name' => '', // Does not exist in Polylang
'language_code' => $lang->slug,
'country_flag_url' => $lang->flag_url,
'country_flag_url' => $lang->get_display_flag_url(),
'url' => ! empty( $url ) ? $url :
( empty( $args['link_empty_to'] ) ? PLL()->links->get_home_url( $lang ) :
str_replace( '{$lang}', $lang->slug, $args['link_empty_to'] ) ),
......
......@@ -10,7 +10,7 @@
* Plugin Name: Polylang
* Plugin URI: https://polylang.pro
* Description: Adds multilingual capability to WordPress
* Version: 2.8.3
* Version: 2.8.4
* Requires at least: 4.9
* Requires PHP: 5.6
* Author: WP SYNTEX
......@@ -53,7 +53,7 @@ if ( defined( 'POLYLANG_VERSION' ) ) {
}
} else {
// Go on loading the plugin
define( 'POLYLANG_VERSION', '2.8.3' );
define( 'POLYLANG_VERSION', '2.8.4' );
define( 'PLL_MIN_WP_VERSION', '4.9' );
define( 'PLL_MIN_PHP_VERSION', '5.6' );
......
......@@ -5,7 +5,7 @@ Tags: multilingual, bilingual, translate, translation, language, multilanguage,
Requires at least: 4.9
Tested up to: 5.5
Requires PHP: 5.6
Stable tag: 2.8.3
Stable tag: 2.8.4
License: GPLv3 or later
License URI: https://www.gnu.org/licenses/gpl-3.0.html
......@@ -78,6 +78,16 @@ Don't hesitate to [give your feedback](http://wordpress.org/support/view/plugin-
== Changelog ==
= 2.8.4 (2020-11-03) =
* Pro: Remove useless bulk translate action for ACF fields groups
* Pro: Fix the translation of the CPTUI labels when the language is set from the content
* Fix sitemaps redirected to the default language since WP 5.5.1
* Fix object cache not flushed for sticky posts #601
* Fix blog page broken when trashing a page and the blog page is not translated in all languages
* Fix custom flags ignored in WPML compatibility mode
* Fix breadcrumb for untranslated post types in Yoast SEO
= 2.8.3 (2020-10-13) =
* Honor install_languages capability to download language packs
......
......@@ -60,7 +60,7 @@ class ClassLoader
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge', $this->prefixesPsr0);
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
}
return array();
......
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