← All changes
|
admin/views/sp-framework/classes/fields.class.php
+10
-66
2.4.21
→
2.2.10
View file →
| @@ -1,35 +1,16 @@ | ||
| 1 | -<?php | |
| 1 | +<?php if ( ! defined( 'ABSPATH' ) ) { | |
| 2 | + die; } // Cannot access directly. | |
| 2 | 3 | /** |
| 3 | - * The fields class of the plugin. | |
| 4 | 4 | * |
| 5 | - * @package Smart_Post_Show | |
| 6 | - * @subpackage Smart_Post_Show/views/sp-framework/classes | |
| 5 | + * Fields Class | |
| 6 | + * | |
| 7 | + * @since 1.0.0 | |
| 8 | + * @version 1.0.0 | |
| 7 | 9 | */ |
| 8 | - | |
| 9 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 10 | - die; } // Cannot access directly. | |
| 11 | - | |
| 12 | - | |
| 13 | 10 | if ( ! class_exists( 'SP_PC_Fields' ) ) { |
| 14 | - /** | |
| 15 | - * | |
| 16 | - * Fields Class | |
| 17 | - * | |
| 18 | - * @since 1.0.0 | |
| 19 | - * @version 1.0.0 | |
| 20 | - */ | |
| 21 | 11 | abstract class SP_PC_Fields extends SP_PC_Abstract { |
| 22 | 12 | |
| 23 | - /** | |
| 24 | - * The field constructor. | |
| 25 | - * | |
| 26 | - * @param array $field The field type. | |
| 27 | - * @param string $value The values of the field. | |
| 28 | - * @param string $unique The unique ID for the field. | |
| 29 | - * @param string $where To where show the output CSS. | |
| 30 | - * @param string $parent The parent args. | |
| 31 | - */ | |
| 32 | 13 | public function __construct( $field = array(), $value = '', $unique = '', $where = '', $parent = '' ) { |
| 33 | 14 | $this->field = $field; |
| 34 | 15 | $this->value = $value; |
| 35 | 16 | $this->unique = $unique; |
| @@ -36,14 +17,8 @@ | ||
| 36 | 17 | $this->where = $where; |
| 37 | 18 | $this->parent = $parent; |
| 38 | 19 | } |
| 39 | 20 | |
| 40 | - /** | |
| 41 | - * Field name method. | |
| 42 | - * | |
| 43 | - * @param string $nested_name Nested field name. | |
| 44 | - * @return string | |
| 45 | - */ | |
| 46 | 21 | public function field_name( $nested_name = '' ) { |
| 47 | 22 | |
| 48 | 23 | $field_id = ( ! empty( $this->field['id'] ) ) ? $this->field['id'] : ''; |
| 49 | 24 | $unique_id = ( ! empty( $this->unique ) ) ? $this->unique . '[' . $field_id . ']' : $field_id; |
| @@ -57,14 +32,8 @@ | ||
| 57 | 32 | return $field_name . $nested_name; |
| 58 | 33 | |
| 59 | 34 | } |
| 60 | 35 | |
| 61 | - /** | |
| 62 | - * Field attributes. | |
| 63 | - * | |
| 64 | - * @param array $custom_atts Custom attributes. | |
| 65 | - * @return mixed | |
| 66 | - */ | |
| 67 | 36 | public function field_attributes( $custom_atts = array() ) { |
| 68 | 37 | |
| 69 | 38 | $field_id = ( ! empty( $this->field['id'] ) ) ? $this->field['id'] : ''; |
| 70 | 39 | $attributes = ( ! empty( $this->field['attributes'] ) ) ? $this->field['attributes'] : array(); |
| @@ -82,9 +51,9 @@ | ||
| 82 | 51 | $atts = ''; |
| 83 | 52 | |
| 84 | 53 | if ( ! empty( $attributes ) ) { |
| 85 | 54 | foreach ( $attributes as $key => $value ) { |
| 86 | - if ( 'only-key' === $value ) { | |
| 55 | + if ( $value === 'only-key' ) { | |
| 87 | 56 | $atts .= ' ' . $key; |
| 88 | 57 | } else { |
| 89 | 58 | $atts .= ' ' . $key . '="' . $value . '"'; |
| 90 | 59 | } |
| @@ -94,22 +63,12 @@ | ||
| 94 | 63 | return $atts; |
| 95 | 64 | |
| 96 | 65 | } |
| 97 | 66 | |
| 98 | - /** | |
| 99 | - * Field before. | |
| 100 | - * | |
| 101 | - * @return mixed | |
| 102 | - */ | |
| 103 | 67 | public function field_before() { |
| 104 | 68 | return ( ! empty( $this->field['before'] ) ) ? $this->field['before'] : ''; |
| 105 | 69 | } |
| 106 | 70 | |
| 107 | - /** | |
| 108 | - * Field after. | |
| 109 | - * | |
| 110 | - * @return mixed | |
| 111 | - */ | |
| 112 | 71 | public function field_after() { |
| 113 | 72 | |
| 114 | 73 | $output = ( ! empty( $this->field['after'] ) ) ? $this->field['after'] : ''; |
| 115 | 74 | $output .= ( ! empty( $this->field['desc'] ) ) ? '<p class="spf-text-desc">' . $this->field['desc'] . '</p>' : ''; |
| @@ -125,11 +84,10 @@ | ||
| 125 | 84 | * |
| 126 | 85 | * @param array $type post types. |
| 127 | 86 | * @param boolean $term post term. |
| 128 | 87 | * @param array $query_args post term. |
| 129 | - * @param array $field_unique unique id. | |
| 130 | 88 | * |
| 131 | - * @return array | |
| 89 | + * @return statement | |
| 132 | 90 | */ |
| 133 | 91 | public static function field_data( $type = '', $term = false, $query_args = array(), $field_unique = null ) { |
| 134 | 92 | |
| 135 | 93 | $options = array(); |
| @@ -188,23 +146,9 @@ | ||
| 188 | 146 | } |
| 189 | 147 | } |
| 190 | 148 | |
| 191 | 149 | break; |
| 192 | - case 'sp_post_carousel': | |
| 193 | - $pcp_get_specific = array( | |
| 194 | - 'post_type' => 'sp_post_carousel', | |
| 195 | - ); | |
| 196 | - $query_args = array_merge( $query_args, $pcp_get_specific ); | |
| 197 | - $all_posts = get_posts( $query_args ); | |
| 198 | 150 | |
| 199 | - if ( ! is_wp_error( $all_posts ) && ! empty( $all_posts ) ) { | |
| 200 | - foreach ( $all_posts as $post_obj ) { | |
| 201 | - $options[ $post_obj->ID ] = isset( $post_obj->post_title ) && ! empty( $post_obj->post_title ) ? $post_obj->post_title : 'Untitled'; | |
| 202 | - } | |
| 203 | - } | |
| 204 | - wp_reset_postdata(); | |
| 205 | - break; | |
| 206 | - | |
| 207 | 151 | case 'category': |
| 208 | 152 | case 'categories': |
| 209 | 153 | case 'tag': |
| 210 | 154 | case 'tags': |
| @@ -296,9 +240,9 @@ | ||
| 296 | 240 | $view_options = get_post_meta( $post->ID, 'sp_pcp_view_options', true ); |
| 297 | 241 | $pcp_post_types = isset( $view_options['pcp_select_post_type'] ) && ! empty( $view_options['pcp_select_post_type'] ) ? $view_options['pcp_select_post_type'] : 'post'; |
| 298 | 242 | $taxonomy_names = get_object_taxonomies( $pcp_post_types, 'names' ); |
| 299 | 243 | if ( ! is_wp_error( $taxonomy_names ) && ! empty( $taxonomy_names ) ) { |
| 300 | - $options[''] = __( 'Select Taxonomy', 'post-carousel' ); | |
| 244 | + $options[''] = __( 'Select Taxonomy', 'smart-post-show' ); | |
| 301 | 245 | foreach ( $taxonomy_names as $taxonomy => $label ) { |
| 302 | 246 | $options[ $label ] = $label; |
| 303 | 247 | } |
| 304 | 248 | } |
| @@ -309,9 +253,9 @@ | ||
| 309 | 253 | global $post; |
| 310 | 254 | $view_options = get_post_meta( $post->ID, 'sp_pcp_view_options', true ); |
| 311 | 255 | $pcp_post_types = isset( $view_options['pcp_select_post_type'] ) && ! empty( $view_options['pcp_select_post_type'] ) ? $view_options['pcp_select_post_type'] : get_post_types( array(), 'names' ); |
| 312 | 256 | |
| 313 | - $field_index = preg_replace( '/[^0-9]/', '', $field_unique ); | |
| 257 | + $field_index = preg_replace( '/[^0-9]/', '', $field_unique ); | |
| 314 | 258 | $pcp_taxonomy = isset( $view_options['pcp_filter_by_taxonomy']['pcp_taxonomy_and_terms'][ $field_index ]['pcp_select_taxonomy'] ) ? $view_options['pcp_filter_by_taxonomy']['pcp_taxonomy_and_terms'][ $field_index ]['pcp_select_taxonomy'] : get_object_taxonomies( $pcp_post_types, 'names' ); |
| 315 | 259 | if ( version_compare( get_bloginfo( 'version' ), '4.5', '>=' ) ) { |
| 316 | 260 | $terms = get_terms( array( 'taxonomy' => $pcp_taxonomy ) ); |
| 317 | 261 | } else { |