AdminAjaxController.php
3 years ago
MetaController.php
3 years ago
NoticeController.php
3 years ago
PostTypeController.php
3 years ago
SettingsController.php
3 years ago
UpgradeController.php
3 years ago
MetaController.php
485 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Meta Controller class. |
| 4 | * |
| 5 | * @package RT_TPG |
| 6 | */ |
| 7 | |
| 8 | namespace RT\ThePostGrid\Controllers\Admin; |
| 9 | |
| 10 | use RT\ThePostGrid\Helpers\Fns; |
| 11 | use RT\ThePostGrid\Helpers\Options; |
| 12 | |
| 13 | // Do not allow directly accessing this file. |
| 14 | if ( ! defined( 'ABSPATH' ) ) { |
| 15 | exit( 'This script cannot be accessed directly.' ); |
| 16 | } |
| 17 | |
| 18 | /** |
| 19 | * Meta Controller class. |
| 20 | */ |
| 21 | class MetaController { |
| 22 | /** |
| 23 | * Class constructor |
| 24 | */ |
| 25 | public function __construct() { |
| 26 | add_action( 'admin_head', [ $this, 'admin_head' ] ); |
| 27 | add_action( 'edit_form_after_title', [ $this, 'tpg_sc_after_title' ] ); |
| 28 | add_action( 'admin_enqueue_scripts', [ $this, 'admin_enqueue_scripts' ] ); |
| 29 | add_action( 'save_post', [ $this, 'save_post' ], 10, 2 ); |
| 30 | add_filter( 'manage_edit-rttpg_columns', [ $this, 'arrange_rttpg_columns' ] ); |
| 31 | add_action( 'manage_rttpg_posts_custom_column', [ $this, 'manage_rttpg_columns' ], 10, 2 ); |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * manage Column |
| 36 | * |
| 37 | * @param string $column Column. |
| 38 | * @return void |
| 39 | */ |
| 40 | public function manage_rttpg_columns( $column ) { |
| 41 | switch ( $column ) { |
| 42 | case 'shortcode': |
| 43 | echo '<input type="text" onfocus="this.select();" readonly="readonly" value="[the-post-grid id="' . get_the_ID() . '" title="' . get_the_title() . '"]" class="large-text code rt-code-sc">'; |
| 44 | break; |
| 45 | default: |
| 46 | break; |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Arrange Columns |
| 52 | * |
| 53 | * @param array $columns Columns. |
| 54 | * @return array |
| 55 | */ |
| 56 | public function arrange_rttpg_columns( $columns ) { |
| 57 | $shortcode = [ 'shortcode' => esc_html__( 'Shortcode', 'the-post-grid' ) ]; |
| 58 | |
| 59 | return array_slice( $columns, 0, 2, true ) + $shortcode + array_slice( $columns, 1, null, true ); |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Admin Scripts |
| 64 | * |
| 65 | * @return void |
| 66 | */ |
| 67 | public function admin_enqueue_scripts() { |
| 68 | |
| 69 | global $pagenow, $typenow; |
| 70 | |
| 71 | if ( 'tpg_builder' === $typenow ) { |
| 72 | wp_enqueue_style( 'rt-tpg-admin' ); |
| 73 | } |
| 74 | |
| 75 | if ( ! in_array( $pagenow, [ 'post.php', 'post-new.php' ], true ) ) { |
| 76 | return; |
| 77 | } |
| 78 | |
| 79 | if ( rtTPG()->post_type !== $typenow ) { |
| 80 | return; |
| 81 | } |
| 82 | |
| 83 | wp_dequeue_script( 'autosave' ); |
| 84 | wp_enqueue_media(); |
| 85 | |
| 86 | $select2Id = 'rt-select2'; |
| 87 | if ( class_exists( 'WPSEO_Admin_Asset_Manager' ) && class_exists( 'Avada' ) ) { |
| 88 | $select2Id = 'yoast-seo-select2'; |
| 89 | } elseif ( class_exists( 'WPSEO_Admin_Asset_Manager' ) ) { |
| 90 | $select2Id = 'yoast-seo-select2'; |
| 91 | } elseif ( class_exists( 'Avada' ) ) { |
| 92 | $select2Id = 'select2-avada-js'; |
| 93 | } |
| 94 | |
| 95 | // scripts. |
| 96 | wp_enqueue_script( |
| 97 | [ |
| 98 | 'jquery', |
| 99 | 'jquery-ui-datepicker', |
| 100 | 'wp-color-picker', |
| 101 | $select2Id, |
| 102 | 'imagesloaded', |
| 103 | 'rt-isotope-js', |
| 104 | 'rt-tpg-admin', |
| 105 | 'rt-tpg-admin-preview', |
| 106 | ] |
| 107 | ); |
| 108 | |
| 109 | // styles. |
| 110 | wp_enqueue_style( |
| 111 | [ |
| 112 | 'wp-color-picker', |
| 113 | 'rt-select2', |
| 114 | 'rt-fontawsome', |
| 115 | 'rt-tpg-admin', |
| 116 | 'rt-tpg-admin-preview', |
| 117 | ] |
| 118 | ); |
| 119 | |
| 120 | wp_localize_script( |
| 121 | 'rt-tpg-admin', |
| 122 | 'rttpg', |
| 123 | [ |
| 124 | 'nonceID' => esc_attr( rtTPG()->nonceId() ), |
| 125 | 'nonce' => esc_attr( wp_create_nonce( rtTPG()->nonceText() ) ), |
| 126 | 'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ), |
| 127 | ] |
| 128 | ); |
| 129 | |
| 130 | } |
| 131 | |
| 132 | /** |
| 133 | * Add Metabox. |
| 134 | * |
| 135 | * @return void |
| 136 | */ |
| 137 | public function admin_head() { |
| 138 | add_meta_box( |
| 139 | 'rttpg_meta', |
| 140 | esc_html__( 'Short Code Generator', 'the-post-grid' ), |
| 141 | [ $this, 'rttpg_meta_settings_selection' ], |
| 142 | rtTPG()->post_type, |
| 143 | 'normal', |
| 144 | 'high' |
| 145 | ); |
| 146 | |
| 147 | add_meta_box( |
| 148 | rtTPG()->post_type . '_sc_preview_meta', |
| 149 | esc_html__( 'Layout Preview', 'the-post-grid' ), |
| 150 | [ $this, 'tpg_sc_preview_selection' ], |
| 151 | rtTPG()->post_type, |
| 152 | 'normal', |
| 153 | 'high' |
| 154 | ); |
| 155 | |
| 156 | add_meta_box( |
| 157 | 'rt_plugin_sc_pro_information', |
| 158 | esc_html__( 'Documentation', 'the-post-grid' ), |
| 159 | [ $this, 'rt_plugin_sc_pro_information' ], |
| 160 | rtTPG()->post_type, |
| 161 | 'side', |
| 162 | 'low' |
| 163 | ); |
| 164 | } |
| 165 | |
| 166 | /** |
| 167 | * Marketing. |
| 168 | * |
| 169 | * @param string $post Post. |
| 170 | * @return void |
| 171 | */ |
| 172 | public function rt_plugin_sc_pro_information( $post ) { |
| 173 | $html = ''; |
| 174 | |
| 175 | if ( 'settings' === $post ) { |
| 176 | $html .= '<div class="rt-document-box rt-update-pro-btn-wrap"> |
| 177 | <a href="' . esc_url( rtTpg()->proLink() ) . '" target="_blank" class="rt-update-pro-btn">' . esc_html__( 'Update Pro To Get More Features', 'the-post-grid' ) . '</a> |
| 178 | </div>'; |
| 179 | } else { |
| 180 | if ( ! rtTPG()->hasPro() ) { |
| 181 | $html .= sprintf( |
| 182 | '<div class="rt-document-box"><div class="rt-box-icon"><i class="dashicons dashicons-megaphone"></i></div><div class="rt-box-content"><h3 class="rt-box-title">%1$s</h3>%2$s</div></div>', |
| 183 | esc_html__( 'Pro Features', 'the-post-grid' ), |
| 184 | Options::get_pro_feature_list() |
| 185 | ); |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | $html .= sprintf( |
| 190 | '<div class="rt-document-box"> |
| 191 | <div class="rt-box-icon"><i class="dashicons dashicons-media-document"></i></div> |
| 192 | <div class="rt-box-content"> |
| 193 | <h3 class="rt-box-title">%1$s</h3> |
| 194 | <p>%2$s</p> |
| 195 | <a href="' . esc_url( rtTpg()->docLink() ) . '" target="_blank" class="rt-admin-btn">%1$s</a> |
| 196 | </div> |
| 197 | </div>', |
| 198 | esc_html__( 'Documentation', 'the-post-grid' ), |
| 199 | esc_html__( 'Get started by spending some time with the documentation we included step by step process with screenshots with video.', 'the-post-grid' ) |
| 200 | ); |
| 201 | |
| 202 | $rtContact = 'https://www.radiustheme.com/contact/'; |
| 203 | $rtFb = 'https://www.facebook.com/groups/234799147426640/'; |
| 204 | $rtsite = 'https://www.radiustheme.com/'; |
| 205 | |
| 206 | $html .= '<div class="rt-document-box"> |
| 207 | <div class="rt-box-icon"><i class="dashicons dashicons-sos"></i></div> |
| 208 | <div class="rt-box-content"> |
| 209 | <h3 class="rt-box-title">Need Help?</h3> |
| 210 | <p>Stuck with something? Please create a |
| 211 | <a href="' . esc_url( $rtContact ) . '">ticket here</a> or post on <a href="' . esc_url( $rtFb ) . '">facebook group</a>. For emergency case join our <a href="' . esc_url( $rtsite ) . '">live chat</a>.</p> |
| 212 | <a href="' . esc_url( $rtContact ) . '" target="_blank" class="rt-admin-btn">' . esc_html__( 'Get Support', 'the-post-grid' ) . '</a> |
| 213 | </div> |
| 214 | </div>'; |
| 215 | |
| 216 | Fns::print_html( $html ); |
| 217 | } |
| 218 | |
| 219 | /** |
| 220 | * Preview |
| 221 | * |
| 222 | * @return void |
| 223 | */ |
| 224 | public function tpg_sc_preview_selection() { |
| 225 | $html = null; |
| 226 | $html .= "<div class='rt-response'></div>"; |
| 227 | $html .= "<div id='tpg-preview-container'></div>"; |
| 228 | |
| 229 | Fns::print_html( $html, true ); |
| 230 | } |
| 231 | |
| 232 | /** |
| 233 | * Text after title |
| 234 | * |
| 235 | * @param object $post Post object. |
| 236 | * @return void |
| 237 | */ |
| 238 | public function tpg_sc_after_title( $post ) { |
| 239 | if ( rtTPG()->post_type !== $post->post_type ) { |
| 240 | return; |
| 241 | } |
| 242 | |
| 243 | $html = null; |
| 244 | $html .= '<div class="postbox rt-after-title" style="margin-bottom: 0;"><div class="inside">'; |
| 245 | $html .= '<p> |
| 246 | <input type="text" onfocus="this.select();" readonly="readonly" value="[the-post-grid id="' . absint( $post->ID ) . '" title="' . esc_attr( $post->post_title ) . '"]" class="large-text code rt-code-sc"> |
| 247 | <input type="text" onfocus="this.select();" readonly="readonly" value="<?php echo do_shortcode( '[the-post-grid id="' . absint( $post->ID ) . '" title="' . esc_attr( $post->post_title ) . '"]' ); ?>" class="large-text code rt-code-sc"> |
| 248 | </p>'; |
| 249 | $html .= '</div></div>'; |
| 250 | |
| 251 | Fns::print_html( $html, true ); |
| 252 | } |
| 253 | |
| 254 | /** |
| 255 | * Meta settings |
| 256 | * |
| 257 | * @param object $post Post object. |
| 258 | * @return void |
| 259 | */ |
| 260 | public function rttpg_meta_settings_selection( $post ) { |
| 261 | $last_tab = trim( get_post_meta( $post->ID, '_tpg_last_active_tab', true ) ); |
| 262 | $last_tab = $last_tab ? $last_tab : 'sc-post-post-source'; |
| 263 | $post = [ |
| 264 | 'post' => $post, |
| 265 | ]; |
| 266 | |
| 267 | wp_nonce_field( rtTPG()->nonceText(), rtTPG()->nonceId() ); |
| 268 | |
| 269 | $html = null; |
| 270 | $html .= '<div id="sc-tabs" class="rttpg-wrapper rt-tab-container rt-setting-holder">'; |
| 271 | $html .= sprintf( |
| 272 | '<ul class="rt-tab-nav"> |
| 273 | <li%s><a href="#sc-post-post-source">%s</a></li> |
| 274 | <li%s><a href="#sc-post-layout-settings">%s</a></li> |
| 275 | <li%s><a href="#sc-settings">%s</a></li> |
| 276 | <li%s><a href="#sc-field-selection">%s</a></li> |
| 277 | <li%s><a href="#sc-style">%s</a></li> |
| 278 | </ul>', |
| 279 | 'sc-post-post-source' === $last_tab ? ' class="active"' : '', |
| 280 | esc_html__( 'Query Build', 'the-post-grid' ), |
| 281 | 'sc-post-layout-settings' === $last_tab ? ' class="active"' : '', |
| 282 | esc_html__( 'Layout Settings', 'the-post-grid' ), |
| 283 | 'sc-settings' === $last_tab ? ' class="active"' : '', |
| 284 | esc_html__( 'Settings', 'the-post-grid' ), |
| 285 | 'sc-field-selection' === $last_tab ? ' class="active"' : '', |
| 286 | esc_html__( 'Field Selection', 'the-post-grid' ), |
| 287 | 'sc-style' === $last_tab ? ' class="active"' : '', |
| 288 | esc_html__( 'Style', 'the-post-grid' ) |
| 289 | ); |
| 290 | |
| 291 | // Query Build tab. |
| 292 | $html .= sprintf( '<div id="sc-post-post-source" class="rt-tab-content"%s>', 'sc-post-post-source' === $last_tab ? ' style="display:block"' : '' ); |
| 293 | $html .= Fns::view( 'settings.post-source', $post, true ); |
| 294 | $html .= '</div>'; |
| 295 | |
| 296 | // Layout Setting tab. |
| 297 | $html .= sprintf( '<div id="sc-post-layout-settings" class="rt-tab-content"%s>', 'sc-post-layout-settings' === $last_tab ? ' style="display:block"' : '' ); |
| 298 | $html .= Fns::view( 'settings.layout-settings', $post, true ); |
| 299 | $html .= '</div>'; |
| 300 | |
| 301 | // Settings tab. |
| 302 | $html .= sprintf( '<div id="sc-settings" class="rt-tab-content"%s>', 'sc-settings' === $last_tab ? ' style="display:block"' : '' ); |
| 303 | $html .= Fns::view( 'settings.sc-settings', $post, true ); |
| 304 | $html .= '</div>'; |
| 305 | |
| 306 | // Field Selection tab. |
| 307 | $html .= sprintf( '<div id="sc-field-selection" class="rt-tab-content"%s>', 'sc-field-selection' === $last_tab ? ' style="display:block"' : '' ); |
| 308 | $html .= Fns::view( 'settings.item-fields', $post, true ); |
| 309 | $html .= '</div>'; |
| 310 | |
| 311 | // Style tab. |
| 312 | $html .= sprintf( '<div id="sc-style" class="rt-tab-content"%s>', 'sc-style' === $last_tab ? ' style="display:block"' : '' ); |
| 313 | $html .= Fns::view( 'settings.style', $post, true ); |
| 314 | $html .= '</div>'; |
| 315 | $html .= sprintf( '<input type="hidden" id="_tpg_last_active_tab" name="_tpg_last_active_tab" value="%s"/>', $last_tab ); |
| 316 | $html .= '</div>'; |
| 317 | |
| 318 | Fns::print_html( $html, true ); |
| 319 | } |
| 320 | |
| 321 | /** |
| 322 | * Save meta box. |
| 323 | * |
| 324 | * @param int $post_id Post ID. |
| 325 | * @param object $post Post object. |
| 326 | * @return mixed |
| 327 | */ |
| 328 | public function save_post( $post_id, $post ) { |
| 329 | if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
| 330 | return $post_id; |
| 331 | } |
| 332 | |
| 333 | if ( ! Fns::verifyNonce() ) { |
| 334 | return $post_id; |
| 335 | } |
| 336 | |
| 337 | if ( rtTPG()->post_type !== $post->post_type ) { |
| 338 | return $post_id; |
| 339 | } |
| 340 | |
| 341 | $mates = Fns::rtAllOptionFields(); |
| 342 | |
| 343 | foreach ( $mates as $metaKey => $field ) { |
| 344 | $rValue = ! empty( $_REQUEST[ $metaKey ] ) ? $_REQUEST[ $metaKey ] : null; |
| 345 | $value = Fns::sanitize( $field, $rValue ); |
| 346 | |
| 347 | if ( empty( $field['multiple'] ) ) { |
| 348 | update_post_meta( $post_id, $metaKey, $value ); |
| 349 | } else { |
| 350 | delete_post_meta( $post_id, $metaKey ); |
| 351 | if ( is_array( $value ) && ! empty( $value ) ) { |
| 352 | foreach ( $value as $item ) { |
| 353 | add_post_meta( $post_id, $metaKey, $item ); |
| 354 | } |
| 355 | } |
| 356 | } |
| 357 | } |
| 358 | |
| 359 | $post_filter = ( isset( $_REQUEST['post_filter'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_REQUEST['post_filter'] ) ) : [] ); |
| 360 | $advFilter = Options::rtTPAdvanceFilters(); |
| 361 | |
| 362 | foreach ( $advFilter['post_filter']['options'] as $filter => $fValue ) { |
| 363 | if ( $filter == 'tpg_taxonomy' ) { |
| 364 | delete_post_meta( $post_id, $filter ); |
| 365 | |
| 366 | if ( ! empty( $_REQUEST[ $filter ] ) && is_array( $_REQUEST[ $filter ] ) ) { |
| 367 | foreach ( $_REQUEST[ $filter ] as $tax ) { |
| 368 | if ( in_array( $filter, $post_filter ) ) { |
| 369 | add_post_meta( $post_id, $filter, trim( $tax ) ); |
| 370 | } |
| 371 | |
| 372 | delete_post_meta( $post_id, 'term_' . $tax ); |
| 373 | |
| 374 | $tt = isset( $_REQUEST[ 'term_' . $tax ] ) ? $_REQUEST[ 'term_' . $tax ] : []; |
| 375 | |
| 376 | if ( is_array( $tt ) && ! empty( $tt ) && in_array( $filter, $post_filter ) ) { |
| 377 | foreach ( $tt as $termID ) { |
| 378 | add_post_meta( $post_id, 'term_' . $tax, trim( $termID ) ); |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | $tto = isset( $_REQUEST[ 'term_operator_' . $tax ] ) ? sanitize_text_field( wp_unslash( $_REQUEST[ 'term_operator_' . $tax ] ) ) : null; |
| 383 | |
| 384 | if ( $tto ) { |
| 385 | update_post_meta( $post_id, 'term_operator_' . $tax, trim( $tto ) ); |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | $filterCount = isset( $_REQUEST[ $filter ] ) ? $_REQUEST[ $filter ] : []; |
| 390 | $tr = isset( $_REQUEST['taxonomy_relation'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['taxonomy_relation'] ) ) : null; |
| 391 | |
| 392 | if ( count( $filterCount ) > 1 && $tr ) { |
| 393 | update_post_meta( $post_id, 'taxonomy_relation', trim( $tr ) ); |
| 394 | } else { |
| 395 | delete_post_meta( $post_id, 'taxonomy_relation' ); |
| 396 | } |
| 397 | } |
| 398 | } elseif ( $filter == 'author' ) { |
| 399 | delete_post_meta( $post_id, 'author' ); |
| 400 | |
| 401 | $authors = ( isset( $_REQUEST['author'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_REQUEST['author'] ) ) : [] ); |
| 402 | |
| 403 | if ( is_array( $authors ) && ! empty( $authors ) && in_array( 'author', $post_filter ) ) { |
| 404 | foreach ( $authors as $authorID ) { |
| 405 | add_post_meta( $post_id, 'author', trim( $authorID ) ); |
| 406 | } |
| 407 | } |
| 408 | } elseif ( $filter == 'tpg_post_status' ) { |
| 409 | delete_post_meta( $post_id, $filter ); |
| 410 | |
| 411 | $statuses = isset( $_REQUEST[ $filter ] ) ? $_REQUEST[ $filter ] : []; |
| 412 | |
| 413 | if ( is_array( $statuses ) && ! empty( $statuses ) && in_array( $filter, $post_filter ) ) { |
| 414 | foreach ( $statuses as $post_status ) { |
| 415 | add_post_meta( $post_id, $filter, trim( $post_status ) ); |
| 416 | } |
| 417 | } |
| 418 | } elseif ( $filter == 's' ) { |
| 419 | delete_post_meta( $post_id, 's' ); |
| 420 | |
| 421 | $s = ( isset( $_REQUEST['s'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['s'] ) ) : null ); |
| 422 | |
| 423 | if ( $s && in_array( 's', $post_filter ) ) { |
| 424 | update_post_meta( $post_id, 's', sanitize_text_field( trim( $s ) ) ); |
| 425 | } |
| 426 | } elseif ( $filter == 'order' ) { |
| 427 | if ( in_array( 'order', $post_filter ) ) { |
| 428 | $order = ( isset( $_REQUEST['order'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['order'] ) ) : null ); |
| 429 | $order_by = ( isset( $_REQUEST['order_by'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['order_by'] ) ) : null ); |
| 430 | $tpg_meta_key = isset( $_REQUEST['tpg_meta_key'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['tpg_meta_key'] ) ) : null; |
| 431 | |
| 432 | if ( $order && in_array( 'order', $post_filter ) ) { |
| 433 | update_post_meta( $post_id, 'order', sanitize_text_field( trim( $order ) ) ); |
| 434 | } |
| 435 | |
| 436 | if ( $order_by && in_array( 'order', $post_filter ) ) { |
| 437 | update_post_meta( $post_id, 'order_by', sanitize_text_field( trim( $order_by ) ) ); |
| 438 | } |
| 439 | |
| 440 | if ( in_array( $order_by, array_keys( Options::rtMetaKeyType() ) ) && $tpg_meta_key && in_array( 'order', $post_filter ) ) { |
| 441 | update_post_meta( $post_id, 'tpg_meta_key', sanitize_text_field( trim( $tpg_meta_key ) ) ); |
| 442 | } else { |
| 443 | delete_post_meta( $post_id, 'tpg_meta_key' ); |
| 444 | } |
| 445 | } else { |
| 446 | delete_post_meta( $post_id, 'order' ); |
| 447 | delete_post_meta( $post_id, 'tpg_meta_key' ); |
| 448 | delete_post_meta( $post_id, 'order_by' ); |
| 449 | } |
| 450 | } elseif ( $filter == 'date_range' ) { |
| 451 | if ( in_array( 'date_range', $post_filter ) ) { |
| 452 | $start = ! empty( $_REQUEST[ $filter . '_start' ] ) ? sanitize_text_field( wp_unslash( $_REQUEST[ $filter . '_start' ] ) ) : null; |
| 453 | $end = ! empty( $_REQUEST[ $filter . '_end' ] ) ? sanitize_text_field( wp_unslash( $_REQUEST[ $filter . '_end' ] ) ) : null; |
| 454 | |
| 455 | update_post_meta( $post_id, $filter . '_start', trim( $start ) ); |
| 456 | update_post_meta( $post_id, $filter . '_end', trim( $end ) ); |
| 457 | } else { |
| 458 | delete_post_meta( $post_id, $filter . '_start' ); |
| 459 | delete_post_meta( $post_id, $filter . '_end' ); |
| 460 | } |
| 461 | } |
| 462 | } |
| 463 | |
| 464 | // Extra css. |
| 465 | $extraFields = Options::extraStyle(); |
| 466 | $extraTypes = [ 'color', 'size', 'weight', 'alignment' ]; |
| 467 | |
| 468 | foreach ( $extraFields as $key => $title ) { |
| 469 | foreach ( $extraTypes as $type ) { |
| 470 | $newKew = $key . "_{$type}"; |
| 471 | if ( isset( $_REQUEST[ $newKew ] ) ) { |
| 472 | $value = sanitize_text_field( wp_unslash( $_REQUEST[ $newKew ] ) ); |
| 473 | |
| 474 | update_post_meta( $post_id, $newKew, $value ); |
| 475 | } |
| 476 | } |
| 477 | } |
| 478 | |
| 479 | if ( isset( $_POST['_tpg_last_active_tab'] ) && $active_tab = sanitize_text_field( wp_unslash( $_POST['_tpg_last_active_tab'] ) ) ) { |
| 480 | update_post_meta( $post_id, '_tpg_last_active_tab', $active_tab ); |
| 481 | } |
| 482 | |
| 483 | } |
| 484 | } |
| 485 |