Commit 69abaeb5 authored by Simonas's avatar Simonas

Header phone LT updated

parent 83e7d371
...@@ -1843,6 +1843,9 @@ class Pods implements Iterator { ...@@ -1843,6 +1843,9 @@ class Pods implements Iterator {
if ( $last_options ) { if ( $last_options ) {
$last_field_data = $last_options; $last_field_data = $last_options;
} elseif ( isset( $related_obj, $related_obj->fields, $related_obj->fields[ $field ] ) ) {
// Save related field data for later to be used for display formatting
$last_field_data = $related_obj->fields[ $field ];
} }
break; break;
...@@ -1870,7 +1873,6 @@ class Pods implements Iterator { ...@@ -1870,7 +1873,6 @@ class Pods implements Iterator {
$field_data = $last_field_data; $field_data = $last_field_data;
} }
// @todo Expand this into traversed fields too.
if ( ! empty( $field_data ) && ( $params->display || ! $params->raw ) && ! $params->in_form && ! $params->raw_display ) { if ( ! empty( $field_data ) && ( $params->display || ! $params->raw ) && ! $params->in_form && ! $params->raw_display ) {
if ( $params->display || ( ( $params->get_meta || $params->deprecated ) && ! in_array( $field_data['type'], $tableless_field_types, true ) ) ) { if ( $params->display || ( ( $params->get_meta || $params->deprecated ) && ! in_array( $field_data['type'], $tableless_field_types, true ) ) ) {
$field_data['options'] = pods_v( 'options', $field_data, array(), true ); $field_data['options'] = pods_v( 'options', $field_data, array(), true );
......
...@@ -2890,7 +2890,7 @@ class PodsAPI { ...@@ -2890,7 +2890,7 @@ class PodsAPI {
if ( ( $field['type'] !== $old_type || $old_simple != $simple ) && empty( $definition ) ) { if ( ( $field['type'] !== $old_type || $old_simple != $simple ) && empty( $definition ) ) {
pods_query( "ALTER TABLE `@wp_pods_{$params->pod}` DROP COLUMN `{$old_name}`", false ); pods_query( "ALTER TABLE `@wp_pods_{$params->pod}` DROP COLUMN `{$old_name}`", false );
} elseif ( 0 < strlen( $definition ) ) { } elseif ( 0 < strlen( $definition ) ) {
if ( $old_name !== $field['name'] || $old_simple != $simple ) { if ( $old_name !== $field['name'] || $old_simple !== $simple || $old_definition !== $definition ) {
$test = false; $test = false;
if ( 0 < strlen( $old_definition ) ) { if ( 0 < strlen( $old_definition ) ) {
...@@ -3774,6 +3774,9 @@ class PodsAPI { ...@@ -3774,6 +3774,9 @@ class PodsAPI {
$custom = apply_filters( 'pods_form_ui_field_pick_custom_values', $custom, $field_data['name'], $value, array_merge( $field_data, $options ), $pod, $params->id ); $custom = apply_filters( 'pods_form_ui_field_pick_custom_values', $custom, $field_data['name'], $value, array_merge( $field_data, $options ), $pod, $params->id );
// Input values are unslashed. Unslash database values as well to ensure correct comparison.
$custom = pods_unslash( $custom );
if ( empty( $value ) || empty( $custom ) ) { if ( empty( $value ) || empty( $custom ) ) {
$value = ''; $value = '';
} elseif ( ! empty( $custom ) ) { } elseif ( ! empty( $custom ) ) {
...@@ -4891,13 +4894,13 @@ class PodsAPI { ...@@ -4891,13 +4894,13 @@ class PodsAPI {
$field = $pod->fields[ $field['name'] ]; $field = $pod->fields[ $field['name'] ];
$field['lookup_name'] = $field['name']; $field['lookup_name'] = $field['name'];
if ( in_array( $field['type'], $tableless_field_types ) && ! in_array( pods_var( 'pick_object', $field ), $simple_tableless_objects ) ) { if ( in_array( $field['type'], $tableless_field_types, true ) && ! in_array( pods_v( 'pick_object', $field ), $simple_tableless_objects, true ) ) {
if ( 'pick' === $field['type'] ) { if ( 'pick' === $field['type'] ) {
if ( empty( $field['table_info'] ) ) { if ( empty( $field['table_info'] ) ) {
$field['table_info'] = $this->get_table_info( pods_var_raw( 'pick_object', $field ), pods_var_raw( 'pick_val', $field ), null, null, $field ); $field['table_info'] = $this->get_table_info( pods_v( 'pick_object', $field ), pods_v( 'pick_val', $field ), null, null, $field );
} }
if ( ! empty( $field['table_info'] ) ) { if ( ! empty( $field['table_info'] ) && 'table' !== $field['table_info']['object_type'] ) {
$field['lookup_name'] .= '.' . $field['table_info']['field_id']; $field['lookup_name'] .= '.' . $field['table_info']['field_id'];
} }
} elseif ( in_array( $field['type'], PodsForm::file_field_types() ) ) { } elseif ( in_array( $field['type'], PodsForm::file_field_types() ) ) {
...@@ -6083,6 +6086,7 @@ class PodsAPI { ...@@ -6083,6 +6086,7 @@ class PodsAPI {
$pod = array( $pod = array(
'id' => 0, 'id' => 0,
'name' => $params->name, 'name' => $params->name,
'object' => $params->name,
'label' => __( 'Pods', 'pods' ), 'label' => __( 'Pods', 'pods' ),
'type' => 'post_type', 'type' => 'post_type',
'storage' => 'meta', 'storage' => 'meta',
...@@ -6095,6 +6099,7 @@ class PodsAPI { ...@@ -6095,6 +6099,7 @@ class PodsAPI {
$pod = array( $pod = array(
'id' => 0, 'id' => 0,
'name' => $params->name, 'name' => $params->name,
'object' => $params->name,
'label' => __( 'Pod Fields', 'pods' ), 'label' => __( 'Pod Fields', 'pods' ),
'type' => 'post_type', 'type' => 'post_type',
'storage' => 'meta', 'storage' => 'meta',
...@@ -8696,12 +8701,23 @@ class PodsAPI { ...@@ -8696,12 +8701,23 @@ class PodsAPI {
$info['table'] = ( empty( $object ) ? $name : $object ); $info['table'] = ( empty( $object ) ? $name : $object );
$info['pod_table'] = $wpdb->prefix . 'pods_' . $info['table']; $info['pod_table'] = $wpdb->prefix . 'pods_' . $info['table'];
if ( ! empty( $field ) && is_array( $field ) ) {
$info['table'] = pods_var_raw( 'pick_table', pods_var_raw( 'options', $field, $field ) ); if ( ! empty( $field ) ) {
$info['field_id'] = pods_var_raw( 'pick_table_id', pods_var_raw( 'options', $field, $field ) ); if ( ! is_array( $field ) ) {
$info['meta_field_value'] = pods_var_raw( 'pick_table_index', pods_var_raw( 'options', $field, $field ) ); if ( is_string( $pod ) ) {
$info['field_index'] = $info['meta_field_value']; $pod = pods( $pod );
$info['meta_field_index'] = $info['meta_field_value']; }
if ( $pod && ! empty( $pod->fields[ $field ] ) ) {
$field = $pod->fields[ $field ];
}
}
if ( is_array( $field ) ) {
$info['table'] = pods_var_raw( 'pick_table', pods_var_raw( 'options', $field, $field ) );
$info['field_id'] = pods_var_raw( 'pick_table_id', pods_var_raw( 'options', $field, $field ) );
$info['meta_field_value'] = pods_var_raw( 'pick_table_index', pods_var_raw( 'options', $field, $field ) );
$info['field_index'] = $info['meta_field_value'];
$info['meta_field_index'] = $info['meta_field_value'];
}
} }
} }
......
...@@ -43,7 +43,7 @@ class PodsAdmin { ...@@ -43,7 +43,7 @@ class PodsAdmin {
add_action( 'admin_init', array( $this, 'admin_init' ), 9 ); add_action( 'admin_init', array( $this, 'admin_init' ), 9 );
// Menus // Menus
add_action( 'admin_menu', array( $this, 'admin_menu' ), 99 ); add_action( 'admin_menu', array( $this, 'admin_menu' ), 9 );
// AJAX for Admin // AJAX for Admin
add_action( 'wp_ajax_pods_admin', array( $this, 'admin_ajax' ) ); add_action( 'wp_ajax_pods_admin', array( $this, 'admin_ajax' ) );
...@@ -3641,106 +3641,110 @@ class PodsAdmin { ...@@ -3641,106 +3641,110 @@ class PodsAdmin {
'label' => 'Pods', 'label' => 'Pods',
'description' => __( 'Debug information for Pods installations.', 'pods' ), 'description' => __( 'Debug information for Pods installations.', 'pods' ),
'fields' => array( 'fields' => array(
'pods-server-software' => array( 'pods-server-software' => array(
'label' => __( 'Server Software', 'pods' ), 'label' => __( 'Server Software', 'pods' ),
'value' => ! empty( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : 'N/A', 'value' => ! empty( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : 'N/A',
), ),
'pods-user-agent' => array( 'pods-user-agent' => array(
'label' => __( 'Your User Agent', 'pods' ), 'label' => __( 'Your User Agent', 'pods' ),
'value' => ! empty( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : 'N/A', 'value' => ! empty( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : 'N/A',
), ),
'pods-session-save-path' => array( 'pods-session-save-path' => array(
'label' => __( 'Session Save Path', 'pods' ), 'label' => __( 'Session Save Path', 'pods' ),
'value' => session_save_path(), 'value' => session_save_path(),
), ),
'pods-session-save-path-exists' => array( 'pods-session-save-path-exists' => array(
'label' => __( 'Session Save Path Exists', 'pods' ), 'label' => __( 'Session Save Path Exists', 'pods' ),
'value' => file_exists( session_save_path() ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ), 'value' => file_exists( session_save_path() ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ),
), ),
'pods-session-save-path-writable' => array( 'pods-session-save-path-writable' => array(
'label' => __( 'Session Save Path Writeable', 'pods' ), 'label' => __( 'Session Save Path Writeable', 'pods' ),
'value' => is_writable( session_save_path() ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ), 'value' => is_writable( session_save_path() ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ),
), ),
'pods-session-max-lifetime' => array( 'pods-session-max-lifetime' => array(
'label' => __( 'Session Max Lifetime', 'pods' ), 'label' => __( 'Session Max Lifetime', 'pods' ),
'value' => ini_get( 'session.gc_maxlifetime' ), 'value' => ini_get( 'session.gc_maxlifetime' ),
), ),
'pods-opcode-cache-apc' => array( 'pods-opcode-cache-apc' => array(
'label' => __( 'Opcode Cache: Apc', 'pods' ), 'label' => __( 'Opcode Cache: Apc', 'pods' ),
'value' => function_exists( 'apc_cache_info' ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ), 'value' => function_exists( 'apc_cache_info' ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ),
), ),
'pods-opcode-cache-memcached' => array( 'pods-opcode-cache-memcached' => array(
'label' => __( 'Opcode Cache: Memcached', 'pods' ), 'label' => __( 'Opcode Cache: Memcached', 'pods' ),
'value' => class_exists( 'eaccelerator_put' ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ), 'value' => class_exists( 'eaccelerator_put' ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ),
), ),
'pods-opcode-cache-opcache' => array( 'pods-opcode-cache-opcache' => array(
'label' => __( 'Opcode Cache: OPcache', 'pods' ), 'label' => __( 'Opcode Cache: OPcache', 'pods' ),
'value' => function_exists( 'opcache_get_status' ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ), 'value' => function_exists( 'opcache_get_status' ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ),
), ),
'pods-opcode-cache-redis' => array( 'pods-opcode-cache-redis' => array(
'label' => __( 'Opcode Cache: Redis', 'pods' ), 'label' => __( 'Opcode Cache: Redis', 'pods' ),
'value' => class_exists( 'xcache_set' ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ), 'value' => class_exists( 'xcache_set' ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ),
), ),
'pods-object-cache-apc' => array( 'pods-object-cache-apc' => array(
'label' => __( 'Object Cache: APC', 'pods' ), 'label' => __( 'Object Cache: APC', 'pods' ),
'value' => function_exists( 'apc_cache_info' ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ), 'value' => function_exists( 'apc_cache_info' ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ),
), ),
'pods-object-cache-apcu' => array( 'pods-object-cache-apcu' => array(
'label' => __( 'Object Cache: APCu', 'pods' ), 'label' => __( 'Object Cache: APCu', 'pods' ),
'value' => function_exists( 'apcu_cache_info' ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ), 'value' => function_exists( 'apcu_cache_info' ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ),
), ),
'pods-object-cache-memcache' => array( 'pods-object-cache-memcache' => array(
'label' => __( 'Object Cache: Memcache', 'pods' ), 'label' => __( 'Object Cache: Memcache', 'pods' ),
'value' => class_exists( 'Memcache' ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ), 'value' => class_exists( 'Memcache' ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ),
), ),
'pods-object-cache-memcached' => array( 'pods-object-cache-memcached' => array(
'label' => __( 'Object Cache: Memcached', 'pods' ), 'label' => __( 'Object Cache: Memcached', 'pods' ),
'value' => class_exists( 'Memcached' ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ), 'value' => class_exists( 'Memcached' ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ),
), ),
'pods-object-cache-redis' => array( 'pods-object-cache-redis' => array(
'label' => __( 'Object Cache: Redis', 'pods' ), 'label' => __( 'Object Cache: Redis', 'pods' ),
'value' => class_exists( 'Redis' ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ), 'value' => class_exists( 'Redis' ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ),
), ),
'pods-memory-current-usage' => array( 'pods-memory-current-usage' => array(
'label' => __( 'Current Memory Usage', 'pods' ), 'label' => __( 'Current Memory Usage', 'pods' ),
'value' => number_format_i18n( memory_get_usage() / 1024 / 1024, 3 ) . 'M', 'value' => number_format_i18n( memory_get_usage() / 1024 / 1024, 3 ) . 'M',
), ),
'pods-memory-current-usage-real' => array( 'pods-memory-current-usage-real' => array(
'label' => __( 'Current Memory Usage (real)', 'pods' ), 'label' => __( 'Current Memory Usage (real)', 'pods' ),
'value' => number_format_i18n( memory_get_usage( true ) / 1024 / 1024, 3 ) . 'M', 'value' => number_format_i18n( memory_get_usage( true ) / 1024 / 1024, 3 ) . 'M',
), ),
'pods-network-wide' => array( 'pods-network-wide' => array(
'label' => __( 'Pods Network-Wide Activated', 'pods' ), 'label' => __( 'Pods Network-Wide Activated', 'pods' ),
'value' => is_plugin_active_for_network( basename( PODS_DIR ) . '/init.php' ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ), 'value' => is_plugin_active_for_network( basename( PODS_DIR ) . '/init.php' ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ),
), ),
'pods-install-location' => array( 'pods-install-location' => array(
'label' => __( 'Pods Install Location', 'pods' ), 'label' => __( 'Pods Install Location', 'pods' ),
'value' => PODS_DIR, 'value' => PODS_DIR,
), ),
'pods-developer' => array( 'pods-developer' => array(
'label' => __( 'Pods Developer Activated' ), 'label' => __( 'Pods Developer Activated' ),
'value' => ( pods_developer() ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ), 'value' => ( pods_developer() ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ),
), ),
'pods-tableless-mode' => array( 'pods-tableless-mode' => array(
'label' => __( 'Pods Tableless Mode Activated', 'pods' ), 'label' => __( 'Pods Tableless Mode Activated', 'pods' ),
'value' => ( pods_tableless() ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ), 'value' => ( pods_tableless() ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ),
), ),
'pods-light-mode' => array( 'pods-light-mode' => array(
'label' => __( 'Pods Light Mode Activated', 'pods' ), 'label' => __( 'Pods Light Mode Activated', 'pods' ),
'value' => ( pods_light() ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ), 'value' => ( pods_light() ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ),
), ),
'pods-strict' => array( 'pods-strict' => array(
'label' => __( 'Pods Strict Activated' ), 'label' => __( 'Pods Strict Activated' ),
'value' => ( pods_strict() ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ), 'value' => ( pods_strict() ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ),
), ),
'pods-allow-deprecated' => array( 'pods-allow-deprecated' => array(
'label' => __( 'Pods Allow Deprecated' ), 'label' => __( 'Pods Allow Deprecated' ),
'value' => ( pods_allow_deprecated() ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ), 'value' => ( pods_allow_deprecated() ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ),
), ),
'pods-api-cache' => array( 'pods-api-cache' => array(
'label' => __( 'Pods API Cache Activated' ), 'label' => __( 'Pods API Cache Activated' ),
'value' => ( pods_api_cache() ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ), 'value' => ( pods_api_cache() ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ),
), ),
'pods-shortcode-allow-evaluate-tags' => array(
'label' => __( 'Pods Shortcode Allow Evaluate Tags' ),
'value' => ( pods_shortcode_allow_evaluate_tags() ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ),
),
), ),
); );
......
...@@ -344,8 +344,8 @@ class PodsInit { ...@@ -344,8 +344,8 @@ class PodsInit {
// Check if Pod is a Modal Window // Check if Pod is a Modal Window
if ( pods_is_modal_window() ) { if ( pods_is_modal_window() ) {
add_filter( 'body_class', array( $this, 'add_classes_to_body_class' ) ); add_filter( 'body_class', array( $this, 'add_classes_to_modal_body' ) );
add_filter( 'admin_body_class', array( $this, 'add_classes_to_body_class' ) ); add_filter( 'admin_body_class', array( $this, 'add_classes_to_modal_body' ) );
} }
// Deal with specifics on admin pages // Deal with specifics on admin pages
...@@ -406,13 +406,17 @@ class PodsInit { ...@@ -406,13 +406,17 @@ class PodsInit {
} }
/** /**
* @param string $classes Body classes. * @param string|array $classes Body classes.
* *
* @return string * @return string|array
*/ */
public function add_classes_to_body_class( $classes ) { public function add_classes_to_modal_body( $classes ) {
$classes .= 'pods-modal-window'; if ( is_array( $classes ) ) {
$classes[] = 'pods-modal-window';
} else {
$classes .= ' pods-modal-window';
}
return $classes; return $classes;
} }
...@@ -1872,6 +1876,7 @@ class PodsInit { ...@@ -1872,6 +1876,7 @@ class PodsInit {
$conditionals[] = 'pods_strict'; $conditionals[] = 'pods_strict';
$conditionals[] = 'pods_allow_deprecated'; $conditionals[] = 'pods_allow_deprecated';
$conditionals[] = 'pods_api_cache'; $conditionals[] = 'pods_api_cache';
$conditionals[] = 'pods_shortcode_allow_evaluate_tags';
return $conditionals; return $conditionals;
} }
} }
...@@ -4634,6 +4634,9 @@ class PodsUI { ...@@ -4634,6 +4634,9 @@ class PodsUI {
'filter_*', 'filter_*',
'view' . $this->num, 'view' . $this->num,
'page' . $this->num, 'page' . $this->num,
'post_type',
'taxonomy',
'action' . $this->num,
), $this->exclusion() ), $this->exclusion()
); );
...@@ -4653,9 +4656,21 @@ class PodsUI { ...@@ -4653,9 +4656,21 @@ class PodsUI {
if ( false !== $this->pagination ) { if ( false !== $this->pagination ) {
if ( 1 < $total_pages ) { if ( 1 < $total_pages ) {
$first_link = esc_url( $request_uri . ( $append ? '&' : '?' ) . 'pg' . $this->num . '=1' );
$prev_link = esc_url( $request_uri . ( $append ? '&' : '?' ) . 'pg' . $this->num . '=' . max( $this->page - 1, 1 ) );
$next_link = esc_url( $request_uri . ( $append ? '&' : '?' ) . 'pg' . $this->num . '=' . min( $this->page + 1, $total_pages ) );
$last_link = esc_url( $request_uri . ( $append ? '&' : '?' ) . 'pg' . $this->num . '=' . $total_pages );
$classes = '';
if ( 1 >= $this->page ) {
$classes .= ' disabled';
}
if ( is_admin() ) {
$classes .= ' button';
}
?> ?>
<a class="first-page<?php echo esc_attr( ( 1 < $this->page ) ? '' : ' disabled' ); ?>" title="<?php esc_attr_e( 'Go to the first page', 'pods' ); ?>" href="<?php echo esc_url( $request_uri . ( $append ? '&' : '?' ) . 'pg' . $this->num . '=1' ); ?>">&laquo;</a> <a class="first-page<?php echo esc_attr( $classes ); ?>" title="<?php esc_attr_e( 'Go to the first page', 'pods' ); ?>" href="<?php echo $first_link; ?>">&laquo;</a>
<a class="prev-page<?php echo esc_attr( ( 1 < $this->page ) ? '' : ' disabled' ); ?>" title="<?php esc_attr_e( 'Go to the previous page', 'pods' ); ?>" href="<?php echo esc_url( $request_uri . ( $append ? '&' : '?' ) . 'pg' . $this->num . '=' . max( $this->page - 1, 1 ) ); ?>">&lsaquo;</a> <a class="prev-page<?php echo esc_attr( $classes ); ?>" title="<?php esc_attr_e( 'Go to the previous page', 'pods' ); ?>" href="<?php echo $prev_link; ?>">&lsaquo;</a>
<?php <?php
if ( true == $header ) { if ( true == $header ) {
?> ?>
...@@ -4680,9 +4695,16 @@ class PodsUI { ...@@ -4680,9 +4695,16 @@ class PodsUI {
<span class="total-pages"><?php echo number_format_i18n( $total_pages ); ?></span></span> <span class="total-pages"><?php echo number_format_i18n( $total_pages ); ?></span></span>
<?php <?php
}//end if }//end if
$classes = '';
if ( $this->page >= $total_pages ) {
$classes .= ' disabled';
}
if ( is_admin() ) {
$classes .= ' button';
}
?> ?>
<a class="next-page<?php echo esc_attr( ( $this->page < $total_pages ) ? '' : ' disabled' ); ?>" title="<?php esc_attr_e( 'Go to the next page', 'pods' ); ?>" href="<?php echo esc_url( $request_uri . ( $append ? '&' : '?' ) . 'pg' . $this->num . '=' . min( $this->page + 1, $total_pages ) ); ?>">&rsaquo;</a> <a class="next-page<?php echo esc_attr( $classes ); ?>" title="<?php esc_attr_e( 'Go to the next page', 'pods' ); ?>" href="<?php echo $next_link; ?>">&rsaquo;</a>
<a class="last-page<?php echo esc_attr( ( $this->page < $total_pages ) ? '' : ' disabled' ); ?>" title="<?php esc_attr_e( 'Go to the last page', 'pods' ); ?>'" href="<?php echo esc_url( $request_uri . ( $append ? '&' : '?' ) . 'pg' . $this->num . '=' . $total_pages ); ?>">&raquo;</a> <a class="last-page<?php echo esc_attr( $classes ); ?>" title="<?php esc_attr_e( 'Go to the last page', 'pods' ); ?>" href="<?php echo $last_link; ?>">&raquo</a>
<?php <?php
}//end if }//end if
}//end if }//end if
...@@ -4914,8 +4936,7 @@ class PodsUI { ...@@ -4914,8 +4936,7 @@ class PodsUI {
$author_restrict = false; $author_restrict = false;
if ( ! empty( $this->restrict['author_restrict'] ) && $restrict === $this->restrict['author_restrict'] ) { if ( ! empty( $this->restrict['author_restrict'] ) && $restrict === $this->restrict['author_restrict'] ) {
$restricted = false; $restricted = false;
$author_restrict = true; $author_restrict = true;
if ( is_object( $this->pod ) ) { if ( is_object( $this->pod ) ) {
...@@ -4927,33 +4948,58 @@ class PodsUI { ...@@ -4927,33 +4948,58 @@ class PodsUI {
if ( pods_is_admin( array( 'pods', 'pods_content' ) ) ) { if ( pods_is_admin( array( 'pods', 'pods_content' ) ) ) {
$restricted = false; $restricted = false;
} elseif ( 'manage' === $action ) { } else {
if ( ! in_array( 'edit', $this->actions_disabled ) && ( current_user_can( 'pods_edit_' . $this->pod->pod ) || current_user_can( 'pods_edit_others_' . $this->pod->pod ) ) ) { // Disable legacy check.
$restricted = false; $author_restrict = false;
} elseif ( ! in_array( 'delete', $this->actions_disabled ) && ( current_user_can( 'pods_delete_' . $this->pod->pod ) || current_user_can( 'pods_delete_others_' . $this->pod->pod ) ) ) {
$restricted = false; $pod = $this->pod;
} elseif ( current_user_can( 'pods_' . $action . '_' . $this->pod->pod ) || current_user_can( 'pods_' . $action . '_others_' . $this->pod->pod ) ) { if ( ! $pod->id() && $row ) {
$restricted = false; $pod->fetch( $row );
}
// Check if the current user is the author of this item.
$author = $pod->field( 'author', true );
$is_author = false;
if ( $author && (int) wp_get_current_user()->ID === (int) pods_v( 'ID', $author, 0 ) ) {
$is_author = true;
}
$cap_actions = array( $action );
if ( 'manage' === $action || 'reorder' === $action ) {
if ( ! in_array( 'edit', $this->actions_disabled, true ) ) {
$cap_actions[] = 'edit';
}
if ( ! in_array( 'delete', $this->actions_disabled, true ) ) {
$cap_actions[] = 'delete';
}
}
foreach ( $cap_actions as $cap ) {
if ( $is_author ) {
// Only need regular capability.
if ( current_user_can( 'pods_' . $cap . '_' . $this->pod->pod ) ) {
$restricted = false;
break;
}
} else {
// This item is created by another user so the "others" capability is required as well.
if (
current_user_can( 'pods_' . $cap . '_' . $this->pod->pod ) &&
current_user_can( 'pods_' . $cap . '_others_' . $this->pod->pod )
) {
$restricted = false;
break;
}
}
} }
} elseif ( current_user_can( 'pods_' . $action . '_' . $this->pod->pod ) || current_user_can( 'pods_' . $action . '_others_' . $this->pod->pod ) ) {
$restricted = false;
} }
}//end if }//end if
/*
@todo determine proper logic for non-pods capabilities
else {
$restricted = true;
if ( pods_is_admin( array( 'pods', 'pods_content' ) ) )
$restricted = false;
elseif ( current_user_can( 'pods_' . $action . '_others_' . $_tbd ) )
$restricted = false;
}
*/
}//end if }//end if
if ( $restricted && ! empty( $restrict ) ) { if ( $restricted && ! empty( $restrict ) ) {
$relation = strtoupper( trim( pods_var( 'relation', $restrict, 'AND', null, true ) ) ); $relation = strtoupper( trim( pods_v( 'relation', $restrict, 'AND', null, true ) ) );
if ( 'AND' !== $relation ) { if ( 'AND' !== $relation ) {
$relation = 'OR'; $relation = 'OR';
...@@ -4969,7 +5015,7 @@ class PodsUI { ...@@ -4969,7 +5015,7 @@ class PodsUI {
if ( is_array( $match ) ) { if ( is_array( $match ) ) {
$match_okay = true; $match_okay = true;
$match_relation = strtoupper( trim( pods_var( 'relation', $match, 'OR', null, true ) ) ); $match_relation = strtoupper( trim( pods_v( 'relation', $match, 'OR', null, true ) ) );
if ( 'AND' !== $match_relation ) { if ( 'AND' !== $match_relation ) {
$match_relation = 'OR'; $match_relation = 'OR';
...@@ -5088,42 +5134,28 @@ class PodsUI { ...@@ -5088,42 +5134,28 @@ class PodsUI {
}//end if }//end if
}//end foreach }//end foreach
if ( ! empty( $author_restrict ) ) { // Legacy author restrict check.
if ( is_object( $this->pod ) && 'manage' === $action ) { if ( $author_restrict && ! $okay && ! empty( $row ) ) {
if ( ! in_array( 'edit', $this->actions_disabled ) && ! current_user_can( 'pods_edit_' . $this->pod->pod ) && ! in_array( 'delete', $this->actions_disabled ) && ! current_user_can( 'pods_delete_' . $this->pod->pod ) ) { foreach ( $this->restrict['author_restrict'] as $key => $val ) {
$okay = false; $author_restricted = $this->get_field( $key );
}
}
if ( is_object( $this->pod ) && ! current_user_can( 'pods_' . $action . '_' . $this->pod->pod ) ) {
$okay = false;
}
/*
@todo determine proper logic for non-pods capabilities
elseif ( !current_user_can( 'pods_' . $action . '_' . $_tbd ) )
$okay = false;
*/
if ( ! $okay && ! empty( $row ) ) {
foreach ( $this->restrict['author_restrict'] as $key => $val ) {
$author_restricted = $this->get_field( $key );
if ( ! empty( $author_restricted ) ) {
if ( ! is_array( $author_restricted ) ) {
$author_restricted = (array) $author_restricted;
}
if ( is_array( $val ) ) { if ( ! empty( $author_restricted ) ) {
foreach ( $val as $v ) { if ( ! is_array( $author_restricted ) ) {
if ( in_array( $v, $author_restricted ) ) { $author_restricted = (array) $author_restricted;
$okay = true; }
} $author_restricted = array_map( 'intval', $author_restricted );
if ( is_array( $val ) ) {
foreach ( $val as $v ) {
if ( in_array( (int) $v, $author_restricted, true ) ) {
$restricted = false;
} }
} elseif ( in_array( $val, $author_restricted ) ) {
$okay = true;
} }
} elseif ( in_array( (int) $val, $author_restricted, true ) ) {
$restricted = false;
} }
} }
}//end if }//end foreach
}//end if }//end if
if ( $okay ) { if ( $okay ) {
...@@ -5131,7 +5163,10 @@ class PodsUI { ...@@ -5131,7 +5163,10 @@ class PodsUI {
} }
}//end if }//end if
if ( isset( $this->actions_custom[ $action ] ) && is_array( $this->actions_custom[ $action ] ) && isset( $this->actions_custom[ $action ]['restrict_callback'] ) && is_callable( $this->actions_custom[ $action ]['restrict_callback'] ) ) { if (
isset( $this->actions_custom[ $action ]['restrict_callback'] )
&& is_callable( $this->actions_custom[ $action ]['restrict_callback'] )
) {
$restricted = call_user_func( $this->actions_custom[ $action ]['restrict_callback'], $restricted, $restrict, $action, $row, $this ); $restricted = call_user_func( $this->actions_custom[ $action ]['restrict_callback'], $restricted, $restrict, $action, $row, $this );
} }
......
...@@ -169,6 +169,25 @@ class PodsField_Boolean extends PodsField { ...@@ -169,6 +169,25 @@ class PodsField_Boolean extends PodsField {
return $data; return $data;
} }
/**
* {@inheritdoc}
*/
public function validate( $value, $name = null, $options = null, $fields = null, $pod = null, $id = null, $params = null ) {
$errors = array();
$check = $this->pre_save( $value, $id, $name, $options, $fields, $pod, $params );
if ( 1 === (int) pods_v( 'required', $options ) && 0 === $check ) {
$errors[] = __( 'This field is required.', 'pods' );
}
if ( ! empty( $errors ) ) {
return $errors;
}
return true;
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
......
...@@ -166,6 +166,19 @@ class PodsField_Date extends PodsField_DateTime { ...@@ -166,6 +166,19 @@ class PodsField_Date extends PodsField_DateTime {
return $schema; return $schema;
} }
/**
* {@inheritdoc}
*/
public function format_display( $options, $js = false ) {
if ( $js && 'custom' === pods_v( static::$type . '_type', $options, 'format' ) ) {
$format = $this->format_datetime( $options, $js );
return $this->convert_format( $format, array( 'source' => 'jquery_ui', 'type' => 'date' ) );
}
return parent::format_display( $options, $js );
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
......
...@@ -281,8 +281,8 @@ class PodsField_DateTime extends PodsField { ...@@ -281,8 +281,8 @@ class PodsField_DateTime extends PodsField {
$value = implode( ' ', $value ); $value = implode( ' ', $value );
} }
// Format Value // @todo Remove? Format Value (done in field template).
$value = $this->format_value_display( $value, $options, true ); //$value = $this->format_value_display( $value, $options, true );
$field_type = static::$type; $field_type = static::$type;
...@@ -321,11 +321,8 @@ class PodsField_DateTime extends PodsField { ...@@ -321,11 +321,8 @@ class PodsField_DateTime extends PodsField {
$js = false; $js = false;
} }
$format = $this->format_datetime( $options, $js ); // Value should always be passed as storage format since 2.7.15.
$format = static::$storage_format;
if ( $js ) {
$format = $this->convert_format( $format, array( 'source' => 'jquery_ui' ) );
}
$check = $this->convert_date( $value, static::$storage_format, $format, true ); $check = $this->convert_date( $value, static::$storage_format, $format, true );
...@@ -345,14 +342,8 @@ class PodsField_DateTime extends PodsField { ...@@ -345,14 +342,8 @@ class PodsField_DateTime extends PodsField {
*/ */
public function pre_save( $value, $id = null, $name = null, $options = null, $fields = null, $pod = null, $params = null ) { public function pre_save( $value, $id = null, $name = null, $options = null, $fields = null, $pod = null, $params = null ) {
$js = true; // Value should always be passed as storage format since 2.7.15.
if ( 'custom' !== pods_v( static::$type . '_type', $options, 'format' ) ) { $format = static::$storage_format;
$js = false;
}
$format = $this->format_datetime( $options, $js );
if ( $js ) {
$format = $this->convert_format( $format, array( 'source' => 'jquery_ui' ) );
}
if ( ! empty( $value ) && ( 0 === (int) pods_v( static::$type . '_allow_empty', $options, 1 ) || ! in_array( if ( ! empty( $value ) && ( 0 === (int) pods_v( static::$type . '_allow_empty', $options, 1 ) || ! in_array(
$value, array( $value, array(
...@@ -446,12 +437,25 @@ class PodsField_DateTime extends PodsField { ...@@ -446,12 +437,25 @@ class PodsField_DateTime extends PodsField {
*/ */
public function format_display( $options, $js = false ) { public function format_display( $options, $js = false ) {
if ( 'custom' !== pods_v( static::$type . '_type', $options, 'format' ) ) { if ( 'custom' === pods_v( static::$type . '_type', $options, 'format' ) ) {
if ( $js ) {
// Gets format strings in jQuery UI format.
$date = $this->format_date( $options, $js );
$time = $this->format_time( $options, $js );
// Convert them to PHP date format.
$date = $this->convert_format( $date, array( 'source' => 'jquery_ui', 'type' => 'date' ) );
$time = $this->convert_format( $time, array( 'source' => 'jquery_ui', 'type' => 'time' ) );
return $date . ' ' . $time;
} else {
$format = $this->format_datetime( $options, $js );
}
} else {
$js = false; $js = false;
} $format = $this->format_datetime( $options, $js );
$format = $this->format_datetime( $options, $js );
if ( $js ) {
$format = $this->convert_format( $format, array( 'source' => 'jquery_ui' ) );
} }
return $format; return $format;
...@@ -495,24 +499,33 @@ class PodsField_DateTime extends PodsField { ...@@ -495,24 +499,33 @@ class PodsField_DateTime extends PodsField {
switch ( (string) pods_v( static::$type . '_type', $options, 'format', true ) ) { switch ( (string) pods_v( static::$type . '_type', $options, 'format', true ) ) {
case 'wp': case 'wp':
$format = get_option( 'date_format' ); $format = get_option( 'date_format' );
if ( $js ) { if ( $js ) {
$format = $this->convert_format( $format, array( 'source' => 'php' ) ); $format = $this->convert_format( $format, array( 'source' => 'php', 'type' => 'date' ) );
} }
break; break;
case 'custom': case 'custom':
if ( ! $js ) { if ( ! $js ) {
$format = pods_v( static::$type . '_format_custom', $options, '' ); $format = pods_v( static::$type . '_format_custom', $options, '' );
} else { } else {
$format = pods_v( static::$type . '_format_custom_js', $options, '' ); $format = pods_v( static::$type . '_format_custom_js', $options, '' );
if ( empty( $format ) ) { if ( empty( $format ) ) {
$format = pods_v( static::$type . '_format_custom', $options, '' ); $format = pods_v( static::$type . '_format_custom', $options, '' );
$format = $this->convert_format( $format, array( 'source' => 'php' ) );
if ( $js ) {
$format = $this->convert_format( $format, array( 'source' => 'php', 'type' => 'date' ) );
}
} }
} }
break; break;
default: default:
$date_format = $this->get_date_formats( $js ); $date_format = $this->get_date_formats( $js );
$format = $date_format[ pods_v( static::$type . '_format', $options, 'ymd_dash', true ) ]; $format = $date_format[ pods_v( static::$type . '_format', $options, 'ymd_dash', true ) ];
break; break;
}//end switch }//end switch
...@@ -549,10 +562,11 @@ class PodsField_DateTime extends PodsField { ...@@ -549,10 +562,11 @@ class PodsField_DateTime extends PodsField {
$format = pods_v( static::$type . '_time_format_custom', $options, '' ); $format = pods_v( static::$type . '_time_format_custom', $options, '' );
} else { } else {
$format = pods_v( static::$type . '_time_format_custom_js', $options, '' ); $format = pods_v( static::$type . '_time_format_custom_js', $options, '' );
$js = false; // Already in JS format.
if ( empty( $format ) ) { if ( empty( $format ) ) {
$format = pods_v( static::$type . '_time_format_custom', $options, '' ); $format = pods_v( static::$type . '_time_format_custom', $options, '' );
$format = $this->convert_format( $format, array( 'source' => 'php' ) ); $js = true;
} }
} }
...@@ -560,10 +574,6 @@ class PodsField_DateTime extends PodsField { ...@@ -560,10 +574,6 @@ class PodsField_DateTime extends PodsField {
default: default:
$format = get_option( 'time_format' ); $format = get_option( 'time_format' );
if ( $js ) {
$format = $this->convert_format( $format, array( 'source' => 'php' ) );
}
break; break;
}//end switch }//end switch
...@@ -601,8 +611,9 @@ class PodsField_DateTime extends PodsField { ...@@ -601,8 +611,9 @@ class PodsField_DateTime extends PodsField {
$filter = 'pods_form_ui_field_date_formats'; $filter = 'pods_form_ui_field_date_formats';
if ( $js ) { if ( $js ) {
// @todo Method parameters? (Not supported by array_map) foreach ( $date_format as $key => $value ) {
$date_format = array_map( array( $this, 'convert_format' ), $date_format ); $date_format[ $key ] = $this->convert_format( $value, array( 'type' => 'date' ) );
}
$filter = 'pods_form_ui_field_date_js_formats'; $filter = 'pods_form_ui_field_date_js_formats';
} }
...@@ -637,8 +648,9 @@ class PodsField_DateTime extends PodsField { ...@@ -637,8 +648,9 @@ class PodsField_DateTime extends PodsField {
$filter = 'pods_form_ui_field_time_formats'; $filter = 'pods_form_ui_field_time_formats';
if ( $js ) { if ( $js ) {
// @todo Method parameters? (Not supported by array_map) foreach ( $time_format as $key => $value ) {
$time_format = array_map( array( $this, 'convert_format' ), $time_format ); $time_format[ $key ] = $this->convert_format( $value, array( 'type' => 'time' ) );
}
$filter = 'pods_form_ui_field_time_js_formats'; $filter = 'pods_form_ui_field_time_js_formats';
} }
...@@ -665,8 +677,9 @@ class PodsField_DateTime extends PodsField { ...@@ -665,8 +677,9 @@ class PodsField_DateTime extends PodsField {
$filter = 'pods_form_ui_field_time_formats_24'; $filter = 'pods_form_ui_field_time_formats_24';
if ( $js ) { if ( $js ) {
// @todo Method parameters? (Not supported by array_map) foreach ( $time_format_24 as $key => $value ) {
$time_format_24 = array_map( array( $this, 'convert_format' ), $time_format_24 ); $time_format_24[ $key ] = $this->convert_format( $value, array( 'type' => 'time' ) );
}
$filter = 'pods_form_ui_field_time_js_formats_24'; $filter = 'pods_form_ui_field_time_js_formats_24';
} }
...@@ -784,55 +797,64 @@ class PodsField_DateTime extends PodsField { ...@@ -784,55 +797,64 @@ class PodsField_DateTime extends PodsField {
$args = array_merge( $args = array_merge(
array( array(
'source' => 'php', 'source' => 'php',
'type' => 'date',
// 'jquery_ui' for reverse. // 'jquery_ui' for reverse.
), $args ), $args
); );
// Keep keys and values sorted by string length. // Keep keys and values sorted by string length.
$symbols = array( if ( 'time' === $args['type'] || 'time' === static::$type ) {
// Day
'd' => 'dd', $symbols = array(
'l' => 'DD', // AM/PM.
'D' => 'D', 'a' => 'tt',
'j' => 'd', 'A' => 'TT',
'N' => '', // Swatch internet time (not supported).
'S' => '', 'B' => '',
'w' => '', // Hour.
'z' => 'o', 'h' => 'hh',
// Week 'H' => 'HH',
'W' => '', 'g' => 'h',
// Month 'G' => 'H',
'F' => 'MM', // Minute.
'm' => 'mm', 'i' => 'mm',
'M' => 'M', // Second.
'n' => 'm', 's' => 'ss',
't' => '', // Microsecond.
// Year 'u' => 'c',
'L' => '', );
'o' => '',
'Y' => 'yy',
'y' => 'y',
// AM/PM
'a' => 'tt',
'A' => 'TT',
// Swatch internet time (not supported)
'B' => '',
// Hour
'h' => 'hh',
'H' => 'HH',
'g' => 'h',
'G' => 'H',
// Minute
'i' => 'mm',
// Second
's' => 'ss',
// Microsecond
'u' => 'c',
);
if ( version_compare( PHP_VERSION, '7.0.0' ) >= 0 ) { if ( version_compare( PHP_VERSION, '7.0.0' ) >= 0 ) {
// Millisecond // Millisecond.
$symbols['v'] = 'l'; $symbols['v'] = 'l';
}
} else {
$symbols = array(
// Day.
'd' => 'dd',
'l' => 'DD',
'D' => 'D',
'j' => 'd',
'N' => '',
'S' => '',
'w' => '',
'z' => 'o',
// Week.
'W' => '',
// Month.
'F' => 'MM',
'm' => 'mm',
'M' => 'M',
'n' => 'm',
't' => '',
// Year.
'L' => '',
'o' => '',
'Y' => 'yy',
'y' => 'y',
);
} }
if ( 'jquery_ui' === $args['source'] ) { if ( 'jquery_ui' === $args['source'] ) {
......
...@@ -169,6 +169,19 @@ class PodsField_Time extends PodsField_DateTime { ...@@ -169,6 +169,19 @@ class PodsField_Time extends PodsField_DateTime {
return empty( $value ); return empty( $value );
} }
/**
* {@inheritdoc}
*/
public function format_display( $options, $js = false ) {
if ( $js && 'custom' === pods_v( static::$type . '_type', $options, 'format' ) ) {
$format = $this->format_datetime( $options, $js );
return $this->convert_format( $format, array( 'source' => 'jquery_ui', 'type' => 'time' ) );
}
return parent::format_display( $options, $js );
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
...@@ -209,7 +222,10 @@ class PodsField_Time extends PodsField_DateTime { ...@@ -209,7 +222,10 @@ class PodsField_Time extends PodsField_DateTime {
if ( empty( $format ) ) { if ( empty( $format ) ) {
$format = pods_v( static::$type . '_format_custom', $options, '' ); $format = pods_v( static::$type . '_format_custom', $options, '' );
$format = $this->convert_format( $format, array( 'source' => 'php' ) );
if ( $js ) {
$format = $this->convert_format( $format, array( 'source' => 'php', 'type' => 'time' ) );
}
} }
} }
...@@ -218,7 +234,7 @@ class PodsField_Time extends PodsField_DateTime { ...@@ -218,7 +234,7 @@ class PodsField_Time extends PodsField_DateTime {
$format = get_option( 'time_format' ); $format = get_option( 'time_format' );
if ( $js ) { if ( $js ) {
$format = $this->convert_format( $format, array( 'source' => 'php' ) ); $format = $this->convert_format( $format, array( 'source' => 'php', 'type' => 'time' ) );
} }
break; break;
......
...@@ -374,6 +374,12 @@ class Pods_Migrate_Packages extends PodsComponent { ...@@ -374,6 +374,12 @@ class Pods_Migrate_Packages extends PodsComponent {
$pod = array_merge( $pod, $pod_data ); $pod = array_merge( $pod, $pod_data );
if ( in_array( $pod['name'], pods_reserved_keywords(), true ) ) {
// Extending objects when using reserved keywords.
// This will then accept `post`, `page` etc. as Pods object names.
$pod['create_extend'] = 'extend';
}
foreach ( $pod['fields'] as $k => $field ) { foreach ( $pod['fields'] as $k => $field ) {
if ( isset( $field['id'] ) && ! isset( $existing_fields[ $field['name'] ] ) ) { if ( isset( $field['id'] ) && ! isset( $existing_fields[ $field['name'] ] ) ) {
unset( $pod['fields'][ $k ]['id'] ); unset( $pod['fields'][ $k ]['id'] );
...@@ -400,13 +406,14 @@ class Pods_Migrate_Packages extends PodsComponent { ...@@ -400,13 +406,14 @@ class Pods_Migrate_Packages extends PodsComponent {
} }
}//end foreach }//end foreach
$api->save_pod( $pod ); if ( $api->save_pod( $pod ) ) {
if ( ! isset( $found['pods'] ) ) {
$found['pods'] = array();
}
if ( ! isset( $found['pods'] ) ) { $found['pods'][ $pod['name'] ] = $pod['label'];
$found['pods'] = array();
} }
$found['pods'][ $pod['name'] ] = $pod['label'];
}//end foreach }//end foreach
}//end if }//end if
......
...@@ -57,16 +57,6 @@ class Pods_Roles extends PodsComponent { ...@@ -57,16 +57,6 @@ class Pods_Roles extends PodsComponent {
global $wp_roles; global $wp_roles;
// Hook into Gravity Forms roles (since it only adds filter if Members plugin itself is activated
if ( class_exists( 'RGForms' ) && ! has_filter(
'members_get_capabilities', array(
'RGForms',
'members_get_capabilities',
)
) ) {
add_filter( 'members_get_capabilities', array( 'RGForms', 'members_get_capabilities' ) );
}
$default_role = get_option( 'default_role' ); $default_role = get_option( 'default_role' );
$roles = array(); $roles = array();
...@@ -447,7 +437,12 @@ class Pods_Roles extends PodsComponent { ...@@ -447,7 +437,12 @@ class Pods_Roles extends PodsComponent {
$capabilities = array_merge( $default_caps, $role_caps, $plugin_caps ); $capabilities = array_merge( $default_caps, $role_caps, $plugin_caps );
// To support Members filters // Gravity Forms.
if ( is_callable( 'GFCommon::all_caps' ) ) {
$capabilities = array_merge( $capabilities, GFCommon::all_caps() );
}
// To support Members filters.
$capabilities = apply_filters( 'members_get_capabilities', $capabilities ); $capabilities = apply_filters( 'members_get_capabilities', $capabilities );
$capabilities = apply_filters( 'pods_roles_get_capabilities', $capabilities ); $capabilities = apply_filters( 'pods_roles_get_capabilities', $capabilities );
......
...@@ -1383,13 +1383,14 @@ function pods_absint( $maybeint, $strict = true, $allow_negative = false ) { ...@@ -1383,13 +1383,14 @@ function pods_absint( $maybeint, $strict = true, $allow_negative = false ) {
/** /**
* Functions like str_replace except it will restrict $occurrences * Functions like str_replace except it will restrict $occurrences
* *
* @since 2.0
*
* @param mixed $find * @param mixed $find
* @param mixed $replace * @param mixed $replace
* @param string $string * @param string $string
* @param int $occurrences (optional) * @param int $occurrences (optional)
* *
* @return mixed * @return mixed
* @version 2.0
*/ */
function pods_str_replace( $find, $replace, $string, $occurrences = - 1 ) { function pods_str_replace( $find, $replace, $string, $occurrences = - 1 ) {
...@@ -1416,8 +1417,12 @@ function pods_str_replace( $find, $replace, $string, $occurrences = - 1 ) { ...@@ -1416,8 +1417,12 @@ function pods_str_replace( $find, $replace, $string, $occurrences = - 1 ) {
} else { } else {
$find = '/' . preg_quote( $find, '/' ) . '/'; $find = '/' . preg_quote( $find, '/' ) . '/';
} }
if ( is_string( $string ) ) {
return preg_replace( $find, $replace, $string, $occurrences ); return preg_replace( $find, $replace, $string, $occurrences );
} else {
// Occasionally we will receive non string values (true, false, null). Allow those to pass through
return $string;
}
} }
/** /**
...@@ -1462,82 +1467,82 @@ function pods_mb_substr( $string, $start, $length = null, $encoding = null ) { ...@@ -1462,82 +1467,82 @@ function pods_mb_substr( $string, $start, $length = null, $encoding = null ) {
} }
/** /**
* Evaluate tags like magic tags but through pods_v * Evaluate tags like magic tags but through pods_v.
* *
* @param string|array|object $tags String to be evaluated * @since 2.1
* @param bool $sanitize Whether to sanitize tags
* *
* @return string * @param string|array|object $tags String to be evaluated.
* @param bool $sanitize Whether to sanitize.
* @param null|mixed $fallback The fallback value to use if not set, should already be sanitized.
* *
* @version 2.1 * @return string
* *
* @see pods_evaluate_tag * @see pods_evaluate_tag
*/ */
function pods_evaluate_tags( $tags, $sanitize = false ) { function pods_evaluate_tags( $tags, $sanitize = false, $fallback = null ) {
if ( is_array( $tags ) ) { if ( is_array( $tags ) ) {
foreach ( $tags as $k => $tag ) { foreach ( $tags as $k => $tag ) {
$tags[ $k ] = pods_evaluate_tags( $tag, $sanitize ); $tags[ $k ] = pods_evaluate_tags( $tag, $sanitize );
} }
return $tags; return $tags;
} elseif ( is_object( $tags ) ) { }
$tags = get_object_vars( $tags );
foreach ( $tags as $k => $tag ) { if ( is_object( $tags ) ) {
$tags[ $k ] = pods_evaluate_tags( $tag, $sanitize ); $tags = get_object_vars( $tags );
}
$tags = (object) $tags; // Evaluate array and cast as object.
$tags = (object) pods_evaluate_tags( $tags );
return $tags; return $tags;
} }
$callback = 'pods_evaluate_tag'; return preg_replace_callback(
'/({@(.*?)})/m',
if ( true === $sanitize ) { function ( $tag ) use ( $sanitize, $fallback ) {
$callback = 'pods_evaluate_tag_sanitized'; return pods_evaluate_tag( $tag, $sanitize, $fallback );
} },
(string) $tags
return preg_replace_callback( '/({@(.*?)})/m', $callback, (string) $tags ); );
} }
/** /**
* Evaluate tag like magic tag but mapped through pods_v_sanitized * Evaluate tag like magic tag but mapped through pods_v_sanitized.
* *
* @param string|array $tag * @since 2.1
* *
* @return string * @param string|array $tag String to be evaluated.
* *
* @version 2.1 * @return string Evaluated content.
* *
* @see pods_evaluate_tag * @see pods_evaluate_tag
*/ */
function pods_evaluate_tag_sanitized( $tag ) { function pods_evaluate_tag_sanitized( $tag ) {
return pods_evaluate_tag( $tag, true ); return pods_evaluate_tag( $tag, true );
} }
/** /**
* Evaluate tag like magic tag but mapped through pods_v * Evaluate tag like magic tag but mapped through pods_v.
* *
* @param string|array $tag * @since 2.1
* @param bool $sanitize Whether to sanitize tags
* *
* @return string * @param string|array $tag String to be evaluated.
* @param bool $sanitize Whether to sanitize tags.
* @param null|mixed $fallback The fallback value to use if not set, should already be sanitized.
* *
* @version 2.1 * @return string Evaluated content.
*/ */
function pods_evaluate_tag( $tag, $sanitize = false ) { function pods_evaluate_tag( $tag, $sanitize = false, $fallback = null ) {
global $wpdb; global $wpdb;
// Handle pods_evaluate_tags // Handle pods_evaluate_tags
if ( is_array( $tag ) ) { if ( is_array( $tag ) ) {
if ( ! isset( $tag[2] ) && strlen( trim( $tag[2] ) ) < 1 ) { if ( ! isset( $tag[2] ) && '' === trim( $tag[2] ) ) {
return ''; if ( null === $fallback ) {
return '';
}
return $fallback;
} }
$tag = $tag[2]; $tag = $tag[2];
...@@ -1546,8 +1551,12 @@ function pods_evaluate_tag( $tag, $sanitize = false ) { ...@@ -1546,8 +1551,12 @@ function pods_evaluate_tag( $tag, $sanitize = false ) {
$tag = trim( $tag, ' {@}' ); $tag = trim( $tag, ' {@}' );
$tag = explode( '.', $tag ); $tag = explode( '.', $tag );
if ( empty( $tag ) || ! isset( $tag[0] ) || strlen( trim( $tag[0] ) ) < 1 ) { if ( empty( $tag ) || ! isset( $tag[0] ) || '' === trim( $tag[0] ) ) {
return ''; if ( null === $fallback ) {
return '';
}
return $fallback;
} }
// Fix formatting that may be after the first . // Fix formatting that may be after the first .
...@@ -1584,16 +1593,16 @@ function pods_evaluate_tag( $tag, $sanitize = false ) { ...@@ -1584,16 +1593,16 @@ function pods_evaluate_tag( $tag, $sanitize = false ) {
); );
if ( in_array( $tag[0], $single_supported, true ) ) { if ( in_array( $tag[0], $single_supported, true ) ) {
$value = pods_v( '', $tag[0], '', true ); $value = pods_v( '', $tag[0], null );
} elseif ( 1 == count( $tag ) ) { } elseif ( 1 === count( $tag ) ) {
$value = pods_v( $tag[0], 'get', '', true ); $value = pods_v( $tag[0], 'get', null );
} elseif ( 2 == count( $tag ) ) { } elseif ( 2 === count( $tag ) ) {
$value = pods_v( $tag[1], $tag[0], '', true ); $value = pods_v( $tag[1], $tag[0], null );
} }
$value = apply_filters( 'pods_evaluate_tag', $value, $tag ); $value = apply_filters( 'pods_evaluate_tag', $value, $tag, $fallback );
if ( is_array( $value ) && 1 == count( $value ) ) { if ( is_array( $value ) && 1 === count( $value ) ) {
$value = current( $value ); $value = current( $value );
} }
...@@ -1601,12 +1610,19 @@ function pods_evaluate_tag( $tag, $sanitize = false ) { ...@@ -1601,12 +1610,19 @@ function pods_evaluate_tag( $tag, $sanitize = false ) {
$value = pods_serial_comma( $value ); $value = pods_serial_comma( $value );
} }
if ( null === $value ) {
$value = '';
}
if ( $sanitize ) { if ( $sanitize ) {
$value = pods_sanitize( $value ); $value = pods_sanitize( $value );
} }
return $value; if ( null !== $fallback && '' === $value ) {
$value = $fallback;
}
return $value;
} }
/** /**
......
...@@ -459,6 +459,21 @@ function pods_api_cache() { ...@@ -459,6 +459,21 @@ function pods_api_cache() {
return true; return true;
} }
/**
* Determine if Pods shortcodes can evaluate magic tags.
*
* @since 2.7.16
*
* @return bool
*/
function pods_shortcode_allow_evaluate_tags() {
if ( defined( 'PODS_SHORTCODE_ALLOW_EVALUATE_TAGS' ) && PODS_SHORTCODE_ALLOW_EVALUATE_TAGS ) {
return true;
}
return false;
}
/** /**
* Marks a function as deprecated and informs when it has been used. * Marks a function as deprecated and informs when it has been used.
* *
...@@ -784,7 +799,8 @@ function pods_shortcode_run( $tags, $content = null ) { ...@@ -784,7 +799,8 @@ function pods_shortcode_run( $tags, $content = null ) {
$offset = max( $offset, 0 ); $offset = max( $offset, 0 );
} }
$defaults = array( // Query related tags separated to use later.
$default_query_tags = array(
'use_current' => false, 'use_current' => false,
'name' => null, 'name' => null,
'id' => null, 'id' => null,
...@@ -806,21 +822,26 @@ function pods_shortcode_run( $tags, $content = null ) { ...@@ -806,21 +822,26 @@ function pods_shortcode_run( $tags, $content = null ) {
'filters_location' => 'before', 'filters_location' => 'before',
'pagination_label' => null, 'pagination_label' => null,
'pagination_location' => 'after', 'pagination_location' => 'after',
'field' => null,
'col' => null,
'template' => null,
'pods_page' => null,
'helper' => null,
'form' => null,
'fields' => null,
'label' => null,
'thank_you' => null,
'view' => null,
'cache_mode' => 'none',
'expires' => 0,
'shortcodes' => false,
); );
$default_other_tags = array(
'field' => null,
'col' => null,
'template' => null,
'pods_page' => null,
'helper' => null,
'form' => null,
'fields' => null,
'label' => null,
'thank_you' => null,
'view' => null,
'cache_mode' => 'none',
'expires' => 0,
'shortcodes' => false,
);
$defaults = array_merge( $default_other_tags, $default_query_tags );
if ( ! empty( $tags ) ) { if ( ! empty( $tags ) ) {
$tags = array_merge( $defaults, $tags ); $tags = array_merge( $defaults, $tags );
} else { } else {
...@@ -853,7 +874,9 @@ function pods_shortcode_run( $tags, $content = null ) { ...@@ -853,7 +874,9 @@ function pods_shortcode_run( $tags, $content = null ) {
} }
if ( ! $tags['use_current'] && empty( $tags['name'] ) ) { if ( ! $tags['use_current'] && empty( $tags['name'] ) ) {
if ( in_the_loop() || is_singular() ) { $has_query_tags = array_intersect_key( array_diff( $tags, $defaults ), $default_query_tags );
if ( ( in_the_loop() || is_singular() ) && ! $has_query_tags ) {
$pod = pods( get_post_type(), get_the_ID(), false ); $pod = pods( get_post_type(), get_the_ID(), false );
if ( ! empty( $pod ) ) { if ( ! empty( $pod ) ) {
...@@ -891,16 +914,16 @@ function pods_shortcode_run( $tags, $content = null ) { ...@@ -891,16 +914,16 @@ function pods_shortcode_run( $tags, $content = null ) {
if ( ! empty( $tags['slug'] ) ) { if ( ! empty( $tags['slug'] ) ) {
$id = $tags['slug']; $id = $tags['slug'];
if ( defined( 'PODS_SHORTCODE_ALLOW_EVALUATE_TAGS' ) && PODS_SHORTCODE_ALLOW_EVALUATE_TAGS ) { if ( pods_shortcode_allow_evaluate_tags() ) {
$id = pods_evaluate_tags( $id ); $id = pods_evaluate_tags( $id, true );
} }
} }
if ( ! empty( $tags['id'] ) ) { if ( ! empty( $tags['id'] ) ) {
$id = $tags['id']; $id = $tags['id'];
if ( defined( 'PODS_SHORTCODE_ALLOW_EVALUATE_TAGS' ) && PODS_SHORTCODE_ALLOW_EVALUATE_TAGS ) { if ( pods_shortcode_allow_evaluate_tags() ) {
$id = pods_evaluate_tags( $id ); $id = pods_evaluate_tags( $id, true );
} }
if ( is_numeric( $id ) ) { if ( is_numeric( $id ) ) {
...@@ -937,16 +960,16 @@ function pods_shortcode_run( $tags, $content = null ) { ...@@ -937,16 +960,16 @@ function pods_shortcode_run( $tags, $content = null ) {
if ( 0 < strlen( $tags['where'] ) ) { if ( 0 < strlen( $tags['where'] ) ) {
$params['where'] = $tags['where']; $params['where'] = $tags['where'];
if ( defined( 'PODS_SHORTCODE_ALLOW_EVALUATE_TAGS' ) && PODS_SHORTCODE_ALLOW_EVALUATE_TAGS ) { if ( pods_shortcode_allow_evaluate_tags() ) {
$params['where'] = pods_evaluate_tags( html_entity_decode( $params['where'] ) ); $params['where'] = pods_evaluate_tags( html_entity_decode( $params['where'] ), true, '""' );
} }
} }
if ( 0 < strlen( $tags['having'] ) ) { if ( 0 < strlen( $tags['having'] ) ) {
$params['having'] = $tags['having']; $params['having'] = $tags['having'];
if ( defined( 'PODS_SHORTCODE_ALLOW_EVALUATE_TAGS' ) && PODS_SHORTCODE_ALLOW_EVALUATE_TAGS ) { if ( pods_shortcode_allow_evaluate_tags() ) {
$params['having'] = pods_evaluate_tags( html_entity_decode( $params['having'] ) ); $params['having'] = pods_evaluate_tags( html_entity_decode( $params['having'] ), true, '""' );
} }
} }
...@@ -2154,7 +2177,7 @@ function pods_no_conflict_on( $object_type = 'post', $object = null ) { ...@@ -2154,7 +2177,7 @@ function pods_no_conflict_on( $object_type = 'post', $object = null ) {
$no_conflict['action'] = array( $no_conflict['action'] = array(
array( 'transition_post_status', array( PodsInit::$meta, 'save_post_detect_new' ), 10, 3 ), array( 'transition_post_status', array( PodsInit::$meta, 'save_post_detect_new' ), 10, 3 ),
array( 'save_post', array( PodsInit::$meta, 'save_post' ), 10, 2 ), array( 'save_post', array( PodsInit::$meta, 'save_post' ), 10, 3 ),
array( 'wp_insert_post_data', array( PodsInit::$meta, 'save_post_track_changed_fields' ), 10, 2 ), array( 'wp_insert_post_data', array( PodsInit::$meta, 'save_post_track_changed_fields' ), 10, 2 ),
); );
} elseif ( 'taxonomy' === $object_type ) { } elseif ( 'taxonomy' === $object_type ) {
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
Plugin Name: Pods - Custom Content Types and Fields Plugin Name: Pods - Custom Content Types and Fields
Plugin URI: https://pods.io/ Plugin URI: https://pods.io/
Description: Pods is a framework for creating, managing, and deploying customized content types and fields Description: Pods is a framework for creating, managing, and deploying customized content types and fields
Version: 2.7.15 Version: 2.7.16.1
Author: Pods Framework Team Author: Pods Framework Team
Author URI: https://pods.io/about/ Author URI: https://pods.io/about/
Text Domain: pods Text Domain: pods
...@@ -36,7 +36,7 @@ if ( defined( 'PODS_VERSION' ) || defined( 'PODS_DIR' ) ) { ...@@ -36,7 +36,7 @@ if ( defined( 'PODS_VERSION' ) || defined( 'PODS_DIR' ) ) {
add_action( 'init', 'pods_deactivate_pods_ui' ); add_action( 'init', 'pods_deactivate_pods_ui' );
} else { } else {
// Current version // Current version
define( 'PODS_VERSION', '2.7.15' ); define( 'PODS_VERSION', '2.7.16.1' );
// Version tracking between DB updates themselves // Version tracking between DB updates themselves
define( 'PODS_DB_VERSION', '2.3.5' ); define( 'PODS_DB_VERSION', '2.3.5' );
......
This diff is collapsed.
...@@ -80,7 +80,7 @@ $pick_object = trim( pods_v_sanitized( 'pick_object', $field ) . '-' . pods_v_sa ...@@ -80,7 +80,7 @@ $pick_object = trim( pods_v_sanitized( 'pick_object', $field ) . '-' . pods_v_sa
'maxlength' => 50, 'maxlength' => 50,
'data-sluggable' => 'field_data[' . $pods_i . '][label]', 'data-sluggable' => 'field_data[' . $pods_i . '][label]',
), ),
'class' => 'pods-validate pods-validate-required pods-slugged-lower', 'class' => 'pods-validate pods-validate-required pods-slugged-lower pods-slugged-sanitize-title',
) )
); );
?> ?>
......
...@@ -45,7 +45,7 @@ $args = array( ...@@ -45,7 +45,7 @@ $args = array(
if ( $use_date ) { if ( $use_date ) {
$args['dateFormat'] = PodsForm::field_method( $form_field_type, 'format_date', $options, true ); $args['dateFormat'] = PodsForm::field_method( $form_field_type, 'format_date', $options, true );
$args['altFormat'] = PodsForm::field_method( $form_field_type, 'convert_format', $mysql_date_format ); $args['altFormat'] = PodsForm::field_method( $form_field_type, 'convert_format', $mysql_date_format, array( 'type' => 'date' ) );
$args['changeMonth'] = true; $args['changeMonth'] = true;
$args['changeYear'] = true; $args['changeYear'] = true;
$args['firstDay'] = (int) get_option( 'start_of_week', 0 ); $args['firstDay'] = (int) get_option( 'start_of_week', 0 );
...@@ -57,8 +57,9 @@ if ( $use_date ) { ...@@ -57,8 +57,9 @@ if ( $use_date ) {
} }
if ( $use_time ) { if ( $use_time ) {
$args['timeFormat'] = PodsForm::field_method( $form_field_type, 'format_time', $options, true ); $args['timeFormat'] = PodsForm::field_method( $form_field_type, 'format_time', $options, true );
$args['altTimeFormat'] = PodsForm::field_method( $form_field_type, 'convert_format', $mysql_time_format ); $args['altTimeFormat'] = PodsForm::field_method( $form_field_type, 'convert_format', $mysql_time_format, array( 'type' => 'time' ) );
$args['ampm'] = ( false !== stripos( $args['timeFormat'], 'tt' ) ); $args['ampm'] = ( false !== stripos( $args['timeFormat'], 'tt' ) );
$args['parse'] = 'loose';
} }
$mysql_format = ''; $mysql_format = '';
...@@ -97,7 +98,7 @@ switch ( $form_field_type ) { ...@@ -97,7 +98,7 @@ switch ( $form_field_type ) {
$date = PodsForm::field_method( $form_field_type, 'createFromFormat', $format, (string) $value ); $date = PodsForm::field_method( $form_field_type, 'createFromFormat', $format, (string) $value );
$date_default = PodsForm::field_method( $form_field_type, 'createFromFormat', $mysql_format, (string) $value ); $date_default = PodsForm::field_method( $form_field_type, 'createFromFormat', $mysql_format, (string) $value );
$formatted_value = $value; $formatted_value = PodsForm::field_method( $form_field_type, 'format_value_display', $value, $options, true );
$mysql_value = $value; $mysql_value = $value;
$empty_values = array( $empty_values = array(
...@@ -126,8 +127,13 @@ if ( ...@@ -126,8 +127,13 @@ if (
} }
if ( $html5 ) { if ( $html5 ) {
// HTML5 uses mysql date format. /**
$value = $mysql_value; * HTML5 uses mysql date format separated with a T.
* @link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/datetime-local
*/
$value = str_replace( ' ', 'T', $mysql_value );
} else {
$value = $formatted_value;
} }
} }
...@@ -146,15 +152,11 @@ $attributes = PodsForm::merge_attributes( $attributes, $name, $form_field_type, ...@@ -146,15 +152,11 @@ $attributes = PodsForm::merge_attributes( $attributes, $name, $form_field_type,
<input<?php PodsForm::attributes( $attributes, $name, $form_field_type, $options ); ?> /> <input<?php PodsForm::attributes( $attributes, $name, $form_field_type, $options ); ?> />
<script> <script>
jQuery( function () { jQuery( function ( $ ) {
var $container = jQuery( '<div>' ).appendTo( 'body' ).addClass( 'pods-compat-container' ), var $container = $( '<div>' ).appendTo( 'body' ).addClass( 'pods-compat-container' ),
$element = jQuery( 'input#<?php echo esc_js( $attributes['id'] ); ?>' ), $element = $( 'input#<?php echo esc_js( $attributes['id'] ); ?>' ),
beforeShow = { $alt = null,
'beforeShow': function( textbox, instance) { args = <?php echo wp_json_encode( $args ); ?>;
jQuery( '#ui-datepicker-div' ).appendTo( $container );
}
},
args = jQuery.extend( <?php echo json_encode( $args ); ?>, beforeShow );
<?php <?php
if ( 'text' !== $type ) { if ( 'text' !== $type ) {
...@@ -165,38 +167,44 @@ $attributes = PodsForm::merge_attributes( $attributes, $name, $form_field_type, ...@@ -165,38 +167,44 @@ $attributes = PodsForm::merge_attributes( $attributes, $name, $form_field_type,
input.setAttribute( 'type', '<?php echo $type; ?>' ); input.setAttribute( 'type', '<?php echo $type; ?>' );
var notADateValue = 'not-a-date'; var notADateValue = 'not-a-date';
input.setAttribute('value', notADateValue); input.setAttribute( 'value', notADateValue );
return (input.value !== notADateValue); return ( input.value !== notADateValue );
} }
if ( ! podsCheckHtml5() ) { if ( ! podsCheckHtml5() ) {
args = altField( args, $element );
$element.val( '<?php echo esc_js( $formatted_value ); ?>' ); $element.val( '<?php echo esc_js( $formatted_value ); ?>' );
$element.<?php echo esc_js( $method ); ?>( args ); jQueryField();
} }
<?php <?php
} else { } else {
?> ?>
args = altField( args, $element ); jQueryField();
$element.<?php echo esc_js( $method ); ?>( args );
<?php <?php
}//end if } //end if
?> ?>
function altField( args, el ) { function jQueryField() {
var $el = $( el ),
$alt = $el.clone();
// Create alt field.
$alt = $element.clone();
$alt.attr( 'type', 'hidden' ); $alt.attr( 'type', 'hidden' );
$alt.val( '<?php echo esc_attr( $mysql_value ) ?>' ); $alt.val( '<?php echo esc_attr( $mysql_value ) ?>' );
$el.after( $alt ); $element.after( $alt );
$element.attr( 'name', $element.attr( 'name' ) + '__ui' );
$el.attr( 'name', $el.attr( 'name' ) + '__ui' ); $element.attr( 'id', $element.attr( 'id' ) + '__ui' );
$el.attr( 'id', $el.attr( 'id' ) + '__ui' );
// Add alt field option.
args.altField = 'input#' + $alt.attr( 'id' ); args.altField = 'input#' + $alt.attr( 'id' );
// Fix manual user input changes.
args.onClose = function() {
$element.<?php echo esc_js( $method ); ?>( 'setDate', $element.val() );
};
// Wrapper.
args.beforeShow = function( textbox, instance ) {
$( '#ui-datepicker-div' ).appendTo( $container );
};
return args; $element.<?php echo esc_js( $method ); ?>( args );
}; }
} ); } );
</script> </script>
...@@ -513,40 +513,55 @@ ...@@ -513,40 +513,55 @@
sluggable_single : function ( sluggable ) { sluggable_single : function ( sluggable ) {
var $slug = $( 'input[name="' + sluggable.replace( '[', '\\[' ).replace( ']', '\\]' ) + '"]' ); var $slug = $( 'input[name="' + sluggable.replace( '[', '\\[' ).replace( ']', '\\]' ) + '"]' );
if ( $slug[ 0 ] ) { if ( $slug.length ) {
$( 'form' ).on( 'change', 'input[name="' + sluggable.replace( '[', '\\[' ).replace( ']', '\\]' ) + '"]', function () { $slug.on( 'change', function () {
if ( 0 < $( this ).val().length ) { // Strip HTML/code.
var slug = $( this ).val(); var slug = $( this ).val().replace( /<( ?:. )*?>/g, '' ),
name = $( this ).prop( 'name' ).replace( '[', '\\[' ).replace( ']', '\\]' );
slug = slug.replace( /<( ?:. )*?>/g, '' ).replace( /([^0-9a-zA-Z\_\- ])/g, '' );
if ( slug.length ) {
// update fields
$( 'input.pods-slugged[data-sluggable="' + $( this ).prop( 'name' ).replace( '[', '\\[' ).replace( ']', '\\]' ) + '"]' ).each( function () { var slug_lower = slug.toLowerCase(),
if ( '' === $( this ).val() ) { slug_sanitized = slug.replace( /([^0-9a-zA-Z\_\- ])/g, '' ),
$( this ).val( slug.charAt( 0 ).toUpperCase() + slug.slice( 1 ) ); slug_sanitized_lower = slug_sanitized.toLowerCase();
$( this ).trigger( 'change' );
} slug = slug.charAt( 0 ).toUpperCase() + slug.slice( 1 );
} );
$( 'input.pods-slugged-lower[data-sluggable="' + $( this ).prop( 'name' ).replace( '[', '\\[' ).replace( ']', '\\]' ) + '"]' ).each( function () { // Update elements and trigger change.
if ( '' === $( this ).val() ) { $( '.pods-slugged[data-sluggable="' + name + '"], .pods-slugged-lower[data-sluggable="' + name + '"]' ).each( function() {
$( this ).val( slug.toLowerCase() ); var $this = $( this ),
$( this ).trigger( 'change' ); lowercase = $this.hasClass( 'pods-slugged-lower' ),
} sanitize_title = $this.hasClass( 'pods-slugged-sanitize-title' ),
val = slug;
if ( sanitize_title ) {
val = slug_sanitized;
if ( lowercase ) {
val = slug_sanitized_lower;
}
} else if ( lowercase ) {
val = slug_lower;
}
switch ( this.nodeName.toLowerCase() ) {
case 'input':
case 'textarea':
// Update fields.
if ( '' === $this.val() ) {
$this.val( val );
}
break;
default:
// Update html.
$this.html( val );
break;
}
$this.trigger( 'change' );
} ); } );
// update elements and trigger change
$( '.pods-slugged-lower[data-sluggable="' + $( this ).prop( 'name' ).replace( '[', '\\[' ).replace( ']', '\\]' ) + '"]:not(input )' )
.html( slug.toLowerCase() )
.trigger( 'change' );
// trigger change
$( '.pods-slugged[data-sluggable="' + $( this ).prop( 'name' ).replace( '[', '\\[' ).replace( ']', '\\]' ) + '"]:not(input )' )
.html( slug.charAt( 0 ).toUpperCase() + slug.slice( 1 ) )
.trigger( 'change' );
} }
} ); } );
if ( 0 < $slug.val().length ) { if ( $slug.val().length ) {
$slug.trigger( 'change' ); $slug.trigger( 'change' );
} }
} }
......
...@@ -28,9 +28,6 @@ export const IframeFrame = wp.media.view.Frame.extend( { ...@@ -28,9 +28,6 @@ export const IframeFrame = wp.media.view.Frame.extend( {
this.on( 'title:create:default', this.createTitle, this ); this.on( 'title:create:default', this.createTitle, this );
this.title.mode( 'default' ); this.title.mode( 'default' );
this.on( 'title:render', function ( view ) {
view.$el.append( '<span class="dashicons dashicons-arrow-down"></span>' );
} );
}, },
initState: function () { initState: function () {
......
...@@ -77,10 +77,16 @@ ...@@ -77,10 +77,16 @@
</nav> </nav>
<?php <?php
$blogID = get_current_blog_id(); $blogID = get_current_blog_id();
$inEmployers = get_post_meta( $post->ID, 'section', true) == 'employers';
$phone = '+37064902392'; $phone = '+37064902392';
$phoneUI = '+370 649 02392'; $phoneUI = '+370 649 02392';
if ($blogID == 1 && $inEmployers):
$phone = '+37065553216';
$phoneUI = '+370 655 53216';
endif;
if ($blogID == 2): if ($blogID == 2):
$phone = '+37166100328'; $phone = '+37166100328';
$phoneUI = '+371 661 00328'; $phoneUI = '+371 661 00328';
...@@ -99,7 +105,7 @@ ...@@ -99,7 +105,7 @@
<?php <?php
global $post; global $post;
if ( get_post_meta( $post->ID, 'section', true) == 'employers'): if ( $inEmployers ):
$contactsPage = new WP_Query( array( $contactsPage = new WP_Query( array(
'numberposts' => 1, 'numberposts' => 1,
'post_type' => 'page', 'post_type' => 'page',
......
...@@ -14,7 +14,7 @@ wp core update-db --network; ...@@ -14,7 +14,7 @@ wp core update-db --network;
wp plugin update loco-translate --version=2.3.1; wp plugin update loco-translate --version=2.3.1;
# wp plugin install pods --version=2.7.15 --activate-network; # wp plugin install pods --version=2.7.15 --activate-network;
wp plugin update pods --version=2.7.15; wp plugin update pods --version=2.7.16.1;
# wp plugin install polylang --version=2.6.6 --activate-network; # wp plugin install polylang --version=2.6.6 --activate-network;
wp plugin update polylang --version=2.6.6; wp plugin update polylang --version=2.6.6;
......
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