Commit 69abaeb5 authored by Simonas's avatar Simonas

Header phone LT updated

parent 83e7d371
......@@ -1843,6 +1843,9 @@ class Pods implements Iterator {
if ( $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;
......@@ -1870,7 +1873,6 @@ class Pods implements Iterator {
$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 ( $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 );
......
......@@ -2890,7 +2890,7 @@ class PodsAPI {
if ( ( $field['type'] !== $old_type || $old_simple != $simple ) && empty( $definition ) ) {
pods_query( "ALTER TABLE `@wp_pods_{$params->pod}` DROP COLUMN `{$old_name}`", false );
} 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;
if ( 0 < strlen( $old_definition ) ) {
......@@ -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 );
// Input values are unslashed. Unslash database values as well to ensure correct comparison.
$custom = pods_unslash( $custom );
if ( empty( $value ) || empty( $custom ) ) {
$value = '';
} elseif ( ! empty( $custom ) ) {
......@@ -4891,13 +4894,13 @@ class PodsAPI {
$field = $pod->fields[ $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 ( 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'];
}
} elseif ( in_array( $field['type'], PodsForm::file_field_types() ) ) {
......@@ -6083,6 +6086,7 @@ class PodsAPI {
$pod = array(
'id' => 0,
'name' => $params->name,
'object' => $params->name,
'label' => __( 'Pods', 'pods' ),
'type' => 'post_type',
'storage' => 'meta',
......@@ -6095,6 +6099,7 @@ class PodsAPI {
$pod = array(
'id' => 0,
'name' => $params->name,
'object' => $params->name,
'label' => __( 'Pod Fields', 'pods' ),
'type' => 'post_type',
'storage' => 'meta',
......@@ -8696,12 +8701,23 @@ class PodsAPI {
$info['table'] = ( empty( $object ) ? $name : $object );
$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 ) );
$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'];
if ( ! empty( $field ) ) {
if ( ! is_array( $field ) ) {
if ( is_string( $pod ) ) {
$pod = pods( $pod );
}
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 {
add_action( 'admin_init', array( $this, 'admin_init' ), 9 );
// Menus
add_action( 'admin_menu', array( $this, 'admin_menu' ), 99 );
add_action( 'admin_menu', array( $this, 'admin_menu' ), 9 );
// AJAX for Admin
add_action( 'wp_ajax_pods_admin', array( $this, 'admin_ajax' ) );
......@@ -3641,106 +3641,110 @@ class PodsAdmin {
'label' => 'Pods',
'description' => __( 'Debug information for Pods installations.', 'pods' ),
'fields' => array(
'pods-server-software' => array(
'pods-server-software' => array(
'label' => __( 'Server Software', 'pods' ),
'value' => ! empty( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : 'N/A',
),
'pods-user-agent' => array(
'pods-user-agent' => array(
'label' => __( 'Your User Agent', 'pods' ),
'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' ),
'value' => session_save_path(),
),
'pods-session-save-path-exists' => array(
'pods-session-save-path-exists' => array(
'label' => __( 'Session Save Path Exists', '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' ),
'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' ),
'value' => ini_get( 'session.gc_maxlifetime' ),
),
'pods-opcode-cache-apc' => array(
'pods-opcode-cache-apc' => array(
'label' => __( 'Opcode Cache: Apc', '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' ),
'value' => class_exists( 'eaccelerator_put' ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ),
),
'pods-opcode-cache-opcache' => array(
'pods-opcode-cache-opcache' => array(
'label' => __( 'Opcode Cache: OPcache', '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' ),
'value' => class_exists( 'xcache_set' ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ),
),
'pods-object-cache-apc' => array(
'pods-object-cache-apc' => array(
'label' => __( 'Object Cache: APC', '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' ),
'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' ),
'value' => class_exists( 'Memcache' ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ),
),
'pods-object-cache-memcached' => array(
'pods-object-cache-memcached' => array(
'label' => __( 'Object Cache: Memcached', 'pods' ),
'value' => class_exists( 'Memcached' ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ),
),
'pods-object-cache-redis' => array(
'pods-object-cache-redis' => array(
'label' => __( 'Object Cache: Redis', 'pods' ),
'value' => class_exists( 'Redis' ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ),
),
'pods-memory-current-usage' => array(
'pods-memory-current-usage' => array(
'label' => __( 'Current Memory Usage', 'pods' ),
'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' ),
'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' ),
'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' ),
'value' => PODS_DIR,
),
'pods-developer' => array(
'pods-developer' => array(
'label' => __( 'Pods Developer Activated' ),
'value' => ( pods_developer() ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ),
),
'pods-tableless-mode' => array(
'pods-tableless-mode' => array(
'label' => __( 'Pods Tableless Mode Activated', 'pods' ),
'value' => ( pods_tableless() ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ),
),
'pods-light-mode' => array(
'pods-light-mode' => array(
'label' => __( 'Pods Light Mode Activated', 'pods' ),
'value' => ( pods_light() ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ),
),
'pods-strict' => array(
'pods-strict' => array(
'label' => __( 'Pods Strict Activated' ),
'value' => ( pods_strict() ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ),
),
'pods-allow-deprecated' => array(
'pods-allow-deprecated' => array(
'label' => __( 'Pods Allow Deprecated' ),
'value' => ( pods_allow_deprecated() ) ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ),
),
'pods-api-cache' => array(
'pods-api-cache' => array(
'label' => __( 'Pods API Cache Activated' ),
'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 {
// Check if Pod is a Modal Window
if ( pods_is_modal_window() ) {
add_filter( 'body_class', array( $this, 'add_classes_to_body_class' ) );
add_filter( 'admin_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_modal_body' ) );
}
// Deal with specifics on admin pages
......@@ -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;
}
......@@ -1872,6 +1876,7 @@ class PodsInit {
$conditionals[] = 'pods_strict';
$conditionals[] = 'pods_allow_deprecated';
$conditionals[] = 'pods_api_cache';
$conditionals[] = 'pods_shortcode_allow_evaluate_tags';
return $conditionals;
}
}
......@@ -4634,6 +4634,9 @@ class PodsUI {
'filter_*',
'view' . $this->num,
'page' . $this->num,
'post_type',
'taxonomy',
'action' . $this->num,
), $this->exclusion()
);
......@@ -4653,9 +4656,21 @@ class PodsUI {
if ( false !== $this->pagination ) {
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="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="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( $classes ); ?>" title="<?php esc_attr_e( 'Go to the previous page', 'pods' ); ?>" href="<?php echo $prev_link; ?>">&lsaquo;</a>
<?php
if ( true == $header ) {
?>
......@@ -4680,9 +4695,16 @@ class PodsUI {
<span class="total-pages"><?php echo number_format_i18n( $total_pages ); ?></span></span>
<?php
}//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="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="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( $classes ); ?>" title="<?php esc_attr_e( 'Go to the last page', 'pods' ); ?>" href="<?php echo $last_link; ?>">&raquo</a>
<?php
}//end if
}//end if
......@@ -4914,8 +4936,7 @@ class PodsUI {
$author_restrict = false;
if ( ! empty( $this->restrict['author_restrict'] ) && $restrict === $this->restrict['author_restrict'] ) {
$restricted = false;
$restricted = false;
$author_restrict = true;
if ( is_object( $this->pod ) ) {
......@@ -4927,33 +4948,58 @@ class PodsUI {
if ( pods_is_admin( array( 'pods', 'pods_content' ) ) ) {
$restricted = false;
} elseif ( 'manage' === $action ) {
if ( ! in_array( 'edit', $this->actions_disabled ) && ( current_user_can( 'pods_edit_' . $this->pod->pod ) || current_user_can( 'pods_edit_others_' . $this->pod->pod ) ) ) {
$restricted = 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;
} elseif ( current_user_can( 'pods_' . $action . '_' . $this->pod->pod ) || current_user_can( 'pods_' . $action . '_others_' . $this->pod->pod ) ) {
$restricted = false;
} else {
// Disable legacy check.
$author_restrict = false;
$pod = $this->pod;
if ( ! $pod->id() && $row ) {
$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
/*
@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
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 ) {
$relation = 'OR';
......@@ -4969,7 +5015,7 @@ class PodsUI {
if ( is_array( $match ) ) {
$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 ) {
$match_relation = 'OR';
......@@ -5088,42 +5134,28 @@ class PodsUI {
}//end if
}//end foreach
if ( ! empty( $author_restrict ) ) {
if ( is_object( $this->pod ) && 'manage' === $action ) {
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 ) ) {
$okay = false;
}
}
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;
}
// Legacy author restrict check.
if ( $author_restrict && ! $okay && ! empty( $row ) ) {
foreach ( $this->restrict['author_restrict'] as $key => $val ) {
$author_restricted = $this->get_field( $key );
if ( is_array( $val ) ) {
foreach ( $val as $v ) {
if ( in_array( $v, $author_restricted ) ) {
$okay = true;
}
if ( ! empty( $author_restricted ) ) {
if ( ! is_array( $author_restricted ) ) {
$author_restricted = (array) $author_restricted;
}
$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
if ( $okay ) {
......@@ -5131,7 +5163,10 @@ class PodsUI {
}
}//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 );
}
......
......@@ -169,6 +169,25 @@ class PodsField_Boolean extends PodsField {
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}
*/
......
......@@ -166,6 +166,19 @@ class PodsField_Date extends PodsField_DateTime {
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}
*/
......
......@@ -281,8 +281,8 @@ class PodsField_DateTime extends PodsField {
$value = implode( ' ', $value );
}
// Format Value
$value = $this->format_value_display( $value, $options, true );
// @todo Remove? Format Value (done in field template).
//$value = $this->format_value_display( $value, $options, true );
$field_type = static::$type;
......@@ -321,11 +321,8 @@ class PodsField_DateTime extends PodsField {
$js = false;
}
$format = $this->format_datetime( $options, $js );
if ( $js ) {
$format = $this->convert_format( $format, array( 'source' => 'jquery_ui' ) );
}
// Value should always be passed as storage format since 2.7.15.
$format = static::$storage_format;
$check = $this->convert_date( $value, static::$storage_format, $format, true );
......@@ -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 ) {
$js = true;
if ( 'custom' !== pods_v( static::$type . '_type', $options, 'format' ) ) {
$js = false;
}
$format = $this->format_datetime( $options, $js );
if ( $js ) {
$format = $this->convert_format( $format, array( 'source' => 'jquery_ui' ) );
}
// Value should always be passed as storage format since 2.7.15.
$format = static::$storage_format;
if ( ! empty( $value ) && ( 0 === (int) pods_v( static::$type . '_allow_empty', $options, 1 ) || ! in_array(
$value, array(
......@@ -446,12 +437,25 @@ class PodsField_DateTime extends PodsField {
*/
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;
}
$format = $this->format_datetime( $options, $js );
if ( $js ) {
$format = $this->convert_format( $format, array( 'source' => 'jquery_ui' ) );
$format = $this->format_datetime( $options, $js );
}
return $format;
......@@ -495,24 +499,33 @@ class PodsField_DateTime extends PodsField {
switch ( (string) pods_v( static::$type . '_type', $options, 'format', true ) ) {
case 'wp':
$format = get_option( 'date_format' );
if ( $js ) {
$format = $this->convert_format( $format, array( 'source' => 'php' ) );
$format = $this->convert_format( $format, array( 'source' => 'php', 'type' => 'date' ) );
}
break;
case 'custom':
if ( ! $js ) {
$format = pods_v( static::$type . '_format_custom', $options, '' );
} else {
$format = pods_v( static::$type . '_format_custom_js', $options, '' );
if ( empty( $format ) ) {
$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;
default:
$date_format = $this->get_date_formats( $js );
$format = $date_format[ pods_v( static::$type . '_format', $options, 'ymd_dash', true ) ];
break;
}//end switch
......@@ -549,10 +562,11 @@ class PodsField_DateTime extends PodsField {
$format = pods_v( static::$type . '_time_format_custom', $options, '' );
} else {
$format = pods_v( static::$type . '_time_format_custom_js', $options, '' );
$js = false; // Already in JS format.
if ( empty( $format ) ) {
$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 {
default:
$format = get_option( 'time_format' );
if ( $js ) {
$format = $this->convert_format( $format, array( 'source' => 'php' ) );
}
break;
}//end switch
......@@ -601,8 +611,9 @@ class PodsField_DateTime extends PodsField {
$filter = 'pods_form_ui_field_date_formats';
if ( $js ) {
// @todo Method parameters? (Not supported by array_map)
$date_format = array_map( array( $this, 'convert_format' ), $date_format );
foreach ( $date_format as $key => $value ) {
$date_format[ $key ] = $this->convert_format( $value, array( 'type' => 'date' ) );
}
$filter = 'pods_form_ui_field_date_js_formats';
}
......@@ -637,8 +648,9 @@ class PodsField_DateTime extends PodsField {
$filter = 'pods_form_ui_field_time_formats';
if ( $js ) {
// @todo Method parameters? (Not supported by array_map)
$time_format = array_map( array( $this, 'convert_format' ), $time_format );
foreach ( $time_format as $key => $value ) {
$time_format[ $key ] = $this->convert_format( $value, array( 'type' => 'time' ) );
}
$filter = 'pods_form_ui_field_time_js_formats';
}
......@@ -665,8 +677,9 @@ class PodsField_DateTime extends PodsField {
$filter = 'pods_form_ui_field_time_formats_24';
if ( $js ) {
// @todo Method parameters? (Not supported by array_map)
$time_format_24 = array_map( array( $this, 'convert_format' ), $time_format_24 );
foreach ( $time_format_24 as $key => $value ) {
$time_format_24[ $key ] = $this->convert_format( $value, array( 'type' => 'time' ) );
}
$filter = 'pods_form_ui_field_time_js_formats_24';
}
......@@ -784,55 +797,64 @@ class PodsField_DateTime extends PodsField {
$args = array_merge(
array(
'source' => 'php',
'type' => 'date',
// 'jquery_ui' for reverse.
), $args
);
// Keep keys and values sorted by string length.
$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',
// 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 ( 'time' === $args['type'] || 'time' === static::$type ) {
$symbols = array(
// 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 ) {
// Millisecond
$symbols['v'] = 'l';
if ( version_compare( PHP_VERSION, '7.0.0' ) >= 0 ) {
// Millisecond.
$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'] ) {
......
......@@ -169,6 +169,19 @@ class PodsField_Time extends PodsField_DateTime {
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}
*/
......@@ -209,7 +222,10 @@ class PodsField_Time extends PodsField_DateTime {
if ( empty( $format ) ) {
$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 {
$format = get_option( 'time_format' );
if ( $js ) {
$format = $this->convert_format( $format, array( 'source' => 'php' ) );
$format = $this->convert_format( $format, array( 'source' => 'php', 'type' => 'time' ) );
}
break;
......
......@@ -374,6 +374,12 @@ class Pods_Migrate_Packages extends PodsComponent {
$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 ) {
if ( isset( $field['id'] ) && ! isset( $existing_fields[ $field['name'] ] ) ) {
unset( $pod['fields'][ $k ]['id'] );
......@@ -400,13 +406,14 @@ class Pods_Migrate_Packages extends PodsComponent {
}
}//end foreach
$api->save_pod( $pod );
if ( $api->save_pod( $pod ) ) {
if ( ! isset( $found['pods'] ) ) {
$found['pods'] = array();
}
if ( ! isset( $found['pods'] ) ) {
$found['pods'] = array();
$found['pods'][ $pod['name'] ] = $pod['label'];
}
$found['pods'][ $pod['name'] ] = $pod['label'];
}//end foreach
}//end if
......
......@@ -57,16 +57,6 @@ class Pods_Roles extends PodsComponent {
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' );
$roles = array();
......@@ -447,7 +437,12 @@ class Pods_Roles extends PodsComponent {
$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( 'pods_roles_get_capabilities', $capabilities );
......
......@@ -1383,13 +1383,14 @@ function pods_absint( $maybeint, $strict = true, $allow_negative = false ) {
/**
* Functions like str_replace except it will restrict $occurrences
*
* @since 2.0
*
* @param mixed $find
* @param mixed $replace
* @param string $string
* @param int $occurrences (optional)
*
* @return mixed
* @version 2.0
*/
function pods_str_replace( $find, $replace, $string, $occurrences = - 1 ) {
......@@ -1416,8 +1417,12 @@ function pods_str_replace( $find, $replace, $string, $occurrences = - 1 ) {
} else {
$find = '/' . preg_quote( $find, '/' ) . '/';
}
return preg_replace( $find, $replace, $string, $occurrences );
if ( is_string( $string ) ) {
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 ) {
}
/**
* 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
* @param bool $sanitize Whether to sanitize tags
* @since 2.1
*
* @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 ) ) {
foreach ( $tags as $k => $tag ) {
$tags[ $k ] = pods_evaluate_tags( $tag, $sanitize );
}
return $tags;
} elseif ( is_object( $tags ) ) {
$tags = get_object_vars( $tags );
}
foreach ( $tags as $k => $tag ) {
$tags[ $k ] = pods_evaluate_tags( $tag, $sanitize );
}
if ( is_object( $tags ) ) {
$tags = get_object_vars( $tags );
$tags = (object) $tags;
// Evaluate array and cast as object.
$tags = (object) pods_evaluate_tags( $tags );
return $tags;
}
$callback = 'pods_evaluate_tag';
if ( true === $sanitize ) {
$callback = 'pods_evaluate_tag_sanitized';
}
return preg_replace_callback( '/({@(.*?)})/m', $callback, (string) $tags );
return preg_replace_callback(
'/({@(.*?)})/m',
function ( $tag ) use ( $sanitize, $fallback ) {
return pods_evaluate_tag( $tag, $sanitize, $fallback );
},
(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 ) {
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
* @param bool $sanitize Whether to sanitize tags
* @since 2.1
*
* @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;
// Handle pods_evaluate_tags
if ( is_array( $tag ) ) {
if ( ! isset( $tag[2] ) && strlen( trim( $tag[2] ) ) < 1 ) {
return '';
if ( ! isset( $tag[2] ) && '' === trim( $tag[2] ) ) {
if ( null === $fallback ) {
return '';
}
return $fallback;
}
$tag = $tag[2];
......@@ -1546,8 +1551,12 @@ function pods_evaluate_tag( $tag, $sanitize = false ) {
$tag = trim( $tag, ' {@}' );
$tag = explode( '.', $tag );
if ( empty( $tag ) || ! isset( $tag[0] ) || strlen( trim( $tag[0] ) ) < 1 ) {
return '';
if ( empty( $tag ) || ! isset( $tag[0] ) || '' === trim( $tag[0] ) ) {
if ( null === $fallback ) {
return '';
}
return $fallback;
}
// Fix formatting that may be after the first .
......@@ -1584,16 +1593,16 @@ function pods_evaluate_tag( $tag, $sanitize = false ) {
);
if ( in_array( $tag[0], $single_supported, true ) ) {
$value = pods_v( '', $tag[0], '', true );
} elseif ( 1 == count( $tag ) ) {
$value = pods_v( $tag[0], 'get', '', true );
} elseif ( 2 == count( $tag ) ) {
$value = pods_v( $tag[1], $tag[0], '', true );
$value = pods_v( '', $tag[0], null );
} elseif ( 1 === count( $tag ) ) {
$value = pods_v( $tag[0], 'get', null );
} elseif ( 2 === count( $tag ) ) {
$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 );
}
......@@ -1601,12 +1610,19 @@ function pods_evaluate_tag( $tag, $sanitize = false ) {
$value = pods_serial_comma( $value );
}
if ( null === $value ) {
$value = '';
}
if ( $sanitize ) {
$value = pods_sanitize( $value );
}
return $value;
if ( null !== $fallback && '' === $value ) {
$value = $fallback;
}
return $value;
}
/**
......
......@@ -459,6 +459,21 @@ function pods_api_cache() {
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.
*
......@@ -784,7 +799,8 @@ function pods_shortcode_run( $tags, $content = null ) {
$offset = max( $offset, 0 );
}
$defaults = array(
// Query related tags separated to use later.
$default_query_tags = array(
'use_current' => false,
'name' => null,
'id' => null,
......@@ -806,21 +822,26 @@ function pods_shortcode_run( $tags, $content = null ) {
'filters_location' => 'before',
'pagination_label' => null,
'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 ) ) {
$tags = array_merge( $defaults, $tags );
} else {
......@@ -853,7 +874,9 @@ function pods_shortcode_run( $tags, $content = null ) {
}
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 );
if ( ! empty( $pod ) ) {
......@@ -891,16 +914,16 @@ function pods_shortcode_run( $tags, $content = null ) {
if ( ! empty( $tags['slug'] ) ) {
$id = $tags['slug'];
if ( defined( 'PODS_SHORTCODE_ALLOW_EVALUATE_TAGS' ) && PODS_SHORTCODE_ALLOW_EVALUATE_TAGS ) {
$id = pods_evaluate_tags( $id );
if ( pods_shortcode_allow_evaluate_tags() ) {
$id = pods_evaluate_tags( $id, true );
}
}
if ( ! empty( $tags['id'] ) ) {
$id = $tags['id'];
if ( defined( 'PODS_SHORTCODE_ALLOW_EVALUATE_TAGS' ) && PODS_SHORTCODE_ALLOW_EVALUATE_TAGS ) {
$id = pods_evaluate_tags( $id );
if ( pods_shortcode_allow_evaluate_tags() ) {
$id = pods_evaluate_tags( $id, true );
}
if ( is_numeric( $id ) ) {
......@@ -937,16 +960,16 @@ function pods_shortcode_run( $tags, $content = null ) {
if ( 0 < strlen( $tags['where'] ) ) {
$params['where'] = $tags['where'];
if ( defined( 'PODS_SHORTCODE_ALLOW_EVALUATE_TAGS' ) && PODS_SHORTCODE_ALLOW_EVALUATE_TAGS ) {
$params['where'] = pods_evaluate_tags( html_entity_decode( $params['where'] ) );
if ( pods_shortcode_allow_evaluate_tags() ) {
$params['where'] = pods_evaluate_tags( html_entity_decode( $params['where'] ), true, '""' );
}
}
if ( 0 < strlen( $tags['having'] ) ) {
$params['having'] = $tags['having'];
if ( defined( 'PODS_SHORTCODE_ALLOW_EVALUATE_TAGS' ) && PODS_SHORTCODE_ALLOW_EVALUATE_TAGS ) {
$params['having'] = pods_evaluate_tags( html_entity_decode( $params['having'] ) );
if ( pods_shortcode_allow_evaluate_tags() ) {
$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 ) {
$no_conflict['action'] = array(
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 ),
);
} elseif ( 'taxonomy' === $object_type ) {
......
......@@ -3,7 +3,7 @@
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.15
Version: 2.7.16.1
Author: Pods Framework Team
Author URI: https://pods.io/about/
Text Domain: pods
......@@ -36,7 +36,7 @@ if ( defined( 'PODS_VERSION' ) || defined( 'PODS_DIR' ) ) {
add_action( 'init', 'pods_deactivate_pods_ui' );
} else {
// Current version
define( 'PODS_VERSION', '2.7.15' );
define( 'PODS_VERSION', '2.7.16.1' );
// Version tracking between DB updates themselves
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
'maxlength' => 50,
'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(
if ( $use_date ) {
$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['changeYear'] = true;
$args['firstDay'] = (int) get_option( 'start_of_week', 0 );
......@@ -57,8 +57,9 @@ if ( $use_date ) {
}
if ( $use_time ) {
$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['parse'] = 'loose';
}
$mysql_format = '';
......@@ -97,7 +98,7 @@ switch ( $form_field_type ) {
$date = PodsForm::field_method( $form_field_type, 'createFromFormat', $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;
$empty_values = array(
......@@ -126,8 +127,13 @@ if (
}
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,
<input<?php PodsForm::attributes( $attributes, $name, $form_field_type, $options ); ?> />
<script>
jQuery( function () {
var $container = jQuery( '<div>' ).appendTo( 'body' ).addClass( 'pods-compat-container' ),
$element = jQuery( 'input#<?php echo esc_js( $attributes['id'] ); ?>' ),
beforeShow = {
'beforeShow': function( textbox, instance) {
jQuery( '#ui-datepicker-div' ).appendTo( $container );
}
},
args = jQuery.extend( <?php echo json_encode( $args ); ?>, beforeShow );
jQuery( function ( $ ) {
var $container = $( '<div>' ).appendTo( 'body' ).addClass( 'pods-compat-container' ),
$element = $( 'input#<?php echo esc_js( $attributes['id'] ); ?>' ),
$alt = null,
args = <?php echo wp_json_encode( $args ); ?>;
<?php
if ( 'text' !== $type ) {
......@@ -165,38 +167,44 @@ $attributes = PodsForm::merge_attributes( $attributes, $name, $form_field_type,
input.setAttribute( 'type', '<?php echo $type; ?>' );
var notADateValue = 'not-a-date';
input.setAttribute('value', notADateValue);
input.setAttribute( 'value', notADateValue );
return (input.value !== notADateValue);
return ( input.value !== notADateValue );
}
if ( ! podsCheckHtml5() ) {
args = altField( args, $element );
$element.val( '<?php echo esc_js( $formatted_value ); ?>' );
$element.<?php echo esc_js( $method ); ?>( args );
jQueryField();
}
<?php
} else {
?>
args = altField( args, $element );
$element.<?php echo esc_js( $method ); ?>( args );
jQueryField();
<?php
}//end if
} //end if
?>
function altField( args, el ) {
var $el = $( el ),
$alt = $el.clone();
function jQueryField() {
// Create alt field.
$alt = $element.clone();
$alt.attr( 'type', 'hidden' );
$alt.val( '<?php echo esc_attr( $mysql_value ) ?>' );
$el.after( $alt );
$el.attr( 'name', $el.attr( 'name' ) + '__ui' );
$el.attr( 'id', $el.attr( 'id' ) + '__ui' );
$element.after( $alt );
$element.attr( 'name', $element.attr( 'name' ) + '__ui' );
$element.attr( 'id', $element.attr( 'id' ) + '__ui' );
// Add alt field option.
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>
......@@ -513,40 +513,55 @@
sluggable_single : function ( sluggable ) {
var $slug = $( 'input[name="' + sluggable.replace( '[', '\\[' ).replace( ']', '\\]' ) + '"]' );
if ( $slug[ 0 ] ) {
$( 'form' ).on( 'change', 'input[name="' + sluggable.replace( '[', '\\[' ).replace( ']', '\\]' ) + '"]', function () {
if ( 0 < $( this ).val().length ) {
var slug = $( this ).val();
slug = slug.replace( /<( ?:. )*?>/g, '' ).replace( /([^0-9a-zA-Z\_\- ])/g, '' );
// update fields
$( 'input.pods-slugged[data-sluggable="' + $( this ).prop( 'name' ).replace( '[', '\\[' ).replace( ']', '\\]' ) + '"]' ).each( function () {
if ( '' === $( this ).val() ) {
$( this ).val( slug.charAt( 0 ).toUpperCase() + slug.slice( 1 ) );
$( this ).trigger( 'change' );
}
} );
$( 'input.pods-slugged-lower[data-sluggable="' + $( this ).prop( 'name' ).replace( '[', '\\[' ).replace( ']', '\\]' ) + '"]' ).each( function () {
if ( '' === $( this ).val() ) {
$( this ).val( slug.toLowerCase() );
$( this ).trigger( 'change' );
}
if ( $slug.length ) {
$slug.on( 'change', function () {
// Strip HTML/code.
var slug = $( this ).val().replace( /<( ?:. )*?>/g, '' ),
name = $( this ).prop( 'name' ).replace( '[', '\\[' ).replace( ']', '\\]' );
if ( slug.length ) {
var slug_lower = slug.toLowerCase(),
slug_sanitized = slug.replace( /([^0-9a-zA-Z\_\- ])/g, '' ),
slug_sanitized_lower = slug_sanitized.toLowerCase();
slug = slug.charAt( 0 ).toUpperCase() + slug.slice( 1 );
// Update elements and trigger change.
$( '.pods-slugged[data-sluggable="' + name + '"], .pods-slugged-lower[data-sluggable="' + name + '"]' ).each( function() {
var $this = $( this ),
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' );
}
}
......
......@@ -28,9 +28,6 @@ export const IframeFrame = wp.media.view.Frame.extend( {
this.on( 'title:create:default', this.createTitle, this );
this.title.mode( 'default' );
this.on( 'title:render', function ( view ) {
view.$el.append( '<span class="dashicons dashicons-arrow-down"></span>' );
} );
},
initState: function () {
......
......@@ -77,10 +77,16 @@
</nav>
<?php
$blogID = get_current_blog_id();
$inEmployers = get_post_meta( $post->ID, 'section', true) == 'employers';
$phone = '+37064902392';
$phoneUI = '+370 649 02392';
if ($blogID == 1 && $inEmployers):
$phone = '+37065553216';
$phoneUI = '+370 655 53216';
endif;
if ($blogID == 2):
$phone = '+37166100328';
$phoneUI = '+371 661 00328';
......@@ -99,7 +105,7 @@
<?php
global $post;
if ( get_post_meta( $post->ID, 'section', true) == 'employers'):
if ( $inEmployers ):
$contactsPage = new WP_Query( array(
'numberposts' => 1,
'post_type' => 'page',
......
......@@ -14,7 +14,7 @@ wp core update-db --network;
wp plugin update loco-translate --version=2.3.1;
# 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 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