@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | * |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 10 | +if (!defined('ABSPATH')) { |
|
| 11 | 11 | exit; // Exit if accessed directly |
| 12 | 12 | } |
| 13 | 13 | |
@@ -16,82 +16,82 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | class GetPaid_Meta_Box_Invoice_Items { |
| 18 | 18 | |
| 19 | - public static function get_columns( $invoice ) { |
|
| 19 | + public static function get_columns($invoice) { |
|
| 20 | 20 | $use_taxes = $invoice->is_taxable() && wpinv_use_taxes(); |
| 21 | 21 | $columns = array( |
| 22 | - 'id' => __( 'ID', 'invoicing' ), |
|
| 23 | - 'title' => __( 'Item', 'invoicing' ), |
|
| 22 | + 'id' => __('ID', 'invoicing'), |
|
| 23 | + 'title' => __('Item', 'invoicing'), |
|
| 24 | 24 | 'price' => sprintf( |
| 25 | 25 | '<span class="getpaid-hide-if-hours getpaid-hide-if-quantity">%s</span> |
| 26 | 26 | <span class="getpaid-hide-if-hours hide-if-amount">%s</span> |
| 27 | 27 | <span class="getpaid-hide-if-quantity hide-if-amount">%s</span>', |
| 28 | - __( 'Amount', 'invoicing' ), |
|
| 29 | - __( 'Price', 'invoicing' ), |
|
| 30 | - __( 'Rate', 'invoicing' ) |
|
| 28 | + __('Amount', 'invoicing'), |
|
| 29 | + __('Price', 'invoicing'), |
|
| 30 | + __('Rate', 'invoicing') |
|
| 31 | 31 | ), |
| 32 | 32 | 'qty' => sprintf( |
| 33 | 33 | '<span class="getpaid-hide-if-hours">%s</span><span class="getpaid-hide-if-quantity">%s</span>', |
| 34 | - __( 'Quantity', 'invoicing' ), |
|
| 35 | - __( 'Hours', 'invoicing' ) |
|
| 34 | + __('Quantity', 'invoicing'), |
|
| 35 | + __('Hours', 'invoicing') |
|
| 36 | 36 | ), |
| 37 | - 'total' => __( 'Total', 'invoicing' ), |
|
| 38 | - 'tax' => __( 'Tax (%)', 'invoicing' ), |
|
| 37 | + 'total' => __('Total', 'invoicing'), |
|
| 38 | + 'tax' => __('Tax (%)', 'invoicing'), |
|
| 39 | 39 | 'action' => '', |
| 40 | 40 | ); |
| 41 | 41 | |
| 42 | - if ( ! $use_taxes ) { |
|
| 43 | - unset( $columns['tax'] ); |
|
| 42 | + if (!$use_taxes) { |
|
| 43 | + unset($columns['tax']); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | return $columns; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - public static function output( $post, $invoice = false ) { |
|
| 49 | + public static function output($post, $invoice = false) { |
|
| 50 | 50 | |
| 51 | - if ( apply_filters( 'getpaid_use_new_invoice_items_metabox', false ) ) { |
|
| 52 | - return self::output2( $post ); |
|
| 51 | + if (apply_filters('getpaid_use_new_invoice_items_metabox', false)) { |
|
| 52 | + return self::output2($post); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - $post_id = !empty( $post->ID ) ? $post->ID : 0; |
|
| 56 | - $invoice = $invoice instanceof WPInv_Invoice ? $invoice : new WPInv_Invoice( $post_id ); |
|
| 55 | + $post_id = !empty($post->ID) ? $post->ID : 0; |
|
| 56 | + $invoice = $invoice instanceof WPInv_Invoice ? $invoice : new WPInv_Invoice($post_id); |
|
| 57 | 57 | $use_taxes = $invoice->is_taxable() && wpinv_use_taxes(); |
| 58 | - $item_types = apply_filters( 'wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post ); |
|
| 59 | - $columns = self::get_columns( $invoice ); |
|
| 60 | - $cols = count( $columns ); |
|
| 58 | + $item_types = apply_filters('wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post); |
|
| 59 | + $columns = self::get_columns($invoice); |
|
| 60 | + $cols = count($columns); |
|
| 61 | 61 | $class = ''; |
| 62 | 62 | |
| 63 | - unset( $item_types['adv'] ); |
|
| 64 | - unset( $item_types['package'] ); |
|
| 63 | + unset($item_types['adv']); |
|
| 64 | + unset($item_types['package']); |
|
| 65 | 65 | |
| 66 | - if ( $invoice->is_paid() ) { |
|
| 66 | + if ($invoice->is_paid()) { |
|
| 67 | 67 | $class .= ' wpinv-paid'; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - if ( $invoice->is_refunded() ) { |
|
| 70 | + if ($invoice->is_refunded()) { |
|
| 71 | 71 | $class .= ' wpinv-refunded'; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - if ( $invoice->is_recurring() ) { |
|
| 74 | + if ($invoice->is_recurring()) { |
|
| 75 | 75 | $class .= ' wpi-recurring'; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | ?> |
| 79 | 79 | |
| 80 | - <div class="wpinv-items-wrap<?php echo esc_attr( $class ); ?>" id="wpinv_items_wrap" data-status="<?php echo esc_attr( $invoice->get_status() ); ?>"> |
|
| 80 | + <div class="wpinv-items-wrap<?php echo esc_attr($class); ?>" id="wpinv_items_wrap" data-status="<?php echo esc_attr($invoice->get_status()); ?>"> |
|
| 81 | 81 | <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0"> |
| 82 | 82 | |
| 83 | 83 | <thead> |
| 84 | 84 | <tr> |
| 85 | - <?php foreach ( $columns as $key => $label ) : ?> |
|
| 86 | - <th class="<?php echo esc_attr( $key ); echo 'total' == $key || 'qty' == $key ? ' hide-if-amount' : '' ?>"><?php echo wp_kses_post( $label ); ?></th> |
|
| 85 | + <?php foreach ($columns as $key => $label) : ?> |
|
| 86 | + <th class="<?php echo esc_attr($key); echo 'total' == $key || 'qty' == $key ? ' hide-if-amount' : '' ?>"><?php echo wp_kses_post($label); ?></th> |
|
| 87 | 87 | <?php endforeach; ?> |
| 88 | 88 | </tr> |
| 89 | 89 | </thead> |
| 90 | 90 | |
| 91 | 91 | <tbody class="wpinv-line-items"> |
| 92 | 92 | <?php |
| 93 | - foreach ( $invoice->get_items() as $int => $item ) { |
|
| 94 | - self::output_row( $columns, $item, $invoice, $int % 2 == 0 ? 'even' : 'odd' ); |
|
| 93 | + foreach ($invoice->get_items() as $int => $item) { |
|
| 94 | + self::output_row($columns, $item, $invoice, $int % 2 == 0 ? 'even' : 'odd'); |
|
| 95 | 95 | } |
| 96 | 96 | ?> |
| 97 | 97 | </tbody> |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | <div class="wp-clearfix"> |
| 109 | 109 | <label class="wpi-item-name"> |
| 110 | 110 | <span class="input-text-wrap"> |
| 111 | - <input type="text" style="width: 100%" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' );?>" class="wpinv-quick-item-name" name="_wpinv_quick[name]"> |
|
| 111 | + <input type="text" style="width: 100%" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="wpinv-quick-item-name" name="_wpinv_quick[name]"> |
|
| 112 | 112 | </span> |
| 113 | 113 | </label> |
| 114 | 114 | </div> |
@@ -116,8 +116,8 @@ discard block |
||
| 116 | 116 | <div class="wp-clearfix"> |
| 117 | 117 | <label class="wpi-item-price"> |
| 118 | 118 | <span class="input-text-wrap"> |
| 119 | - <input type="text" style="width: 200px" placeholder="<?php esc_attr_e( 'Item Price', 'invoicing' );?>" class="wpinv-quick-item-price" name="_wpinv_quick[price]"> |
|
| 120 | - × <input type="text" style="width: 140px" placeholder="<?php esc_attr_e( 'Item Quantity', 'invoicing' );?>" class="wpinv-quick-item-qty" name="_wpinv_quick[qty]"> |
|
| 119 | + <input type="text" style="width: 200px" placeholder="<?php esc_attr_e('Item Price', 'invoicing'); ?>" class="wpinv-quick-item-price" name="_wpinv_quick[price]"> |
|
| 120 | + × <input type="text" style="width: 140px" placeholder="<?php esc_attr_e('Item Quantity', 'invoicing'); ?>" class="wpinv-quick-item-qty" name="_wpinv_quick[qty]"> |
|
| 121 | 121 | </span> |
| 122 | 122 | </label> |
| 123 | 123 | </div> |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | <div class="wp-clearfix"> |
| 126 | 126 | <label class="wpi-item-name"> |
| 127 | 127 | <span class="input-text-wrap"> |
| 128 | - <textarea rows="4" style="width: 100%" placeholder="<?php esc_attr_e( 'Item Description', 'invoicing' );?>" class="wpinv-quick-item-description" name="_wpinv_quick[description]"></textarea> |
|
| 128 | + <textarea rows="4" style="width: 100%" placeholder="<?php esc_attr_e('Item Description', 'invoicing'); ?>" class="wpinv-quick-item-description" name="_wpinv_quick[description]"></textarea> |
|
| 129 | 129 | </span> |
| 130 | 130 | </label> |
| 131 | 131 | </div> |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | <div class="wp-clearfix"> |
| 134 | 134 | <label class="wpi-item-type"> |
| 135 | 135 | <span class="input-text-wrap"> |
| 136 | - <?php wpinv_html_select( array( |
|
| 136 | + <?php wpinv_html_select(array( |
|
| 137 | 137 | 'options' => $item_types, |
| 138 | 138 | 'name' => '_wpinv_quick[type]', |
| 139 | 139 | 'id' => '_wpinv_quick_type', |
@@ -141,19 +141,19 @@ discard block |
||
| 141 | 141 | 'show_option_all' => false, |
| 142 | 142 | 'show_option_none' => false, |
| 143 | 143 | 'class' => 'gdmbx2-text-medium wpinv-quick-type', |
| 144 | - ) ); ?> |
|
| 144 | + )); ?> |
|
| 145 | 145 | </span> |
| 146 | 146 | </label> |
| 147 | 147 | </div> |
| 148 | 148 | |
| 149 | - <?php if ( $use_taxes ) : ?> |
|
| 149 | + <?php if ($use_taxes) : ?> |
|
| 150 | 150 | <div class="wp-clearfix"> |
| 151 | 151 | <label class="wpi-vat-rule"> |
| 152 | 152 | <span class="input-text-wrap"> |
| 153 | 153 | <?php |
| 154 | - wpinv_html_select( array( |
|
| 154 | + wpinv_html_select(array( |
|
| 155 | 155 | 'options' => array_merge( |
| 156 | - array( '' => __( 'Select VAT Rule', 'invoicing' ) ), |
|
| 156 | + array('' => __('Select VAT Rule', 'invoicing')), |
|
| 157 | 157 | getpaid_get_tax_rules() |
| 158 | 158 | ), |
| 159 | 159 | 'name' => '_wpinv_quick[vat_rule]', |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | 'show_option_none' => false, |
| 163 | 163 | 'class' => 'gdmbx2-text-medium wpinv-quick-vat-rule', |
| 164 | 164 | 'selected' => 'digital', |
| 165 | - ) ); |
|
| 165 | + )); |
|
| 166 | 166 | ?> |
| 167 | 167 | </span> |
| 168 | 168 | </label> |
@@ -171,9 +171,9 @@ discard block |
||
| 171 | 171 | <label class="wpi-vat-class"> |
| 172 | 172 | <span class="input-text-wrap"> |
| 173 | 173 | <?php |
| 174 | - wpinv_html_select( array( |
|
| 174 | + wpinv_html_select(array( |
|
| 175 | 175 | 'options' => array_merge( |
| 176 | - array( '' => __( 'Select VAT Class', 'invoicing' ) ), |
|
| 176 | + array('' => __('Select VAT Class', 'invoicing')), |
|
| 177 | 177 | getpaid_get_tax_classes() |
| 178 | 178 | ), |
| 179 | 179 | 'name' => '_wpinv_quick[vat_class]', |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | 'show_option_none' => false, |
| 183 | 183 | 'class' => 'gdmbx2-text-medium wpinv-quick-vat-class', |
| 184 | 184 | 'selected' => '_standard', |
| 185 | - ) ); |
|
| 185 | + )); |
|
| 186 | 186 | ?> |
| 187 | 187 | </span> |
| 188 | 188 | </label> |
@@ -203,29 +203,29 @@ discard block |
||
| 203 | 203 | </td> |
| 204 | 204 | </tr> |
| 205 | 205 | <tr class="totals"> |
| 206 | - <td colspan="<?php echo ( (int) $cols - 4 ); ?>"></td> |
|
| 206 | + <td colspan="<?php echo ((int) $cols - 4); ?>"></td> |
|
| 207 | 207 | <td colspan="4"> |
| 208 | 208 | <table cellspacing="0" cellpadding="0"> |
| 209 | 209 | <tr class="subtotal"> |
| 210 | - <td class="name"><?php esc_html_e( 'Sub Total:', 'invoicing' );?></td> |
|
| 211 | - <td class="total"><?php wpinv_the_price( $invoice->get_subtotal(), $invoice->get_currency() );?></td> |
|
| 210 | + <td class="name"><?php esc_html_e('Sub Total:', 'invoicing'); ?></td> |
|
| 211 | + <td class="total"><?php wpinv_the_price($invoice->get_subtotal(), $invoice->get_currency()); ?></td> |
|
| 212 | 212 | <td class="action"></td> |
| 213 | 213 | </tr> |
| 214 | 214 | <tr class="discount"> |
| 215 | - <td class="name"><?php esc_html_e( 'Discount:', 'invoicing' ) ; ?></td> |
|
| 216 | - <td class="total"><?php wpinv_the_price( $invoice->get_total_discount(), $invoice->get_currency() );?></td> |
|
| 215 | + <td class="name"><?php esc_html_e('Discount:', 'invoicing'); ?></td> |
|
| 216 | + <td class="total"><?php wpinv_the_price($invoice->get_total_discount(), $invoice->get_currency()); ?></td> |
|
| 217 | 217 | <td class="action"></td> |
| 218 | 218 | </tr> |
| 219 | - <?php if ( $use_taxes ) : ?> |
|
| 219 | + <?php if ($use_taxes) : ?> |
|
| 220 | 220 | <tr class="tax"> |
| 221 | - <td class="name"><?php esc_html_e( 'Tax:', 'invoicing' );?></td> |
|
| 222 | - <td class="total"><?php wpinv_the_price( $invoice->get_total_tax(), $invoice->get_currency() );?></td> |
|
| 221 | + <td class="name"><?php esc_html_e('Tax:', 'invoicing'); ?></td> |
|
| 222 | + <td class="total"><?php wpinv_the_price($invoice->get_total_tax(), $invoice->get_currency()); ?></td> |
|
| 223 | 223 | <td class="action"></td> |
| 224 | 224 | </tr> |
| 225 | 225 | <?php endif; ?> |
| 226 | 226 | <tr class="total"> |
| 227 | - <td class="name"><?php esc_html_e( 'Total:', 'invoicing' );?></td> |
|
| 228 | - <td class="total"><?php wpinv_the_price( $invoice->get_total(), $invoice->get_currency() );?></td> |
|
| 227 | + <td class="name"><?php esc_html_e('Total:', 'invoicing'); ?></td> |
|
| 228 | + <td class="total"><?php wpinv_the_price($invoice->get_total(), $invoice->get_currency()); ?></td> |
|
| 229 | 229 | <td class="action"></td> |
| 230 | 230 | </tr> |
| 231 | 231 | </table> |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | </table> |
| 237 | 237 | <div class="wpinv-actions"> |
| 238 | 238 | <?php |
| 239 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
| 239 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
| 240 | 240 | wpinv_item_dropdown( |
| 241 | 241 | array( |
| 242 | 242 | 'name' => 'wpinv_invoice_item', |
@@ -246,61 +246,61 @@ discard block |
||
| 246 | 246 | ) |
| 247 | 247 | ); |
| 248 | 248 | |
| 249 | - echo " " . '<button class="button button-primary" id="wpinv-add-item">' . sprintf( esc_html__( 'Add item to %s', 'invoicing' ), esc_html( $invoice->get_label() ) ) . '</button>'; |
|
| 250 | - echo " " . '<button class="button button-primary" id="wpinv-new-item">' . esc_html__( 'Create new item', 'invoicing' ) . '</button>'; |
|
| 251 | - echo " " . '<button class="button button-primary wpinv-flr" id="wpinv-recalc-totals">' . esc_html__( 'Recalculate Totals', 'invoicing' ) . '</button>'; |
|
| 249 | + echo " " . '<button class="button button-primary" id="wpinv-add-item">' . sprintf(esc_html__('Add item to %s', 'invoicing'), esc_html($invoice->get_label())) . '</button>'; |
|
| 250 | + echo " " . '<button class="button button-primary" id="wpinv-new-item">' . esc_html__('Create new item', 'invoicing') . '</button>'; |
|
| 251 | + echo " " . '<button class="button button-primary wpinv-flr" id="wpinv-recalc-totals">' . esc_html__('Recalculate Totals', 'invoicing') . '</button>'; |
|
| 252 | 252 | |
| 253 | 253 | } |
| 254 | 254 | ?> |
| 255 | - <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?> |
|
| 255 | + <?php do_action('wpinv_invoice_items_actions', $invoice); ?> |
|
| 256 | 256 | </div> |
| 257 | 257 | </div> |
| 258 | 258 | <?php |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | - public static function output_row( $columns, $item, $invoice, $class='even' ) { |
|
| 261 | + public static function output_row($columns, $item, $invoice, $class = 'even') { |
|
| 262 | 262 | |
| 263 | 263 | ?> |
| 264 | - <tr class="item item-<?php echo esc_attr( $class ); ?>" data-item-id="<?php echo esc_attr( $item->get_id() ); ?>"> |
|
| 265 | - <?php foreach ( array_keys( $columns ) as $column ) : ?> |
|
| 266 | - <td class="<?php echo esc_attr( $column ); echo 'total' == $column || 'qty' == $column ? ' hide-if-amount' : '' ?>"> |
|
| 264 | + <tr class="item item-<?php echo esc_attr($class); ?>" data-item-id="<?php echo esc_attr($item->get_id()); ?>"> |
|
| 265 | + <?php foreach (array_keys($columns) as $column) : ?> |
|
| 266 | + <td class="<?php echo esc_attr($column); echo 'total' == $column || 'qty' == $column ? ' hide-if-amount' : '' ?>"> |
|
| 267 | 267 | <?php |
| 268 | - switch ( $column ) { |
|
| 268 | + switch ($column) { |
|
| 269 | 269 | case 'id': |
| 270 | 270 | echo (int) $item->get_id(); |
| 271 | 271 | break; |
| 272 | 272 | case 'title': |
| 273 | 273 | printf( |
| 274 | 274 | '<a href="%s" target="_blank">%s</a>', |
| 275 | - esc_url( get_edit_post_link( $item->get_id() ) ), |
|
| 276 | - esc_html( $item->get_raw_name() ) |
|
| 275 | + esc_url(get_edit_post_link($item->get_id())), |
|
| 276 | + esc_html($item->get_raw_name()) |
|
| 277 | 277 | ); |
| 278 | 278 | |
| 279 | - $summary = apply_filters( 'getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice ); |
|
| 280 | - if ( $summary !== '' ) { |
|
| 279 | + $summary = apply_filters('getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice); |
|
| 280 | + if ($summary !== '') { |
|
| 281 | 281 | printf( |
| 282 | 282 | '<span class="meta">%s</span>', |
| 283 | - wp_kses_post( wpautop( $summary ) ) |
|
| 283 | + wp_kses_post(wpautop($summary)) |
|
| 284 | 284 | ); |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | printf( |
| 288 | 288 | '<input type="hidden" value="%s" name="getpaid_items[%s][name]" class="getpaid-recalculate-prices-on-change" />', |
| 289 | - esc_attr( $item->get_raw_name() ), |
|
| 289 | + esc_attr($item->get_raw_name()), |
|
| 290 | 290 | (int) $item->get_id() |
| 291 | 291 | ); |
| 292 | 292 | |
| 293 | 293 | printf( |
| 294 | 294 | '<textarea style="display: none;" name="getpaid_items[%s][description]" class="getpaid-recalculate-prices-on-change">%s</textarea>', |
| 295 | 295 | (int) $item->get_id(), |
| 296 | - esc_attr( $item->get_description() ) |
|
| 296 | + esc_attr($item->get_description()) |
|
| 297 | 297 | ); |
| 298 | 298 | |
| 299 | 299 | break; |
| 300 | 300 | case 'price': |
| 301 | 301 | printf( |
| 302 | 302 | '<input type="text" value="%s" name="getpaid_items[%s][price]" style="width: 100px;" class="getpaid-admin-invoice-item-price getpaid-recalculate-prices-on-change" />', |
| 303 | - esc_attr( getpaid_unstandardize_amount( $item->get_price() ) ), |
|
| 303 | + esc_attr(getpaid_unstandardize_amount($item->get_price())), |
|
| 304 | 304 | (int) $item->get_id() |
| 305 | 305 | ); |
| 306 | 306 | |
@@ -308,26 +308,26 @@ discard block |
||
| 308 | 308 | case 'qty': |
| 309 | 309 | printf( |
| 310 | 310 | '<input type="text" style="width: 100px;" value="%s" name="getpaid_items[%s][quantity]" class="getpaid-admin-invoice-item-quantity getpaid-recalculate-prices-on-change" />', |
| 311 | - floatval( $item->get_quantity() ), |
|
| 311 | + floatval($item->get_quantity()), |
|
| 312 | 312 | (int) $item->get_id() |
| 313 | 313 | ); |
| 314 | 314 | |
| 315 | 315 | break; |
| 316 | 316 | case 'total': |
| 317 | - wpinv_the_price( $item->get_sub_total(), $invoice->get_currency() ); |
|
| 317 | + wpinv_the_price($item->get_sub_total(), $invoice->get_currency()); |
|
| 318 | 318 | |
| 319 | 319 | break; |
| 320 | 320 | case 'tax': |
| 321 | - echo floatval( wpinv_round_amount( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) ) . '%'; |
|
| 321 | + echo floatval(wpinv_round_amount(getpaid_get_invoice_tax_rate($invoice, $item), 2)) . '%'; |
|
| 322 | 322 | |
| 323 | 323 | break; |
| 324 | 324 | case 'action': |
| 325 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
| 325 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
| 326 | 326 | echo '<i class="fa fa-trash wpinv-item-remove"></i>'; |
| 327 | 327 | } |
| 328 | 328 | break; |
| 329 | 329 | } |
| 330 | - do_action( 'getpaid_admin_edit_invoice_item_' . $column, $item, $invoice ); |
|
| 330 | + do_action('getpaid_admin_edit_invoice_item_' . $column, $item, $invoice); |
|
| 331 | 331 | ?> |
| 332 | 332 | </td> |
| 333 | 333 | <?php endforeach; ?> |
@@ -340,10 +340,10 @@ discard block |
||
| 340 | 340 | * |
| 341 | 341 | * @param WP_Post $post |
| 342 | 342 | */ |
| 343 | - public static function output2( $post ) { |
|
| 343 | + public static function output2($post) { |
|
| 344 | 344 | |
| 345 | 345 | // Prepare the invoice. |
| 346 | - $invoice = new WPInv_Invoice( $post ); |
|
| 346 | + $invoice = new WPInv_Invoice($post); |
|
| 347 | 347 | |
| 348 | 348 | // Invoice items. |
| 349 | 349 | $items = $invoice->get_items(); |
@@ -351,28 +351,28 @@ discard block |
||
| 351 | 351 | $totals = array( |
| 352 | 352 | |
| 353 | 353 | 'subtotal' => array( |
| 354 | - 'label' => __( 'Items Subtotal', 'invoicing' ), |
|
| 355 | - 'value' => wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() ), |
|
| 354 | + 'label' => __('Items Subtotal', 'invoicing'), |
|
| 355 | + 'value' => wpinv_price($invoice->get_subtotal(), $invoice->get_currency()), |
|
| 356 | 356 | ), |
| 357 | 357 | |
| 358 | 358 | 'discount' => array( |
| 359 | - 'label' => __( 'Total Discount', 'invoicing' ), |
|
| 360 | - 'value' => wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() ), |
|
| 359 | + 'label' => __('Total Discount', 'invoicing'), |
|
| 360 | + 'value' => wpinv_price($invoice->get_total_discount(), $invoice->get_currency()), |
|
| 361 | 361 | ), |
| 362 | 362 | |
| 363 | 363 | 'tax' => array( |
| 364 | - 'label' => __( 'Total Tax', 'invoicing' ), |
|
| 365 | - 'value' => wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() ), |
|
| 364 | + 'label' => __('Total Tax', 'invoicing'), |
|
| 365 | + 'value' => wpinv_price($invoice->get_total_tax(), $invoice->get_currency()), |
|
| 366 | 366 | ), |
| 367 | 367 | |
| 368 | 368 | 'total' => array( |
| 369 | - 'label' => __( 'Invoice Total', 'invoicing' ), |
|
| 370 | - 'value' => wpinv_price( $invoice->get_total(), $invoice->get_currency() ), |
|
| 369 | + 'label' => __('Invoice Total', 'invoicing'), |
|
| 370 | + 'value' => wpinv_price($invoice->get_total(), $invoice->get_currency()), |
|
| 371 | 371 | ) |
| 372 | 372 | ); |
| 373 | 373 | |
| 374 | - if ( ! wpinv_use_taxes() ) { |
|
| 375 | - unset( $totals['tax'] ); |
|
| 374 | + if (!wpinv_use_taxes()) { |
|
| 375 | + unset($totals['tax']); |
|
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | $item_args = array( |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | 'orderby' => 'title', |
| 381 | 381 | 'order' => 'ASC', |
| 382 | 382 | 'posts_per_page' => -1, |
| 383 | - 'post_status' => array( 'publish' ), |
|
| 383 | + 'post_status' => array('publish'), |
|
| 384 | 384 | 'meta_query' => array( |
| 385 | 385 | array( |
| 386 | 386 | 'key' => '_wpinv_type', |
@@ -404,10 +404,10 @@ discard block |
||
| 404 | 404 | } |
| 405 | 405 | </style> |
| 406 | 406 | |
| 407 | - <div class="bsui getpaid-invoice-items-inner <?php echo empty( $items ) ? 'no-items' : 'has-items'; ?> <?php echo $invoice->is_paid() || $invoice->is_refunded() ? 'not-editable' : 'editable'; ?>" style="margin-top: 1.5rem; padding: 0 12px 12px;"> |
|
| 407 | + <div class="bsui getpaid-invoice-items-inner <?php echo empty($items) ? 'no-items' : 'has-items'; ?> <?php echo $invoice->is_paid() || $invoice->is_refunded() ? 'not-editable' : 'editable'; ?>" style="margin-top: 1.5rem; padding: 0 12px 12px;"> |
|
| 408 | 408 | |
| 409 | - <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?> |
|
| 410 | - <?php do_action( 'wpinv_meta_box_before_invoice_template_row', $invoice->get_id() ); ?> |
|
| 409 | + <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?> |
|
| 410 | + <?php do_action('wpinv_meta_box_before_invoice_template_row', $invoice->get_id()); ?> |
|
| 411 | 411 | |
| 412 | 412 | <div class="row"> |
| 413 | 413 | <div class="col-12 col-sm-6"> |
@@ -416,15 +416,15 @@ discard block |
||
| 416 | 416 | array( |
| 417 | 417 | 'id' => 'wpinv_template', |
| 418 | 418 | 'name' => 'wpinv_template', |
| 419 | - 'label' => __( 'Template', 'invoicing' ), |
|
| 419 | + 'label' => __('Template', 'invoicing'), |
|
| 420 | 420 | 'label_type' => 'vertical', |
| 421 | - 'placeholder' => __( 'Choose a template', 'invoicing' ), |
|
| 421 | + 'placeholder' => __('Choose a template', 'invoicing'), |
|
| 422 | 422 | 'class' => 'form-control-sm', |
| 423 | - 'value' => $invoice->get_template( 'edit' ), |
|
| 423 | + 'value' => $invoice->get_template('edit'), |
|
| 424 | 424 | 'options' => array( |
| 425 | - 'quantity' => __( 'Quantity', 'invoicing' ), |
|
| 426 | - 'hours' => __( 'Hours', 'invoicing' ), |
|
| 427 | - 'amount' => __( 'Amount Only', 'invoicing' ), |
|
| 425 | + 'quantity' => __('Quantity', 'invoicing'), |
|
| 426 | + 'hours' => __('Hours', 'invoicing'), |
|
| 427 | + 'amount' => __('Amount Only', 'invoicing'), |
|
| 428 | 428 | ), |
| 429 | 429 | 'data-allow-clear' => 'false', |
| 430 | 430 | 'select2' => true, |
@@ -441,11 +441,11 @@ discard block |
||
| 441 | 441 | array( |
| 442 | 442 | 'id' => 'wpinv_currency', |
| 443 | 443 | 'name' => 'wpinv_currency', |
| 444 | - 'label' => __( 'Currency', 'invoicing' ), |
|
| 444 | + 'label' => __('Currency', 'invoicing'), |
|
| 445 | 445 | 'label_type' => 'vertical', |
| 446 | - 'placeholder' => __( 'Select Invoice Currency', 'invoicing' ), |
|
| 446 | + 'placeholder' => __('Select Invoice Currency', 'invoicing'), |
|
| 447 | 447 | 'class' => 'form-control-sm', |
| 448 | - 'value' => $invoice->get_currency( 'edit' ), |
|
| 448 | + 'value' => $invoice->get_currency('edit'), |
|
| 449 | 449 | 'required' => false, |
| 450 | 450 | 'data-allow-clear' => 'false', |
| 451 | 451 | 'select2' => true, |
@@ -458,24 +458,24 @@ discard block |
||
| 458 | 458 | </div> |
| 459 | 459 | </div> |
| 460 | 460 | |
| 461 | - <?php do_action( 'wpinv_meta_box_invoice_template_row', $invoice->get_id() ); ?> |
|
| 461 | + <?php do_action('wpinv_meta_box_invoice_template_row', $invoice->get_id()); ?> |
|
| 462 | 462 | <?php endif; ?> |
| 463 | 463 | |
| 464 | 464 | <table cellpadding="0" cellspacing="0" class="getpaid_invoice_items"> |
| 465 | 465 | <thead> |
| 466 | 466 | <tr> |
| 467 | - <th class="getpaid-item" colspan="2"><?php esc_html_e( 'Item', 'invoicing' ) ?></th> |
|
| 467 | + <th class="getpaid-item" colspan="2"><?php esc_html_e('Item', 'invoicing') ?></th> |
|
| 468 | 468 | <th class="getpaid-quantity hide-if-amount text-right"> |
| 469 | - <span class="getpaid-hide-if-hours"><?php esc_html_e( 'Quantity', 'invoicing' ) ?></span> |
|
| 470 | - <span class="getpaid-hide-if-quantity"><?php esc_html_e( 'Hours', 'invoicing' ) ?></span> |
|
| 469 | + <span class="getpaid-hide-if-hours"><?php esc_html_e('Quantity', 'invoicing') ?></span> |
|
| 470 | + <span class="getpaid-hide-if-quantity"><?php esc_html_e('Hours', 'invoicing') ?></span> |
|
| 471 | 471 | </th> |
| 472 | 472 | <th class="getpaid-price hide-if-amount text-right"> |
| 473 | - <span class="getpaid-hide-if-hours"><?php esc_html_e( 'Price', 'invoicing' ) ?></span> |
|
| 474 | - <span class="getpaid-hide-if-quantity"><?php esc_html_e( 'Rate', 'invoicing' ) ?></span> |
|
| 473 | + <span class="getpaid-hide-if-hours"><?php esc_html_e('Price', 'invoicing') ?></span> |
|
| 474 | + <span class="getpaid-hide-if-quantity"><?php esc_html_e('Rate', 'invoicing') ?></span> |
|
| 475 | 475 | </th> |
| 476 | 476 | <th class="getpaid-item-subtotal text-right"> |
| 477 | - <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php esc_html_e( 'Amount', 'invoicing' ) ?></span> |
|
| 478 | - <span class="hide-if-amount"><?php esc_html_e( 'Total', 'invoicing' ) ?></span> |
|
| 477 | + <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php esc_html_e('Amount', 'invoicing') ?></span> |
|
| 478 | + <span class="hide-if-amount"><?php esc_html_e('Total', 'invoicing') ?></span> |
|
| 479 | 479 | </th> |
| 480 | 480 | <th class="getpaid-item-actions hide-if-not-editable" width="70px"> </th> |
| 481 | 481 | </tr> |
@@ -483,8 +483,8 @@ discard block |
||
| 483 | 483 | <tbody class="getpaid_invoice_line_items"> |
| 484 | 484 | <tr class="hide-if-has-items hide-if-not-editable"> |
| 485 | 485 | <td colspan="2" class="pt-4 pb-4"> |
| 486 | - <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php esc_html_e( 'Add Existing Items', 'invoicing' ) ?></button> |
|
| 487 | - <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php esc_html_e( 'Create New Item', 'invoicing' ) ?></button> |
|
| 486 | + <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php esc_html_e('Add Existing Items', 'invoicing') ?></button> |
|
| 487 | + <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php esc_html_e('Create New Item', 'invoicing') ?></button> |
|
| 488 | 488 | </td> |
| 489 | 489 | <td class="hide-if-amount"> </th> |
| 490 | 490 | <td class="hide-if-amount"> </th> |
@@ -516,11 +516,11 @@ discard block |
||
| 516 | 516 | <div class="col-12 col-sm-6 offset-sm-6"> |
| 517 | 517 | <table class="getpaid-invoice-totals text-right w-100"> |
| 518 | 518 | <tbody> |
| 519 | - <?php foreach ( apply_filters( 'getpaid_invoice_subtotal_rows', $totals, $invoice ) as $key => $data ) : ?> |
|
| 520 | - <tr class="getpaid-totals-<?php echo esc_attr( $key ); ?>"> |
|
| 521 | - <td class="label"><?php echo esc_html( $data['label'] ) ?>:</td> |
|
| 519 | + <?php foreach (apply_filters('getpaid_invoice_subtotal_rows', $totals, $invoice) as $key => $data) : ?> |
|
| 520 | + <tr class="getpaid-totals-<?php echo esc_attr($key); ?>"> |
|
| 521 | + <td class="label"><?php echo esc_html($data['label']) ?>:</td> |
|
| 522 | 522 | <td width="1%"></td> |
| 523 | - <td class="value"><?php echo wp_kses_post( $data['value'] ) ?></td> |
|
| 523 | + <td class="value"><?php echo wp_kses_post($data['value']) ?></td> |
|
| 524 | 524 | </tr> |
| 525 | 525 | <?php endforeach; ?> |
| 526 | 526 | </tbody> |
@@ -533,18 +533,18 @@ discard block |
||
| 533 | 533 | <div class="getpaid-invoice-item-actions hide-if-no-items hide-if-not-editable"> |
| 534 | 534 | <div class="row"> |
| 535 | 535 | <div class="text-left col-12 col-sm-8"> |
| 536 | - <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php esc_html_e( 'Add Existing Item', 'invoicing' ) ?></button> |
|
| 537 | - <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php esc_html_e( 'Create New Item', 'invoicing' ) ?></button> |
|
| 538 | - <?php do_action( 'getpaid-invoice-items-actions', $invoice ); ?> |
|
| 536 | + <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php esc_html_e('Add Existing Item', 'invoicing') ?></button> |
|
| 537 | + <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php esc_html_e('Create New Item', 'invoicing') ?></button> |
|
| 538 | + <?php do_action('getpaid-invoice-items-actions', $invoice); ?> |
|
| 539 | 539 | </div> |
| 540 | 540 | <div class="text-right col-12 col-sm-4"> |
| 541 | - <button type="button" class="button button-primary recalculate-totals-button"><?php esc_html_e( 'Recalculate Totals', 'invoicing' ) ?></button> |
|
| 541 | + <button type="button" class="button button-primary recalculate-totals-button"><?php esc_html_e('Recalculate Totals', 'invoicing') ?></button> |
|
| 542 | 542 | </div> |
| 543 | 543 | </div> |
| 544 | 544 | </div> |
| 545 | 545 | |
| 546 | 546 | <div class="getpaid-invoice-item-actions hide-if-editable"> |
| 547 | - <p class="description m-2 text-right text-muted"><?php esc_html_e( 'This invoice is no longer editable', 'invoicing' ); ?></p> |
|
| 547 | + <p class="description m-2 text-right text-muted"><?php esc_html_e('This invoice is no longer editable', 'invoicing'); ?></p> |
|
| 548 | 548 | </div> |
| 549 | 549 | |
| 550 | 550 | <!-- Add items to an invoice --> |
@@ -552,8 +552,8 @@ discard block |
||
| 552 | 552 | <div class="modal-dialog modal-dialog-centered" role="document"> |
| 553 | 553 | <div class="modal-content"> |
| 554 | 554 | <div class="modal-header"> |
| 555 | - <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php esc_html_e( "Add Item(s)", 'invoicing' ); ?></h5> |
|
| 556 | - <button type="button" class="close" data-dismiss="modal" aria-label="<?php esc_html_e( "Close", 'invoicing' ); ?>"> |
|
| 555 | + <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php esc_html_e("Add Item(s)", 'invoicing'); ?></h5> |
|
| 556 | + <button type="button" class="close" data-dismiss="modal" aria-label="<?php esc_html_e("Close", 'invoicing'); ?>"> |
|
| 557 | 557 | <span aria-hidden="true">×</span> |
| 558 | 558 | </button> |
| 559 | 559 | </div> |
@@ -561,10 +561,10 @@ discard block |
||
| 561 | 561 | <table class="widefat"> |
| 562 | 562 | <thead> |
| 563 | 563 | <tr> |
| 564 | - <th class="pl-0 text-left"><?php esc_html_e( 'Item', 'invoicing' ) ?></th> |
|
| 564 | + <th class="pl-0 text-left"><?php esc_html_e('Item', 'invoicing') ?></th> |
|
| 565 | 565 | <th class="pr-0 text-right hide-if-amount"> |
| 566 | - <span class="getpaid-hide-if-hours"><?php esc_html_e( 'Quantity', 'invoicing' ) ?></span> |
|
| 567 | - <span class="getpaid-hide-if-quantity"><?php esc_html_e( 'Hours', 'invoicing' ) ?></span> |
|
| 566 | + <span class="getpaid-hide-if-hours"><?php esc_html_e('Quantity', 'invoicing') ?></span> |
|
| 567 | + <span class="getpaid-hide-if-quantity"><?php esc_html_e('Hours', 'invoicing') ?></span> |
|
| 568 | 568 | </th> |
| 569 | 569 | </tr> |
| 570 | 570 | </thead> |
@@ -572,9 +572,9 @@ discard block |
||
| 572 | 572 | <tr> |
| 573 | 573 | <td class="pl-0 text-left"> |
| 574 | 574 | <select class="regular-text getpaid-add-invoice-item-select"> |
| 575 | - <option value="" selected="selected" disabled><?php esc_html_e( 'Select an item…', 'invoicing' ); ?></option> |
|
| 576 | - <?php foreach ( get_posts( $item_args ) as $item ) : ?> |
|
| 577 | - <option value="<?php echo (int) $item->ID; ?>"><?php echo esc_html( $item->post_title ); ?></option> |
|
| 575 | + <option value="" selected="selected" disabled><?php esc_html_e('Select an item…', 'invoicing'); ?></option> |
|
| 576 | + <?php foreach (get_posts($item_args) as $item) : ?> |
|
| 577 | + <option value="<?php echo (int) $item->ID; ?>"><?php echo esc_html($item->post_title); ?></option> |
|
| 578 | 578 | <?php endforeach; ?> |
| 579 | 579 | </select> |
| 580 | 580 | </td> |
@@ -586,8 +586,8 @@ discard block |
||
| 586 | 586 | </table> |
| 587 | 587 | </div> |
| 588 | 588 | <div class="modal-footer"> |
| 589 | - <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e( 'Cancel', 'invoicing' ); ?></button> |
|
| 590 | - <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php esc_html_e( 'Add', 'invoicing' ); ?></button> |
|
| 589 | + <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e('Cancel', 'invoicing'); ?></button> |
|
| 590 | + <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php esc_html_e('Add', 'invoicing'); ?></button> |
|
| 591 | 591 | </div> |
| 592 | 592 | </div> |
| 593 | 593 | </div> |
@@ -598,8 +598,8 @@ discard block |
||
| 598 | 598 | <div class="modal-dialog modal-dialog-centered" role="document"> |
| 599 | 599 | <div class="modal-content"> |
| 600 | 600 | <div class="modal-header"> |
| 601 | - <h5 class="modal-title" id="getpaid-create-invoice-item-label"><?php esc_html_e( "Create Item", 'invoicing' ); ?></h5> |
|
| 602 | - <button type="button" class="close" data-dismiss="modal" aria-label="<?php esc_html_e( "Close", 'invoicing' ); ?>"> |
|
| 601 | + <h5 class="modal-title" id="getpaid-create-invoice-item-label"><?php esc_html_e("Create Item", 'invoicing'); ?></h5> |
|
| 602 | + <button type="button" class="close" data-dismiss="modal" aria-label="<?php esc_html_e("Close", 'invoicing'); ?>"> |
|
| 603 | 603 | <span aria-hidden="true">×</span> |
| 604 | 604 | </button> |
| 605 | 605 | </div> |
@@ -607,27 +607,27 @@ discard block |
||
| 607 | 607 | <div class="getpaid-create-item-div"> |
| 608 | 608 | <input type="hidden" name="id" value="new" class="form-control form-control-sm item-id"> |
| 609 | 609 | <label class="form-group w-100"> |
| 610 | - <span><?php esc_html_e( 'Name', 'invoicing' ); ?></span> |
|
| 611 | - <input type="text" name="name" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="form-control form-control-sm item-name"> |
|
| 610 | + <span><?php esc_html_e('Name', 'invoicing'); ?></span> |
|
| 611 | + <input type="text" name="name" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="form-control form-control-sm item-name"> |
|
| 612 | 612 | </label> |
| 613 | 613 | <label class="form-group w-100"> |
| 614 | - <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e( 'Amount', 'invoicing' ); ?></span> |
|
| 615 | - <span class="hide-if-amount"><?php esc_html_e( 'Price', 'invoicing' ); ?></span> |
|
| 616 | - <input type="text" name="price" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control form-control-sm item-price"> |
|
| 614 | + <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e('Amount', 'invoicing'); ?></span> |
|
| 615 | + <span class="hide-if-amount"><?php esc_html_e('Price', 'invoicing'); ?></span> |
|
| 616 | + <input type="text" name="price" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control form-control-sm item-price"> |
|
| 617 | 617 | </label> |
| 618 | 618 | <label class="form-group w-100 hide-if-amount"> |
| 619 | - <span><?php esc_html_e( 'Quantity', 'invoicing' ); ?></span> |
|
| 619 | + <span><?php esc_html_e('Quantity', 'invoicing'); ?></span> |
|
| 620 | 620 | <input type="text" name="quantity" placeholder="1" class="form-control form-control-sm item-quantity"> |
| 621 | 621 | </label> |
| 622 | 622 | <label class="form-group w-100"> |
| 623 | - <span><?php esc_html_e( 'Item Description', 'invoicing' ); ?></span> |
|
| 624 | - <textarea name="description" placeholder="<?php esc_attr_e( 'Enter a description for this item', 'invoicing' ); ?>" class="form-control item-description"></textarea> |
|
| 623 | + <span><?php esc_html_e('Item Description', 'invoicing'); ?></span> |
|
| 624 | + <textarea name="description" placeholder="<?php esc_attr_e('Enter a description for this item', 'invoicing'); ?>" class="form-control item-description"></textarea> |
|
| 625 | 625 | </label> |
| 626 | 626 | </div> |
| 627 | 627 | </div> |
| 628 | 628 | <div class="modal-footer"> |
| 629 | - <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e( 'Cancel', 'invoicing' ); ?></button> |
|
| 630 | - <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e( 'Create', 'invoicing' ); ?></button> |
|
| 629 | + <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e('Cancel', 'invoicing'); ?></button> |
|
| 630 | + <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e('Create', 'invoicing'); ?></button> |
|
| 631 | 631 | </div> |
| 632 | 632 | </div> |
| 633 | 633 | </div> |
@@ -638,8 +638,8 @@ discard block |
||
| 638 | 638 | <div class="modal-dialog modal-dialog-centered" role="document"> |
| 639 | 639 | <div class="modal-content"> |
| 640 | 640 | <div class="modal-header"> |
| 641 | - <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php esc_html_e( "Edit Item", 'invoicing' ); ?></h5> |
|
| 642 | - <button type="button" class="close" data-dismiss="modal" aria-label="<?php esc_html_e( "Close", 'invoicing' ); ?>"> |
|
| 641 | + <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php esc_html_e("Edit Item", 'invoicing'); ?></h5> |
|
| 642 | + <button type="button" class="close" data-dismiss="modal" aria-label="<?php esc_html_e("Close", 'invoicing'); ?>"> |
|
| 643 | 643 | <span aria-hidden="true">×</span> |
| 644 | 644 | </button> |
| 645 | 645 | </div> |
@@ -647,27 +647,27 @@ discard block |
||
| 647 | 647 | <div class="getpaid-edit-item-div"> |
| 648 | 648 | <input type="hidden" name="id" class="form-control form-control-sm item-id"> |
| 649 | 649 | <label class="form-group w-100"> |
| 650 | - <span><?php esc_html_e( 'Name', 'invoicing' ); ?></span> |
|
| 651 | - <input type="text" name="name" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="form-control form-control-sm item-name"> |
|
| 650 | + <span><?php esc_html_e('Name', 'invoicing'); ?></span> |
|
| 651 | + <input type="text" name="name" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="form-control form-control-sm item-name"> |
|
| 652 | 652 | </label> |
| 653 | 653 | <label class="form-group w-100"> |
| 654 | - <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e( 'Amount', 'invoicing' ); ?></span> |
|
| 655 | - <span class="hide-if-amount"><?php esc_html_e( 'Price', 'invoicing' ); ?></span> |
|
| 656 | - <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount( 0 ); ?>" class="form-control form-control-sm item-price"> |
|
| 654 | + <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e('Amount', 'invoicing'); ?></span> |
|
| 655 | + <span class="hide-if-amount"><?php esc_html_e('Price', 'invoicing'); ?></span> |
|
| 656 | + <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount(0); ?>" class="form-control form-control-sm item-price"> |
|
| 657 | 657 | </label> |
| 658 | 658 | <label class="form-group w-100 hide-if-amount"> |
| 659 | - <span><?php esc_html_e( 'Quantity', 'invoicing' ); ?></span> |
|
| 659 | + <span><?php esc_html_e('Quantity', 'invoicing'); ?></span> |
|
| 660 | 660 | <input type="text" name="quantity" placeholder="1" class="form-control form-control-sm item-quantity"> |
| 661 | 661 | </label> |
| 662 | 662 | <label class="form-group w-100"> |
| 663 | - <span><?php esc_html_e( 'Item Description', 'invoicing' ); ?></span> |
|
| 664 | - <textarea name="description" placeholder="<?php esc_attr_e( 'Enter a description for this item', 'invoicing' ); ?>" class="form-control item-description"></textarea> |
|
| 663 | + <span><?php esc_html_e('Item Description', 'invoicing'); ?></span> |
|
| 664 | + <textarea name="description" placeholder="<?php esc_attr_e('Enter a description for this item', 'invoicing'); ?>" class="form-control item-description"></textarea> |
|
| 665 | 665 | </label> |
| 666 | 666 | </div> |
| 667 | 667 | </div> |
| 668 | 668 | <div class="modal-footer"> |
| 669 | - <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e( 'Cancel', 'invoicing' ); ?></button> |
|
| 670 | - <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e( 'Save', 'invoicing' ); ?></button> |
|
| 669 | + <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e('Cancel', 'invoicing'); ?></button> |
|
| 670 | + <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e('Save', 'invoicing'); ?></button> |
|
| 671 | 671 | </div> |
| 672 | 672 | </div> |
| 673 | 673 | </div> |
@@ -4,99 +4,99 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | -defined( 'ABSPATH' ) || exit; |
|
| 7 | +defined('ABSPATH') || exit; |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Displays an invoice. |
| 11 | 11 | * |
| 12 | 12 | * @param WPInv_Invoice $invoice. |
| 13 | 13 | */ |
| 14 | -function getpaid_invoice( $invoice ) { |
|
| 15 | - if ( ! empty( $invoice ) ) { |
|
| 16 | - wpinv_get_template( 'invoice/invoice.php', compact( 'invoice' ) ); |
|
| 14 | +function getpaid_invoice($invoice) { |
|
| 15 | + if (!empty($invoice)) { |
|
| 16 | + wpinv_get_template('invoice/invoice.php', compact('invoice')); |
|
| 17 | 17 | } |
| 18 | 18 | } |
| 19 | -add_action( 'getpaid_invoice', 'getpaid_invoice', 10 ); |
|
| 19 | +add_action('getpaid_invoice', 'getpaid_invoice', 10); |
|
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * Displays the invoice footer. |
| 23 | 23 | */ |
| 24 | -function getpaid_invoice_footer( $invoice ) { |
|
| 25 | - if ( ! empty( $invoice ) ) { |
|
| 26 | - wpinv_get_template( 'invoice/footer.php', compact( 'invoice' ) ); |
|
| 24 | +function getpaid_invoice_footer($invoice) { |
|
| 25 | + if (!empty($invoice)) { |
|
| 26 | + wpinv_get_template('invoice/footer.php', compact('invoice')); |
|
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | -add_action( 'getpaid_invoice_footer', 'getpaid_invoice_footer', 10 ); |
|
| 29 | +add_action('getpaid_invoice_footer', 'getpaid_invoice_footer', 10); |
|
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * Displays the invoice top bar. |
| 33 | 33 | */ |
| 34 | -function getpaid_invoice_header( $invoice ) { |
|
| 35 | - if ( ! empty( $invoice ) ) { |
|
| 36 | - wpinv_get_template( 'invoice/header.php', compact( 'invoice' ) ); |
|
| 34 | +function getpaid_invoice_header($invoice) { |
|
| 35 | + if (!empty($invoice)) { |
|
| 36 | + wpinv_get_template('invoice/header.php', compact('invoice')); |
|
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | -add_action( 'getpaid_invoice_header', 'getpaid_invoice_header', 10 ); |
|
| 39 | +add_action('getpaid_invoice_header', 'getpaid_invoice_header', 10); |
|
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | 42 | * Displays actions on the left side of the header. |
| 43 | 43 | */ |
| 44 | -function getpaid_invoice_header_left_actions( $invoice ) { |
|
| 45 | - if ( ! empty( $invoice ) ) { |
|
| 46 | - wpinv_get_template( 'invoice/header-left-actions.php', compact( 'invoice' ) ); |
|
| 44 | +function getpaid_invoice_header_left_actions($invoice) { |
|
| 45 | + if (!empty($invoice)) { |
|
| 46 | + wpinv_get_template('invoice/header-left-actions.php', compact('invoice')); |
|
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | -add_action( 'getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10 ); |
|
| 49 | +add_action('getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10); |
|
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | 52 | * Displays actions on the right side of the invoice top bar. |
| 53 | 53 | */ |
| 54 | -function getpaid_invoice_header_right_actions( $invoice ) { |
|
| 55 | - if ( ! empty( $invoice ) ) { |
|
| 56 | - wpinv_get_template( 'invoice/header-right-actions.php', compact( 'invoice' ) ); |
|
| 54 | +function getpaid_invoice_header_right_actions($invoice) { |
|
| 55 | + if (!empty($invoice)) { |
|
| 56 | + wpinv_get_template('invoice/header-right-actions.php', compact('invoice')); |
|
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | -add_action( 'getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10 ); |
|
| 59 | +add_action('getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10); |
|
| 60 | 60 | |
| 61 | 61 | /** |
| 62 | 62 | * Displays the invoice title, logo etc. |
| 63 | 63 | */ |
| 64 | -function getpaid_invoice_details_top( $invoice ) { |
|
| 65 | - if ( ! empty( $invoice ) ) { |
|
| 66 | - wpinv_get_template( 'invoice/details-top.php', compact( 'invoice' ) ); |
|
| 64 | +function getpaid_invoice_details_top($invoice) { |
|
| 65 | + if (!empty($invoice)) { |
|
| 66 | + wpinv_get_template('invoice/details-top.php', compact('invoice')); |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | -add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_top', 10 ); |
|
| 69 | +add_action('getpaid_invoice_details', 'getpaid_invoice_details_top', 10); |
|
| 70 | 70 | |
| 71 | 71 | /** |
| 72 | 72 | * Displays the company logo. |
| 73 | 73 | */ |
| 74 | -function getpaid_invoice_logo( $invoice ) { |
|
| 75 | - if ( ! empty( $invoice ) ) { |
|
| 76 | - wpinv_get_template( 'invoice/invoice-logo.php', compact( 'invoice' ) ); |
|
| 74 | +function getpaid_invoice_logo($invoice) { |
|
| 75 | + if (!empty($invoice)) { |
|
| 76 | + wpinv_get_template('invoice/invoice-logo.php', compact('invoice')); |
|
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | -add_action( 'getpaid_invoice_details_top_left', 'getpaid_invoice_logo' ); |
|
| 79 | +add_action('getpaid_invoice_details_top_left', 'getpaid_invoice_logo'); |
|
| 80 | 80 | |
| 81 | 81 | /** |
| 82 | 82 | * Displays the type of invoice. |
| 83 | 83 | */ |
| 84 | -function getpaid_invoice_type( $invoice ) { |
|
| 85 | - if ( ! empty( $invoice ) ) { |
|
| 86 | - wpinv_get_template( 'invoice/invoice-type.php', compact( 'invoice' ) ); |
|
| 84 | +function getpaid_invoice_type($invoice) { |
|
| 85 | + if (!empty($invoice)) { |
|
| 86 | + wpinv_get_template('invoice/invoice-type.php', compact('invoice')); |
|
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | -add_action( 'getpaid_invoice_details_top_right', 'getpaid_invoice_type' ); |
|
| 89 | +add_action('getpaid_invoice_details_top_right', 'getpaid_invoice_type'); |
|
| 90 | 90 | |
| 91 | 91 | /** |
| 92 | 92 | * Displays the invoice details. |
| 93 | 93 | */ |
| 94 | -function getpaid_invoice_details_main( $invoice ) { |
|
| 95 | - if ( ! empty( $invoice ) ) { |
|
| 96 | - wpinv_get_template( 'invoice/details.php', compact( 'invoice' ) ); |
|
| 94 | +function getpaid_invoice_details_main($invoice) { |
|
| 95 | + if (!empty($invoice)) { |
|
| 96 | + wpinv_get_template('invoice/details.php', compact('invoice')); |
|
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | -add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_main', 50 ); |
|
| 99 | +add_action('getpaid_invoice_details', 'getpaid_invoice_details_main', 50); |
|
| 100 | 100 | |
| 101 | 101 | /** |
| 102 | 102 | * Returns a path to the templates directory. |
@@ -125,8 +125,8 @@ discard block |
||
| 125 | 125 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
| 126 | 126 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
| 127 | 127 | */ |
| 128 | -function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
| 129 | - getpaid_template()->display_template( $template_name, $args, $template_path, $default_path ); |
|
| 128 | +function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
| 129 | + getpaid_template()->display_template($template_name, $args, $template_path, $default_path); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -139,8 +139,8 @@ discard block |
||
| 139 | 139 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
| 140 | 140 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
| 141 | 141 | */ |
| 142 | -function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
| 143 | - return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path ); |
|
| 142 | +function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
| 143 | + return getpaid_template()->get_template($template_name, $args, $template_path, $default_path); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | * @return string |
| 150 | 150 | */ |
| 151 | 151 | function wpinv_template_path() { |
| 152 | - return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() ); |
|
| 152 | + return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name()); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | * @return string |
| 159 | 159 | */ |
| 160 | 160 | function wpinv_get_theme_template_dir_name() { |
| 161 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
| 161 | + return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing')); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -170,58 +170,58 @@ discard block |
||
| 170 | 170 | * @param string $template_path The template path relative to the theme's root dir. Defaults to 'invoicing'. |
| 171 | 171 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
| 172 | 172 | */ |
| 173 | -function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
| 174 | - return getpaid_template()->locate_template( $template_name, $template_path, $default_path ); |
|
| 173 | +function wpinv_locate_template($template_name, $template_path = '', $default_path = '') { |
|
| 174 | + return getpaid_template()->locate_template($template_name, $template_path, $default_path); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | -function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
|
| 178 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
| 177 | +function wpinv_get_template_part($slug, $name = null, $load = true) { |
|
| 178 | + do_action('get_template_part_' . $slug, $slug, $name); |
|
| 179 | 179 | |
| 180 | 180 | // Setup possible parts |
| 181 | 181 | $templates = array(); |
| 182 | - if ( isset( $name ) ) { |
|
| 182 | + if (isset($name)) { |
|
| 183 | 183 | $templates[] = $slug . '-' . $name . '.php'; |
| 184 | 184 | } |
| 185 | 185 | $templates[] = $slug . '.php'; |
| 186 | 186 | |
| 187 | 187 | // Allow template parts to be filtered |
| 188 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
| 188 | + $templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name); |
|
| 189 | 189 | |
| 190 | 190 | // Return the part that is found |
| 191 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
| 191 | + return wpinv_locate_tmpl($templates, $load, false); |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | -function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
|
| 194 | +function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) { |
|
| 195 | 195 | // No file found yet |
| 196 | 196 | $located = false; |
| 197 | 197 | |
| 198 | 198 | // Try to find a template file |
| 199 | - foreach ( (array)$template_names as $template_name ) { |
|
| 199 | + foreach ((array) $template_names as $template_name) { |
|
| 200 | 200 | |
| 201 | 201 | // Continue if template is empty |
| 202 | - if ( empty( $template_name ) ) { |
|
| 202 | + if (empty($template_name)) { |
|
| 203 | 203 | continue; |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | // Trim off any slashes from the template name |
| 207 | - $template_name = ltrim( $template_name, '/' ); |
|
| 207 | + $template_name = ltrim($template_name, '/'); |
|
| 208 | 208 | |
| 209 | 209 | // try locating this template file by looping through the template paths |
| 210 | - foreach ( wpinv_get_theme_template_paths() as $template_path ) { |
|
| 210 | + foreach (wpinv_get_theme_template_paths() as $template_path) { |
|
| 211 | 211 | |
| 212 | - if ( file_exists( $template_path . $template_name ) ) { |
|
| 212 | + if (file_exists($template_path . $template_name)) { |
|
| 213 | 213 | $located = $template_path . $template_name; |
| 214 | 214 | break; |
| 215 | 215 | } |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - if ( ! empty( $located ) ) { |
|
| 218 | + if (!empty($located)) { |
|
| 219 | 219 | break; |
| 220 | 220 | } |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - if ( ( true == $load ) && ! empty( $located ) ) { |
|
| 224 | - load_template( $located, $require_once ); |
|
| 223 | + if ((true == $load) && !empty($located)) { |
|
| 224 | + load_template($located, $require_once); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | return $located; |
@@ -231,73 +231,73 @@ discard block |
||
| 231 | 231 | $template_dir = wpinv_get_theme_template_dir_name(); |
| 232 | 232 | |
| 233 | 233 | $file_paths = array( |
| 234 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
| 235 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
| 234 | + 1 => trailingslashit(get_stylesheet_directory()) . $template_dir, |
|
| 235 | + 10 => trailingslashit(get_template_directory()) . $template_dir, |
|
| 236 | 236 | 100 => wpinv_get_templates_dir(), |
| 237 | 237 | ); |
| 238 | 238 | |
| 239 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
| 239 | + $file_paths = apply_filters('wpinv_template_paths', $file_paths); |
|
| 240 | 240 | |
| 241 | 241 | // sort the file paths based on priority |
| 242 | - ksort( $file_paths, SORT_NUMERIC ); |
|
| 242 | + ksort($file_paths, SORT_NUMERIC); |
|
| 243 | 243 | |
| 244 | - return array_map( 'trailingslashit', $file_paths ); |
|
| 244 | + return array_map('trailingslashit', $file_paths); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | function wpinv_checkout_meta_tags() { |
| 248 | 248 | |
| 249 | 249 | $pages = array(); |
| 250 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
| 251 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
| 252 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
| 253 | - $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
| 250 | + $pages[] = wpinv_get_option('success_page'); |
|
| 251 | + $pages[] = wpinv_get_option('failure_page'); |
|
| 252 | + $pages[] = wpinv_get_option('invoice_history_page'); |
|
| 253 | + $pages[] = wpinv_get_option('invoice_subscription_page'); |
|
| 254 | 254 | |
| 255 | - if ( ! wpinv_is_checkout() && ! is_page( $pages ) ) { |
|
| 255 | + if (!wpinv_is_checkout() && !is_page($pages)) { |
|
| 256 | 256 | return; |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
| 260 | 260 | } |
| 261 | -add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
|
| 261 | +add_action('wp_head', 'wpinv_checkout_meta_tags'); |
|
| 262 | 262 | |
| 263 | -function wpinv_add_body_classes( $class ) { |
|
| 264 | - $classes = (array)$class; |
|
| 263 | +function wpinv_add_body_classes($class) { |
|
| 264 | + $classes = (array) $class; |
|
| 265 | 265 | |
| 266 | - if ( wpinv_is_checkout() ) { |
|
| 266 | + if (wpinv_is_checkout()) { |
|
| 267 | 267 | $classes[] = 'wpinv-checkout'; |
| 268 | 268 | $classes[] = 'wpinv-page'; |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | - if ( wpinv_is_success_page() ) { |
|
| 271 | + if (wpinv_is_success_page()) { |
|
| 272 | 272 | $classes[] = 'wpinv-success'; |
| 273 | 273 | $classes[] = 'wpinv-page'; |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | - if ( wpinv_is_failed_transaction_page() ) { |
|
| 276 | + if (wpinv_is_failed_transaction_page()) { |
|
| 277 | 277 | $classes[] = 'wpinv-failed-transaction'; |
| 278 | 278 | $classes[] = 'wpinv-page'; |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | - if ( wpinv_is_invoice_history_page() ) { |
|
| 281 | + if (wpinv_is_invoice_history_page()) { |
|
| 282 | 282 | $classes[] = 'wpinv-history'; |
| 283 | 283 | $classes[] = 'wpinv-page'; |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | - if ( wpinv_is_subscriptions_history_page() ) { |
|
| 286 | + if (wpinv_is_subscriptions_history_page()) { |
|
| 287 | 287 | $classes[] = 'wpinv-subscription'; |
| 288 | 288 | $classes[] = 'wpinv-page'; |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | - if ( wpinv_is_test_mode() ) { |
|
| 291 | + if (wpinv_is_test_mode()) { |
|
| 292 | 292 | $classes[] = 'wpinv-test-mode'; |
| 293 | 293 | $classes[] = 'wpinv-page'; |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | - return array_unique( $classes ); |
|
| 296 | + return array_unique($classes); |
|
| 297 | 297 | } |
| 298 | -add_filter( 'body_class', 'wpinv_add_body_classes' ); |
|
| 298 | +add_filter('body_class', 'wpinv_add_body_classes'); |
|
| 299 | 299 | |
| 300 | -function wpinv_html_select( $args = array() ) { |
|
| 300 | +function wpinv_html_select($args = array()) { |
|
| 301 | 301 | $defaults = array( |
| 302 | 302 | 'options' => array(), |
| 303 | 303 | 'name' => null, |
@@ -306,8 +306,8 @@ discard block |
||
| 306 | 306 | 'selected' => 0, |
| 307 | 307 | 'placeholder' => null, |
| 308 | 308 | 'multiple' => false, |
| 309 | - 'show_option_all' => _x( 'All', 'all dropdown items', 'invoicing' ), |
|
| 310 | - 'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ), |
|
| 309 | + 'show_option_all' => _x('All', 'all dropdown items', 'invoicing'), |
|
| 310 | + 'show_option_none' => _x('None', 'no dropdown items', 'invoicing'), |
|
| 311 | 311 | 'data' => array(), |
| 312 | 312 | 'onchange' => null, |
| 313 | 313 | 'required' => false, |
@@ -315,79 +315,79 @@ discard block |
||
| 315 | 315 | 'readonly' => false, |
| 316 | 316 | ); |
| 317 | 317 | |
| 318 | - $args = wp_parse_args( $args, $defaults ); |
|
| 318 | + $args = wp_parse_args($args, $defaults); |
|
| 319 | 319 | |
| 320 | 320 | $attrs = array( |
| 321 | 321 | 'name' => $args['name'], |
| 322 | 322 | 'id' => $args['id'], |
| 323 | - 'class' => 'wpinv-select ' . implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ), |
|
| 324 | - 'multiple' => ! empty( $args['multiple'] ), |
|
| 325 | - 'readonly' => ! empty( $args['readonly'] ), |
|
| 326 | - 'disabled' => ! empty( $args['disabled'] ), |
|
| 327 | - 'required' => ! empty( $args['required'] ), |
|
| 328 | - 'onchange' => ! empty( $args['onchange'] ), |
|
| 323 | + 'class' => 'wpinv-select ' . implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))), |
|
| 324 | + 'multiple' => !empty($args['multiple']), |
|
| 325 | + 'readonly' => !empty($args['readonly']), |
|
| 326 | + 'disabled' => !empty($args['disabled']), |
|
| 327 | + 'required' => !empty($args['required']), |
|
| 328 | + 'onchange' => !empty($args['onchange']), |
|
| 329 | 329 | ); |
| 330 | 330 | |
| 331 | - if ( $args['placeholder'] ) { |
|
| 331 | + if ($args['placeholder']) { |
|
| 332 | 332 | $attrs['data-placeholder'] = $args['placeholder']; |
| 333 | 333 | } |
| 334 | 334 | |
| 335 | - if ( $args['onchange'] ) { |
|
| 335 | + if ($args['onchange']) { |
|
| 336 | 336 | $attrs['onchange'] = $args['onchange']; |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | - foreach ( $args['data'] as $key => $value ) { |
|
| 339 | + foreach ($args['data'] as $key => $value) { |
|
| 340 | 340 | $attrs["data-$key"] = $value; |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | echo '<select '; |
| 344 | 344 | |
| 345 | - foreach ( $attrs as $attr => $value ) { |
|
| 345 | + foreach ($attrs as $attr => $value) { |
|
| 346 | 346 | |
| 347 | - if ( false === $value ) { |
|
| 347 | + if (false === $value) { |
|
| 348 | 348 | continue; |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | - if ( true === $value ) { |
|
| 352 | - echo ' ' . esc_attr( $attr ); |
|
| 351 | + if (true === $value) { |
|
| 352 | + echo ' ' . esc_attr($attr); |
|
| 353 | 353 | } else { |
| 354 | - echo ' ' . esc_attr( $attr ) . '="' . esc_attr( $value ) . '"'; |
|
| 354 | + echo ' ' . esc_attr($attr) . '="' . esc_attr($value) . '"'; |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | echo '>'; |
| 360 | 360 | |
| 361 | - if ( $args['show_option_all'] ) { |
|
| 362 | - if ( $args['multiple'] ) { |
|
| 363 | - $selected = in_array( 0, $args['selected'] ); |
|
| 361 | + if ($args['show_option_all']) { |
|
| 362 | + if ($args['multiple']) { |
|
| 363 | + $selected = in_array(0, $args['selected']); |
|
| 364 | 364 | } else { |
| 365 | - $selected = empty( $args['selected'] ); |
|
| 365 | + $selected = empty($args['selected']); |
|
| 366 | 366 | } |
| 367 | - echo '<option value="all"' . selected( $selected, true, false ) . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
| 367 | + echo '<option value="all"' . selected($selected, true, false) . '>' . esc_html($args['show_option_all']) . '</option>'; |
|
| 368 | 368 | } |
| 369 | 369 | |
| 370 | - if ( ! empty( $args['options'] ) ) { |
|
| 370 | + if (!empty($args['options'])) { |
|
| 371 | 371 | |
| 372 | - if ( $args['show_option_none'] ) { |
|
| 373 | - if ( $args['multiple'] ) { |
|
| 374 | - $selected = in_array( '', $args['selected'], true ); |
|
| 372 | + if ($args['show_option_none']) { |
|
| 373 | + if ($args['multiple']) { |
|
| 374 | + $selected = in_array('', $args['selected'], true); |
|
| 375 | 375 | } else { |
| 376 | 376 | $selected = $args['selected'] === ''; |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | - echo '<option value=""' . selected( $selected, true, false ) . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
| 379 | + echo '<option value=""' . selected($selected, true, false) . '>' . esc_html($args['show_option_none']) . '</option>'; |
|
| 380 | 380 | } |
| 381 | 381 | |
| 382 | - foreach ( $args['options'] as $key => $option ) { |
|
| 382 | + foreach ($args['options'] as $key => $option) { |
|
| 383 | 383 | |
| 384 | - if ( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
| 385 | - $selected = in_array( $key, $args['selected'], true ); |
|
| 384 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
| 385 | + $selected = in_array($key, $args['selected'], true); |
|
| 386 | 386 | } else { |
| 387 | 387 | $selected = $args['selected'] === $key; |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | - echo '<option value="' . esc_attr( $key ) . '"' . selected( $selected, true, false ) . '>' . esc_html( $option ) . '</option>'; |
|
| 390 | + echo '<option value="' . esc_attr($key) . '"' . selected($selected, true, false) . '>' . esc_html($option) . '</option>'; |
|
| 391 | 391 | } |
| 392 | 392 | } |
| 393 | 393 | |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | |
| 396 | 396 | } |
| 397 | 397 | |
| 398 | -function wpinv_item_dropdown( $args = array() ) { |
|
| 398 | +function wpinv_item_dropdown($args = array()) { |
|
| 399 | 399 | $defaults = array( |
| 400 | 400 | 'name' => 'wpi_item', |
| 401 | 401 | 'id' => 'wpi_item', |
@@ -403,14 +403,14 @@ discard block |
||
| 403 | 403 | 'multiple' => false, |
| 404 | 404 | 'selected' => 0, |
| 405 | 405 | 'number' => -1, |
| 406 | - 'placeholder' => __( 'Choose a item', 'invoicing' ), |
|
| 407 | - 'data' => array( 'search-type' => 'item' ), |
|
| 406 | + 'placeholder' => __('Choose a item', 'invoicing'), |
|
| 407 | + 'data' => array('search-type' => 'item'), |
|
| 408 | 408 | 'show_option_all' => false, |
| 409 | 409 | 'show_option_none' => false, |
| 410 | 410 | 'show_recurring' => false, |
| 411 | 411 | ); |
| 412 | 412 | |
| 413 | - $args = wp_parse_args( $args, $defaults ); |
|
| 413 | + $args = wp_parse_args($args, $defaults); |
|
| 414 | 414 | |
| 415 | 415 | $item_args = array( |
| 416 | 416 | 'post_type' => 'wpi_item', |
@@ -419,40 +419,40 @@ discard block |
||
| 419 | 419 | 'posts_per_page' => $args['number'], |
| 420 | 420 | ); |
| 421 | 421 | |
| 422 | - $item_args = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults ); |
|
| 422 | + $item_args = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults); |
|
| 423 | 423 | |
| 424 | - $items = get_posts( $item_args ); |
|
| 424 | + $items = get_posts($item_args); |
|
| 425 | 425 | $options = array(); |
| 426 | - if ( $items ) { |
|
| 427 | - foreach ( $items as $item ) { |
|
| 428 | - $title = esc_html( $item->post_title ); |
|
| 426 | + if ($items) { |
|
| 427 | + foreach ($items as $item) { |
|
| 428 | + $title = esc_html($item->post_title); |
|
| 429 | 429 | |
| 430 | - if ( ! empty( $args['show_recurring'] ) ) { |
|
| 431 | - $title .= wpinv_get_item_suffix( $item->ID, false ); |
|
| 430 | + if (!empty($args['show_recurring'])) { |
|
| 431 | + $title .= wpinv_get_item_suffix($item->ID, false); |
|
| 432 | 432 | } |
| 433 | 433 | |
| 434 | - $options[ absint( $item->ID ) ] = $title; |
|
| 434 | + $options[absint($item->ID)] = $title; |
|
| 435 | 435 | } |
| 436 | 436 | } |
| 437 | 437 | |
| 438 | 438 | // This ensures that any selected items are included in the drop down |
| 439 | - if ( is_array( $args['selected'] ) ) { |
|
| 440 | - foreach ( $args['selected'] as $item ) { |
|
| 441 | - if ( ! in_array( $item, $options ) ) { |
|
| 442 | - $title = get_the_title( $item ); |
|
| 443 | - if ( ! empty( $args['show_recurring'] ) ) { |
|
| 444 | - $title .= wpinv_get_item_suffix( $item, false ); |
|
| 439 | + if (is_array($args['selected'])) { |
|
| 440 | + foreach ($args['selected'] as $item) { |
|
| 441 | + if (!in_array($item, $options)) { |
|
| 442 | + $title = get_the_title($item); |
|
| 443 | + if (!empty($args['show_recurring'])) { |
|
| 444 | + $title .= wpinv_get_item_suffix($item, false); |
|
| 445 | 445 | } |
| 446 | - $options[ $item ] = $title; |
|
| 446 | + $options[$item] = $title; |
|
| 447 | 447 | } |
| 448 | 448 | } |
| 449 | - } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) { |
|
| 450 | - if ( ! in_array( $args['selected'], $options ) ) { |
|
| 451 | - $title = get_the_title( $args['selected'] ); |
|
| 452 | - if ( ! empty( $args['show_recurring'] ) ) { |
|
| 453 | - $title .= wpinv_get_item_suffix( $args['selected'], false ); |
|
| 449 | + } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { |
|
| 450 | + if (!in_array($args['selected'], $options)) { |
|
| 451 | + $title = get_the_title($args['selected']); |
|
| 452 | + if (!empty($args['show_recurring'])) { |
|
| 453 | + $title .= wpinv_get_item_suffix($args['selected'], false); |
|
| 454 | 454 | } |
| 455 | - $options[ $args['selected'] ] = get_the_title( $args['selected'] ); |
|
| 455 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
| 456 | 456 | } |
| 457 | 457 | } |
| 458 | 458 | |
@@ -488,16 +488,16 @@ discard block |
||
| 488 | 488 | ); |
| 489 | 489 | |
| 490 | 490 | $options = array(); |
| 491 | - if ( $items ) { |
|
| 492 | - foreach ( $items as $item ) { |
|
| 493 | - $options[ $item->ID ] = esc_html( $item->post_title ) . wpinv_get_item_suffix( $item->ID, false ); |
|
| 491 | + if ($items) { |
|
| 492 | + foreach ($items as $item) { |
|
| 493 | + $options[$item->ID] = esc_html($item->post_title) . wpinv_get_item_suffix($item->ID, false); |
|
| 494 | 494 | } |
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | return $options; |
| 498 | 498 | } |
| 499 | 499 | |
| 500 | -function wpinv_html_checkbox( $args = array() ) { |
|
| 500 | +function wpinv_html_checkbox($args = array()) { |
|
| 501 | 501 | $defaults = array( |
| 502 | 502 | 'name' => null, |
| 503 | 503 | 'current' => null, |
@@ -508,17 +508,17 @@ discard block |
||
| 508 | 508 | ), |
| 509 | 509 | ); |
| 510 | 510 | |
| 511 | - $args = wp_parse_args( $args, $defaults ); |
|
| 511 | + $args = wp_parse_args($args, $defaults); |
|
| 512 | 512 | |
| 513 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 513 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 514 | 514 | $attr = ''; |
| 515 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
| 515 | + if (!empty($args['options']['disabled'])) { |
|
| 516 | 516 | $attr .= ' disabled="disabled"'; |
| 517 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
| 517 | + } elseif (!empty($args['options']['readonly'])) { |
|
| 518 | 518 | $attr .= ' readonly'; |
| 519 | 519 | } |
| 520 | 520 | |
| 521 | - $output = '<input type="checkbox"' . $attr . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . esc_attr( $class ) . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
| 521 | + $output = '<input type="checkbox"' . $attr . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . esc_attr($class) . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />'; |
|
| 522 | 522 | |
| 523 | 523 | return $output; |
| 524 | 524 | } |
@@ -526,34 +526,34 @@ discard block |
||
| 526 | 526 | /** |
| 527 | 527 | * Displays a hidden field. |
| 528 | 528 | */ |
| 529 | -function getpaid_hidden_field( $name, $value ) { |
|
| 530 | - echo "<input type='hidden' name='" . esc_attr( $name ) . "' value='" . esc_attr( $value ) . "' />"; |
|
| 529 | +function getpaid_hidden_field($name, $value) { |
|
| 530 | + echo "<input type='hidden' name='" . esc_attr($name) . "' value='" . esc_attr($value) . "' />"; |
|
| 531 | 531 | } |
| 532 | 532 | |
| 533 | 533 | /** |
| 534 | 534 | * Displays a submit field. |
| 535 | 535 | */ |
| 536 | -function getpaid_submit_field( $value, $name = 'submit', $class = 'btn-primary' ) { |
|
| 537 | - echo "<input type='submit' name='" . esc_attr( $name ) . "' value='" . esc_attr( $value ) . "' class='btn " . esc_attr( $class ) . "' />"; |
|
| 536 | +function getpaid_submit_field($value, $name = 'submit', $class = 'btn-primary') { |
|
| 537 | + echo "<input type='submit' name='" . esc_attr($name) . "' value='" . esc_attr($value) . "' class='btn " . esc_attr($class) . "' />"; |
|
| 538 | 538 | } |
| 539 | 539 | |
| 540 | -function wpinv_html_text( $args = array() ) { |
|
| 540 | +function wpinv_html_text($args = array()) { |
|
| 541 | 541 | // Backwards compatibility |
| 542 | - if ( func_num_args() > 1 ) { |
|
| 542 | + if (func_num_args() > 1) { |
|
| 543 | 543 | $args = func_get_args(); |
| 544 | 544 | |
| 545 | 545 | $name = $args[0]; |
| 546 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
| 547 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
| 548 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
| 546 | + $value = isset($args[1]) ? $args[1] : ''; |
|
| 547 | + $label = isset($args[2]) ? $args[2] : ''; |
|
| 548 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
| 549 | 549 | } |
| 550 | 550 | |
| 551 | 551 | $defaults = array( |
| 552 | 552 | 'id' => '', |
| 553 | - 'name' => isset( $name ) ? $name : 'text', |
|
| 554 | - 'value' => isset( $value ) ? $value : null, |
|
| 555 | - 'label' => isset( $label ) ? $label : null, |
|
| 556 | - 'desc' => isset( $desc ) ? $desc : null, |
|
| 553 | + 'name' => isset($name) ? $name : 'text', |
|
| 554 | + 'value' => isset($value) ? $value : null, |
|
| 555 | + 'label' => isset($label) ? $label : null, |
|
| 556 | + 'desc' => isset($desc) ? $desc : null, |
|
| 557 | 557 | 'placeholder' => '', |
| 558 | 558 | 'class' => 'regular-text', |
| 559 | 559 | 'disabled' => false, |
@@ -563,41 +563,41 @@ discard block |
||
| 563 | 563 | 'data' => false, |
| 564 | 564 | ); |
| 565 | 565 | |
| 566 | - $args = wp_parse_args( $args, $defaults ); |
|
| 566 | + $args = wp_parse_args($args, $defaults); |
|
| 567 | 567 | |
| 568 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 568 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 569 | 569 | $options = ''; |
| 570 | - if ( $args['required'] ) { |
|
| 570 | + if ($args['required']) { |
|
| 571 | 571 | $options .= ' required="required"'; |
| 572 | 572 | } |
| 573 | - if ( $args['readonly'] ) { |
|
| 573 | + if ($args['readonly']) { |
|
| 574 | 574 | $options .= ' readonly'; |
| 575 | 575 | } |
| 576 | - if ( $args['readonly'] ) { |
|
| 576 | + if ($args['readonly']) { |
|
| 577 | 577 | $options .= ' readonly'; |
| 578 | 578 | } |
| 579 | 579 | |
| 580 | 580 | $data = ''; |
| 581 | - if ( ! empty( $args['data'] ) ) { |
|
| 582 | - foreach ( $args['data'] as $key => $value ) { |
|
| 583 | - $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" '; |
|
| 581 | + if (!empty($args['data'])) { |
|
| 582 | + foreach ($args['data'] as $key => $value) { |
|
| 583 | + $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" '; |
|
| 584 | 584 | } |
| 585 | 585 | } |
| 586 | 586 | |
| 587 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
| 588 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
| 589 | - if ( ! empty( $args['desc'] ) ) { |
|
| 590 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
| 587 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
| 588 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>'; |
|
| 589 | + if (!empty($args['desc'])) { |
|
| 590 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
| 591 | 591 | } |
| 592 | 592 | |
| 593 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>'; |
|
| 593 | + $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>'; |
|
| 594 | 594 | |
| 595 | 595 | $output .= '</span>'; |
| 596 | 596 | |
| 597 | 597 | return $output; |
| 598 | 598 | } |
| 599 | 599 | |
| 600 | -function wpinv_html_textarea( $args = array() ) { |
|
| 600 | +function wpinv_html_textarea($args = array()) { |
|
| 601 | 601 | $defaults = array( |
| 602 | 602 | 'name' => 'textarea', |
| 603 | 603 | 'value' => null, |
@@ -608,31 +608,31 @@ discard block |
||
| 608 | 608 | 'placeholder' => '', |
| 609 | 609 | ); |
| 610 | 610 | |
| 611 | - $args = wp_parse_args( $args, $defaults ); |
|
| 611 | + $args = wp_parse_args($args, $defaults); |
|
| 612 | 612 | |
| 613 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 613 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 614 | 614 | $disabled = ''; |
| 615 | - if ( $args['disabled'] ) { |
|
| 615 | + if ($args['disabled']) { |
|
| 616 | 616 | $disabled = ' disabled="disabled"'; |
| 617 | 617 | } |
| 618 | 618 | |
| 619 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
| 620 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
| 621 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
| 619 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
| 620 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>'; |
|
| 621 | + $output .= '<textarea name="' . esc_attr($args['name']) . '" placeholder="' . esc_attr($args['placeholder']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>'; |
|
| 622 | 622 | |
| 623 | - if ( ! empty( $args['desc'] ) ) { |
|
| 624 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
| 623 | + if (!empty($args['desc'])) { |
|
| 624 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
| 625 | 625 | } |
| 626 | 626 | $output .= '</span>'; |
| 627 | 627 | |
| 628 | 628 | return $output; |
| 629 | 629 | } |
| 630 | 630 | |
| 631 | -function wpinv_html_ajax_user_search( $args = array() ) { |
|
| 631 | +function wpinv_html_ajax_user_search($args = array()) { |
|
| 632 | 632 | $defaults = array( |
| 633 | 633 | 'name' => 'user_id', |
| 634 | 634 | 'value' => null, |
| 635 | - 'placeholder' => __( 'Enter username', 'invoicing' ), |
|
| 635 | + 'placeholder' => __('Enter username', 'invoicing'), |
|
| 636 | 636 | 'label' => null, |
| 637 | 637 | 'desc' => null, |
| 638 | 638 | 'class' => '', |
@@ -641,13 +641,13 @@ discard block |
||
| 641 | 641 | 'data' => false, |
| 642 | 642 | ); |
| 643 | 643 | |
| 644 | - $args = wp_parse_args( $args, $defaults ); |
|
| 644 | + $args = wp_parse_args($args, $defaults); |
|
| 645 | 645 | |
| 646 | 646 | $args['class'] = 'wpinv-ajax-user-search ' . $args['class']; |
| 647 | 647 | |
| 648 | 648 | $output = '<span class="wpinv_user_search_wrap">'; |
| 649 | - $output .= wpinv_html_text( $args ); |
|
| 650 | - $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>'; |
|
| 649 | + $output .= wpinv_html_text($args); |
|
| 650 | + $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>'; |
|
| 651 | 651 | $output .= '</span>'; |
| 652 | 652 | |
| 653 | 653 | return $output; |
@@ -658,44 +658,44 @@ discard block |
||
| 658 | 658 | * |
| 659 | 659 | * @param string $template the template that is currently being used. |
| 660 | 660 | */ |
| 661 | -function wpinv_template( $template ) { |
|
| 661 | +function wpinv_template($template) { |
|
| 662 | 662 | global $post; |
| 663 | 663 | |
| 664 | - if ( ! is_admin() && ( is_single() || is_404() ) && ! empty( $post->ID ) && getpaid_is_invoice_post_type( get_post_type( $post->ID ) ) ) { |
|
| 664 | + if (!is_admin() && (is_single() || is_404()) && !empty($post->ID) && getpaid_is_invoice_post_type(get_post_type($post->ID))) { |
|
| 665 | 665 | |
| 666 | 666 | // If the user can view this invoice, display it. |
| 667 | - if ( wpinv_user_can_view_invoice( $post->ID ) ) { |
|
| 667 | + if (wpinv_user_can_view_invoice($post->ID)) { |
|
| 668 | 668 | |
| 669 | - return wpinv_get_template_part( 'wpinv-invoice-print', false, false ); |
|
| 669 | + return wpinv_get_template_part('wpinv-invoice-print', false, false); |
|
| 670 | 670 | |
| 671 | 671 | // Else display an error message. |
| 672 | 672 | } else { |
| 673 | 673 | |
| 674 | - return wpinv_get_template_part( 'wpinv-invalid-access', false, false ); |
|
| 674 | + return wpinv_get_template_part('wpinv-invalid-access', false, false); |
|
| 675 | 675 | |
| 676 | 676 | } |
| 677 | 677 | } |
| 678 | 678 | |
| 679 | 679 | return $template; |
| 680 | 680 | } |
| 681 | -add_filter( 'template_include', 'wpinv_template', 1000, 1 ); |
|
| 681 | +add_filter('template_include', 'wpinv_template', 1000, 1); |
|
| 682 | 682 | |
| 683 | 683 | function wpinv_get_business_address() { |
| 684 | 684 | $business_address = wpinv_store_address(); |
| 685 | - $business_address = ! empty( $business_address ) ? wp_kses_post( wpautop( $business_address ) ) : ''; |
|
| 685 | + $business_address = !empty($business_address) ? wp_kses_post(wpautop($business_address)) : ''; |
|
| 686 | 686 | |
| 687 | 687 | $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : ''; |
| 688 | 688 | |
| 689 | - return apply_filters( 'wpinv_get_business_address', $business_address ); |
|
| 689 | + return apply_filters('wpinv_get_business_address', $business_address); |
|
| 690 | 690 | } |
| 691 | 691 | |
| 692 | 692 | /** |
| 693 | 693 | * Displays the company address. |
| 694 | 694 | */ |
| 695 | 695 | function wpinv_display_from_address() { |
| 696 | - wpinv_get_template( 'invoice/company-address.php' ); |
|
| 696 | + wpinv_get_template('invoice/company-address.php'); |
|
| 697 | 697 | } |
| 698 | -add_action( 'getpaid_invoice_details_left', 'wpinv_display_from_address', 10 ); |
|
| 698 | +add_action('getpaid_invoice_details_left', 'wpinv_display_from_address', 10); |
|
| 699 | 699 | |
| 700 | 700 | /** |
| 701 | 701 | * Generates a watermark text for an invoice. |
@@ -703,9 +703,9 @@ discard block |
||
| 703 | 703 | * @param WPInv_Invoice $invoice |
| 704 | 704 | * @return string |
| 705 | 705 | */ |
| 706 | -function wpinv_watermark( $invoice ) { |
|
| 707 | - $watermark = wpinv_get_watermark( $invoice ); |
|
| 708 | - return apply_filters( 'wpinv_get_watermark', $watermark, $invoice ); |
|
| 706 | +function wpinv_watermark($invoice) { |
|
| 707 | + $watermark = wpinv_get_watermark($invoice); |
|
| 708 | + return apply_filters('wpinv_get_watermark', $watermark, $invoice); |
|
| 709 | 709 | } |
| 710 | 710 | |
| 711 | 711 | /** |
@@ -714,37 +714,37 @@ discard block |
||
| 714 | 714 | * @param WPInv_Invoice $invoice |
| 715 | 715 | * @return string |
| 716 | 716 | */ |
| 717 | -function wpinv_get_watermark( $invoice ) { |
|
| 717 | +function wpinv_get_watermark($invoice) { |
|
| 718 | 718 | return $invoice->get_status_nicename(); |
| 719 | 719 | } |
| 720 | 720 | |
| 721 | 721 | /** |
| 722 | 722 | * @deprecated |
| 723 | 723 | */ |
| 724 | -function wpinv_display_invoice_details( $invoice ) { |
|
| 725 | - return getpaid_invoice_meta( $invoice ); |
|
| 724 | +function wpinv_display_invoice_details($invoice) { |
|
| 725 | + return getpaid_invoice_meta($invoice); |
|
| 726 | 726 | } |
| 727 | 727 | |
| 728 | 728 | /** |
| 729 | 729 | * Displays invoice meta. |
| 730 | 730 | */ |
| 731 | -function getpaid_invoice_meta( $invoice ) { |
|
| 731 | +function getpaid_invoice_meta($invoice) { |
|
| 732 | 732 | |
| 733 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 733 | + $invoice = new WPInv_Invoice($invoice); |
|
| 734 | 734 | |
| 735 | 735 | // Ensure that we have an invoice. |
| 736 | - if ( 0 == $invoice->get_id() ) { |
|
| 736 | + if (0 == $invoice->get_id()) { |
|
| 737 | 737 | return; |
| 738 | 738 | } |
| 739 | 739 | |
| 740 | 740 | // Get the invoice meta. |
| 741 | - $meta = getpaid_get_invoice_meta( $invoice ); |
|
| 741 | + $meta = getpaid_get_invoice_meta($invoice); |
|
| 742 | 742 | |
| 743 | 743 | // Display the meta. |
| 744 | - wpinv_get_template( 'invoice/invoice-meta.php', compact( 'invoice', 'meta' ) ); |
|
| 744 | + wpinv_get_template('invoice/invoice-meta.php', compact('invoice', 'meta')); |
|
| 745 | 745 | |
| 746 | 746 | } |
| 747 | -add_action( 'getpaid_invoice_details_right', 'getpaid_invoice_meta', 10 ); |
|
| 747 | +add_action('getpaid_invoice_details_right', 'getpaid_invoice_meta', 10); |
|
| 748 | 748 | |
| 749 | 749 | /** |
| 750 | 750 | * Retrieves the address markup to use on Invoices. |
@@ -756,29 +756,29 @@ discard block |
||
| 756 | 756 | * @param string $separator How to separate address lines. |
| 757 | 757 | * @return string |
| 758 | 758 | */ |
| 759 | -function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) { |
|
| 759 | +function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') { |
|
| 760 | 760 | |
| 761 | 761 | // Retrieve the address markup... |
| 762 | - $country = empty( $billing_details['country'] ) ? '' : $billing_details['country']; |
|
| 763 | - $format = wpinv_get_full_address_format( $country ); |
|
| 762 | + $country = empty($billing_details['country']) ? '' : $billing_details['country']; |
|
| 763 | + $format = wpinv_get_full_address_format($country); |
|
| 764 | 764 | |
| 765 | 765 | // ... and the replacements. |
| 766 | - $replacements = wpinv_get_invoice_address_replacements( $billing_details ); |
|
| 766 | + $replacements = wpinv_get_invoice_address_replacements($billing_details); |
|
| 767 | 767 | |
| 768 | - $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format ); |
|
| 768 | + $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format); |
|
| 769 | 769 | |
| 770 | 770 | // Remove unavailable tags. |
| 771 | - $formatted_address = preg_replace( '/\{\{\w+\}\}/', '', $formatted_address ); |
|
| 771 | + $formatted_address = preg_replace('/\{\{\w+\}\}/', '', $formatted_address); |
|
| 772 | 772 | |
| 773 | 773 | // Clean up white space. |
| 774 | - $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
| 775 | - $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address ); |
|
| 774 | + $formatted_address = preg_replace('/ +/', ' ', trim($formatted_address)); |
|
| 775 | + $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address); |
|
| 776 | 776 | |
| 777 | 777 | // Break newlines apart and remove empty lines/trim commas and white space. |
| 778 | - $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
| 778 | + $formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address))); |
|
| 779 | 779 | |
| 780 | 780 | // Add html breaks. |
| 781 | - $formatted_address = implode( $separator, $formatted_address ); |
|
| 781 | + $formatted_address = implode($separator, $formatted_address); |
|
| 782 | 782 | |
| 783 | 783 | // We're done! |
| 784 | 784 | return $formatted_address; |
@@ -790,118 +790,118 @@ discard block |
||
| 790 | 790 | * |
| 791 | 791 | * @param WPInv_Invoice $invoice |
| 792 | 792 | */ |
| 793 | -function wpinv_display_to_address( $invoice = 0 ) { |
|
| 794 | - if ( ! empty( $invoice ) ) { |
|
| 795 | - wpinv_get_template( 'invoice/billing-address.php', compact( 'invoice' ) ); |
|
| 793 | +function wpinv_display_to_address($invoice = 0) { |
|
| 794 | + if (!empty($invoice)) { |
|
| 795 | + wpinv_get_template('invoice/billing-address.php', compact('invoice')); |
|
| 796 | 796 | } |
| 797 | 797 | } |
| 798 | -add_action( 'getpaid_invoice_details_left', 'wpinv_display_to_address', 40 ); |
|
| 798 | +add_action('getpaid_invoice_details_left', 'wpinv_display_to_address', 40); |
|
| 799 | 799 | |
| 800 | 800 | |
| 801 | 801 | /** |
| 802 | 802 | * Displays invoice line items. |
| 803 | 803 | */ |
| 804 | -function wpinv_display_line_items( $invoice_id = 0 ) { |
|
| 804 | +function wpinv_display_line_items($invoice_id = 0) { |
|
| 805 | 805 | |
| 806 | 806 | // Prepare the invoice. |
| 807 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 807 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 808 | 808 | |
| 809 | 809 | // Abort if there is no invoice. |
| 810 | - if ( 0 == $invoice->get_id() ) { |
|
| 810 | + if (0 == $invoice->get_id()) { |
|
| 811 | 811 | return; |
| 812 | 812 | } |
| 813 | 813 | |
| 814 | 814 | // Line item columns. |
| 815 | - $columns = getpaid_invoice_item_columns( $invoice ); |
|
| 816 | - $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice ); |
|
| 815 | + $columns = getpaid_invoice_item_columns($invoice); |
|
| 816 | + $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice); |
|
| 817 | 817 | |
| 818 | - wpinv_get_template( 'invoice/line-items.php', compact( 'invoice', 'columns' ) ); |
|
| 818 | + wpinv_get_template('invoice/line-items.php', compact('invoice', 'columns')); |
|
| 819 | 819 | } |
| 820 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_line_items', 10 ); |
|
| 820 | +add_action('getpaid_invoice_line_items', 'wpinv_display_line_items', 10); |
|
| 821 | 821 | |
| 822 | 822 | /** |
| 823 | 823 | * Displays invoice subscriptions. |
| 824 | 824 | * |
| 825 | 825 | * @param WPInv_Invoice $invoice |
| 826 | 826 | */ |
| 827 | -function getpaid_display_invoice_subscriptions( $invoice ) { |
|
| 827 | +function getpaid_display_invoice_subscriptions($invoice) { |
|
| 828 | 828 | |
| 829 | 829 | // Subscriptions. |
| 830 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
| 830 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
| 831 | 831 | |
| 832 | - if ( empty( $subscriptions ) || ! $invoice->is_recurring() ) { |
|
| 832 | + if (empty($subscriptions) || !$invoice->is_recurring()) { |
|
| 833 | 833 | return; |
| 834 | 834 | } |
| 835 | 835 | |
| 836 | - $main_subscription = getpaid_get_invoice_subscription( $invoice ); |
|
| 836 | + $main_subscription = getpaid_get_invoice_subscription($invoice); |
|
| 837 | 837 | |
| 838 | 838 | // Display related subscriptions. |
| 839 | - if ( is_array( $subscriptions ) ) { |
|
| 840 | - printf( '<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__( 'Related Subscriptions', 'invoicing' ) ); |
|
| 841 | - getpaid_admin_subscription_related_subscriptions_metabox( $main_subscription, false ); |
|
| 839 | + if (is_array($subscriptions)) { |
|
| 840 | + printf('<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__('Related Subscriptions', 'invoicing')); |
|
| 841 | + getpaid_admin_subscription_related_subscriptions_metabox($main_subscription, false); |
|
| 842 | 842 | } |
| 843 | 843 | |
| 844 | - if ( $main_subscription->get_total_payments() > 1 ) { |
|
| 845 | - printf( '<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__( 'Related Invoices', 'invoicing' ) ); |
|
| 846 | - getpaid_admin_subscription_invoice_details_metabox( $main_subscription, false ); |
|
| 844 | + if ($main_subscription->get_total_payments() > 1) { |
|
| 845 | + printf('<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__('Related Invoices', 'invoicing')); |
|
| 846 | + getpaid_admin_subscription_invoice_details_metabox($main_subscription, false); |
|
| 847 | 847 | } |
| 848 | 848 | |
| 849 | 849 | } |
| 850 | -add_action( 'getpaid_invoice_line_items', 'getpaid_display_invoice_subscriptions', 55 ); |
|
| 851 | -add_action( 'wpinv_receipt_end', 'getpaid_display_invoice_subscriptions', 11 ); |
|
| 850 | +add_action('getpaid_invoice_line_items', 'getpaid_display_invoice_subscriptions', 55); |
|
| 851 | +add_action('wpinv_receipt_end', 'getpaid_display_invoice_subscriptions', 11); |
|
| 852 | 852 | |
| 853 | 853 | /** |
| 854 | 854 | * Displays invoice notices on invoices. |
| 855 | 855 | */ |
| 856 | 856 | function wpinv_display_invoice_notice() { |
| 857 | 857 | |
| 858 | - $label = wpinv_get_option( 'vat_invoice_notice_label' ); |
|
| 859 | - $notice = wpinv_get_option( 'vat_invoice_notice' ); |
|
| 858 | + $label = wpinv_get_option('vat_invoice_notice_label'); |
|
| 859 | + $notice = wpinv_get_option('vat_invoice_notice'); |
|
| 860 | 860 | |
| 861 | - if ( empty( $label ) && empty( $notice ) ) { |
|
| 861 | + if (empty($label) && empty($notice)) { |
|
| 862 | 862 | return; |
| 863 | 863 | } |
| 864 | 864 | |
| 865 | 865 | echo '<div class="mt-4 mb-4 wpinv-vat-notice">'; |
| 866 | 866 | |
| 867 | - if ( ! empty( $label ) ) { |
|
| 868 | - echo "<h5>" . esc_html( $label ) . "</h5>"; |
|
| 867 | + if (!empty($label)) { |
|
| 868 | + echo "<h5>" . esc_html($label) . "</h5>"; |
|
| 869 | 869 | } |
| 870 | 870 | |
| 871 | - if ( ! empty( $notice ) ) { |
|
| 872 | - echo '<small class="form-text text-muted">' . wp_kses_post( wpautop( wptexturize( $notice ) ) ) . '</small>'; |
|
| 871 | + if (!empty($notice)) { |
|
| 872 | + echo '<small class="form-text text-muted">' . wp_kses_post(wpautop(wptexturize($notice))) . '</small>'; |
|
| 873 | 873 | } |
| 874 | 874 | |
| 875 | 875 | echo '</div>'; |
| 876 | 876 | } |
| 877 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100 ); |
|
| 877 | +add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100); |
|
| 878 | 878 | |
| 879 | 879 | /** |
| 880 | 880 | * @param WPInv_Invoice $invoice |
| 881 | 881 | */ |
| 882 | -function wpinv_display_invoice_notes( $invoice ) { |
|
| 882 | +function wpinv_display_invoice_notes($invoice) { |
|
| 883 | 883 | |
| 884 | 884 | // Retrieve the notes. |
| 885 | - $notes = wpinv_get_invoice_notes( $invoice->get_id(), 'customer' ); |
|
| 885 | + $notes = wpinv_get_invoice_notes($invoice->get_id(), 'customer'); |
|
| 886 | 886 | |
| 887 | 887 | // Abort if we have non. |
| 888 | - if ( empty( $notes ) ) { |
|
| 888 | + if (empty($notes)) { |
|
| 889 | 889 | return; |
| 890 | 890 | } |
| 891 | 891 | |
| 892 | 892 | // Echo the note. |
| 893 | 893 | echo '<div class="getpaid-invoice-notes-wrapper position-relative my-4">'; |
| 894 | - echo '<h2 class="getpaid-invoice-notes-title mb-1 p-0 h4">' . esc_html__( 'Notes', 'invoicing' ) . '</h2>'; |
|
| 894 | + echo '<h2 class="getpaid-invoice-notes-title mb-1 p-0 h4">' . esc_html__('Notes', 'invoicing') . '</h2>'; |
|
| 895 | 895 | echo '<ul class="getpaid-invoice-notes text-break overflow-auto list-unstyled p-0 m-0">'; |
| 896 | 896 | |
| 897 | - foreach ( $notes as $note ) { |
|
| 898 | - wpinv_get_invoice_note_line_item( $note ); |
|
| 897 | + foreach ($notes as $note) { |
|
| 898 | + wpinv_get_invoice_note_line_item($note); |
|
| 899 | 899 | } |
| 900 | 900 | |
| 901 | 901 | echo '</ul>'; |
| 902 | 902 | echo '</div>'; |
| 903 | 903 | } |
| 904 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60 ); |
|
| 904 | +add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60); |
|
| 905 | 905 | |
| 906 | 906 | /** |
| 907 | 907 | * Loads scripts on our invoice templates. |
@@ -909,32 +909,32 @@ discard block |
||
| 909 | 909 | function wpinv_display_style() { |
| 910 | 910 | |
| 911 | 911 | // Make sure that all scripts have been loaded. |
| 912 | - if ( ! did_action( 'wp_enqueue_scripts' ) ) { |
|
| 913 | - do_action( 'wp_enqueue_scripts' ); |
|
| 912 | + if (!did_action('wp_enqueue_scripts')) { |
|
| 913 | + do_action('wp_enqueue_scripts'); |
|
| 914 | 914 | } |
| 915 | 915 | |
| 916 | 916 | // Register the invoices style. |
| 917 | - wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice.css' ) ); |
|
| 917 | + wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice.css')); |
|
| 918 | 918 | |
| 919 | 919 | // Load required styles |
| 920 | - wp_print_styles( 'wpinv-single-style' ); |
|
| 921 | - wp_print_styles( 'ayecode-ui' ); |
|
| 920 | + wp_print_styles('wpinv-single-style'); |
|
| 921 | + wp_print_styles('ayecode-ui'); |
|
| 922 | 922 | |
| 923 | 923 | // Maybe load custom css. |
| 924 | - $custom_css = wpinv_get_option( 'template_custom_css' ); |
|
| 924 | + $custom_css = wpinv_get_option('template_custom_css'); |
|
| 925 | 925 | |
| 926 | - if ( isset( $custom_css ) && ! empty( $custom_css ) ) { |
|
| 927 | - $custom_css = wp_kses( $custom_css, array( '\'', '\"' ) ); |
|
| 928 | - $custom_css = str_replace( '>', '>', $custom_css ); |
|
| 926 | + if (isset($custom_css) && !empty($custom_css)) { |
|
| 927 | + $custom_css = wp_kses($custom_css, array('\'', '\"')); |
|
| 928 | + $custom_css = str_replace('>', '>', $custom_css); |
|
| 929 | 929 | echo '<style type="text/css">'; |
| 930 | - echo wp_kses_post( $custom_css ); |
|
| 930 | + echo wp_kses_post($custom_css); |
|
| 931 | 931 | echo '</style>'; |
| 932 | 932 | } |
| 933 | 933 | |
| 934 | 934 | wp_site_icon(); |
| 935 | 935 | } |
| 936 | -add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' ); |
|
| 937 | -add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' ); |
|
| 936 | +add_action('wpinv_invoice_print_head', 'wpinv_display_style'); |
|
| 937 | +add_action('wpinv_invalid_invoice_head', 'wpinv_display_style'); |
|
| 938 | 938 | |
| 939 | 939 | |
| 940 | 940 | /** |
@@ -946,41 +946,41 @@ discard block |
||
| 946 | 946 | // Retrieve the current invoice. |
| 947 | 947 | $invoice_id = getpaid_get_current_invoice_id(); |
| 948 | 948 | |
| 949 | - if ( empty( $invoice_id ) ) { |
|
| 949 | + if (empty($invoice_id)) { |
|
| 950 | 950 | |
| 951 | 951 | return aui()->alert( |
| 952 | 952 | array( |
| 953 | 953 | 'type' => 'warning', |
| 954 | - 'content' => __( 'Invalid invoice', 'invoicing' ), |
|
| 954 | + 'content' => __('Invalid invoice', 'invoicing'), |
|
| 955 | 955 | ) |
| 956 | 956 | ); |
| 957 | 957 | |
| 958 | 958 | } |
| 959 | 959 | |
| 960 | 960 | // Can the user view this invoice? |
| 961 | - if ( ! wpinv_user_can_view_invoice( $invoice_id ) ) { |
|
| 961 | + if (!wpinv_user_can_view_invoice($invoice_id)) { |
|
| 962 | 962 | |
| 963 | 963 | return aui()->alert( |
| 964 | 964 | array( |
| 965 | 965 | 'type' => 'warning', |
| 966 | - 'content' => __( 'You are not allowed to view this invoice', 'invoicing' ), |
|
| 966 | + 'content' => __('You are not allowed to view this invoice', 'invoicing'), |
|
| 967 | 967 | ) |
| 968 | 968 | ); |
| 969 | 969 | |
| 970 | 970 | } |
| 971 | 971 | |
| 972 | 972 | // Ensure that it is not yet paid for. |
| 973 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 973 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 974 | 974 | |
| 975 | 975 | // Maybe mark it as viewed. |
| 976 | - getpaid_maybe_mark_invoice_as_viewed( $invoice ); |
|
| 976 | + getpaid_maybe_mark_invoice_as_viewed($invoice); |
|
| 977 | 977 | |
| 978 | - if ( $invoice->is_paid() ) { |
|
| 978 | + if ($invoice->is_paid()) { |
|
| 979 | 979 | |
| 980 | 980 | return aui()->alert( |
| 981 | 981 | array( |
| 982 | 982 | 'type' => 'success', |
| 983 | - 'content' => __( 'This invoice has already been paid.', 'invoicing' ), |
|
| 983 | + 'content' => __('This invoice has already been paid.', 'invoicing'), |
|
| 984 | 984 | ) |
| 985 | 985 | ); |
| 986 | 986 | |
@@ -990,15 +990,15 @@ discard block |
||
| 990 | 990 | $wpi_checkout_id = $invoice_id; |
| 991 | 991 | |
| 992 | 992 | // Retrieve appropriate payment form. |
| 993 | - $payment_form = new GetPaid_Payment_Form( $invoice->get_meta( 'force_payment_form' ) ); |
|
| 994 | - $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
| 993 | + $payment_form = new GetPaid_Payment_Form($invoice->get_meta('force_payment_form')); |
|
| 994 | + $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
| 995 | 995 | |
| 996 | - if ( ! $payment_form->exists() ) { |
|
| 996 | + if (!$payment_form->exists()) { |
|
| 997 | 997 | |
| 998 | 998 | return aui()->alert( |
| 999 | 999 | array( |
| 1000 | 1000 | 'type' => 'warning', |
| 1001 | - 'content' => __( 'Error loading the payment form', 'invoicing' ), |
|
| 1001 | + 'content' => __('Error loading the payment form', 'invoicing'), |
|
| 1002 | 1002 | ) |
| 1003 | 1003 | ); |
| 1004 | 1004 | |
@@ -1007,29 +1007,29 @@ discard block |
||
| 1007 | 1007 | // Set the invoice. |
| 1008 | 1008 | $payment_form->invoice = $invoice; |
| 1009 | 1009 | |
| 1010 | - if ( ! $payment_form->is_default() ) { |
|
| 1010 | + if (!$payment_form->is_default()) { |
|
| 1011 | 1011 | |
| 1012 | 1012 | $items = array(); |
| 1013 | 1013 | $item_ids = array(); |
| 1014 | 1014 | |
| 1015 | - foreach ( $invoice->get_items() as $item ) { |
|
| 1016 | - if ( ! in_array( $item->get_id(), $item_ids ) ) { |
|
| 1015 | + foreach ($invoice->get_items() as $item) { |
|
| 1016 | + if (!in_array($item->get_id(), $item_ids)) { |
|
| 1017 | 1017 | $item_ids[] = $item->get_id(); |
| 1018 | 1018 | $items[] = $item; |
| 1019 | 1019 | } |
| 1020 | 1020 | } |
| 1021 | 1021 | |
| 1022 | - foreach ( $payment_form->get_items() as $item ) { |
|
| 1023 | - if ( ! in_array( $item->get_id(), $item_ids ) ) { |
|
| 1022 | + foreach ($payment_form->get_items() as $item) { |
|
| 1023 | + if (!in_array($item->get_id(), $item_ids)) { |
|
| 1024 | 1024 | $item_ids[] = $item->get_id(); |
| 1025 | 1025 | $items[] = $item; |
| 1026 | 1026 | } |
| 1027 | 1027 | } |
| 1028 | 1028 | |
| 1029 | - $payment_form->set_items( $items ); |
|
| 1029 | + $payment_form->set_items($items); |
|
| 1030 | 1030 | |
| 1031 | 1031 | } else { |
| 1032 | - $payment_form->set_items( $invoice->get_items() ); |
|
| 1032 | + $payment_form->set_items($invoice->get_items()); |
|
| 1033 | 1033 | } |
| 1034 | 1034 | |
| 1035 | 1035 | // Generate the html. |
@@ -1038,7 +1038,7 @@ discard block |
||
| 1038 | 1038 | } |
| 1039 | 1039 | |
| 1040 | 1040 | function wpinv_empty_cart_message() { |
| 1041 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
| 1041 | + return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>'); |
|
| 1042 | 1042 | } |
| 1043 | 1043 | |
| 1044 | 1044 | /** |
@@ -1056,76 +1056,76 @@ discard block |
||
| 1056 | 1056 | true |
| 1057 | 1057 | ); |
| 1058 | 1058 | } |
| 1059 | -add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
|
| 1059 | +add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart'); |
|
| 1060 | 1060 | |
| 1061 | 1061 | /** |
| 1062 | 1062 | * Filters the receipt page. |
| 1063 | 1063 | */ |
| 1064 | -function wpinv_filter_success_page_content( $content ) { |
|
| 1064 | +function wpinv_filter_success_page_content($content) { |
|
| 1065 | 1065 | |
| 1066 | 1066 | // Maybe abort early. |
| 1067 | - if ( is_admin() || ! is_singular() || ! in_the_loop() || ! is_main_query() || is_preview() ) { |
|
| 1067 | + if (is_admin() || !is_singular() || !in_the_loop() || !is_main_query() || is_preview()) { |
|
| 1068 | 1068 | return $content; |
| 1069 | 1069 | } |
| 1070 | 1070 | |
| 1071 | 1071 | // Ensure this is our page. |
| 1072 | - if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) { |
|
| 1072 | + if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) { |
|
| 1073 | 1073 | |
| 1074 | - $gateway = sanitize_text_field( $_GET['payment-confirm'] ); |
|
| 1075 | - return apply_filters( "wpinv_payment_confirm_$gateway", $content ); |
|
| 1074 | + $gateway = sanitize_text_field($_GET['payment-confirm']); |
|
| 1075 | + return apply_filters("wpinv_payment_confirm_$gateway", $content); |
|
| 1076 | 1076 | |
| 1077 | 1077 | } |
| 1078 | 1078 | |
| 1079 | 1079 | return $content; |
| 1080 | 1080 | } |
| 1081 | -add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 ); |
|
| 1081 | +add_filter('the_content', 'wpinv_filter_success_page_content', 99999); |
|
| 1082 | 1082 | |
| 1083 | -function wpinv_invoice_link( $invoice_id ) { |
|
| 1084 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1083 | +function wpinv_invoice_link($invoice_id) { |
|
| 1084 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1085 | 1085 | |
| 1086 | - if ( empty( $invoice ) ) { |
|
| 1086 | + if (empty($invoice)) { |
|
| 1087 | 1087 | return null; |
| 1088 | 1088 | } |
| 1089 | 1089 | |
| 1090 | - $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>'; |
|
| 1090 | + $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>'; |
|
| 1091 | 1091 | |
| 1092 | - return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice ); |
|
| 1092 | + return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice); |
|
| 1093 | 1093 | } |
| 1094 | 1094 | |
| 1095 | -function wpinv_get_invoice_note_line_item( $note, $echo = true ) { |
|
| 1096 | - if ( empty( $note ) ) { |
|
| 1095 | +function wpinv_get_invoice_note_line_item($note, $echo = true) { |
|
| 1096 | + if (empty($note)) { |
|
| 1097 | 1097 | return null; |
| 1098 | 1098 | } |
| 1099 | 1099 | |
| 1100 | - if ( is_int( $note ) ) { |
|
| 1101 | - $note = get_comment( $note ); |
|
| 1100 | + if (is_int($note)) { |
|
| 1101 | + $note = get_comment($note); |
|
| 1102 | 1102 | } |
| 1103 | 1103 | |
| 1104 | - if ( ! ( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) { |
|
| 1104 | + if (!(is_object($note) && is_a($note, 'WP_Comment'))) { |
|
| 1105 | 1105 | return null; |
| 1106 | 1106 | } |
| 1107 | 1107 | |
| 1108 | - $note_classes = array( 'note' ); |
|
| 1109 | - $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : ''; |
|
| 1108 | + $note_classes = array('note'); |
|
| 1109 | + $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : ''; |
|
| 1110 | 1110 | $note_classes[] = $note->comment_author === 'System' ? 'system-note' : ''; |
| 1111 | - $note_classes = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note ); |
|
| 1112 | - $note_classes = ! empty( $note_classes ) ? implode( ' ', $note_classes ) : ''; |
|
| 1111 | + $note_classes = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note); |
|
| 1112 | + $note_classes = !empty($note_classes) ? implode(' ', $note_classes) : ''; |
|
| 1113 | 1113 | |
| 1114 | 1114 | ob_start(); |
| 1115 | 1115 | ?> |
| 1116 | - <li rel="<?php echo absint( $note->comment_ID ); ?>" class="<?php echo esc_attr( $note_classes ); ?> mb-2"> |
|
| 1116 | + <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?> mb-2"> |
|
| 1117 | 1117 | <div class="note_content"> |
| 1118 | 1118 | |
| 1119 | - <?php echo wp_kses_post( wptexturize( $note->comment_content ) ); ?> |
|
| 1119 | + <?php echo wp_kses_post(wptexturize($note->comment_content)); ?> |
|
| 1120 | 1120 | |
| 1121 | - <?php if ( ! is_admin() ) : ?> |
|
| 1121 | + <?php if (!is_admin()) : ?> |
|
| 1122 | 1122 | <em class="small form-text text-muted mt-0"> |
| 1123 | 1123 | <?php |
| 1124 | 1124 | printf( |
| 1125 | - esc_html__( '%1$s - %2$s at %3$s', 'invoicing' ), |
|
| 1126 | - esc_html( $note->comment_author ), |
|
| 1127 | - esc_html( getpaid_format_date_value( $note->comment_date ) ), |
|
| 1128 | - esc_html( date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) ) |
|
| 1125 | + esc_html__('%1$s - %2$s at %3$s', 'invoicing'), |
|
| 1126 | + esc_html($note->comment_author), |
|
| 1127 | + esc_html(getpaid_format_date_value($note->comment_date)), |
|
| 1128 | + esc_html(date_i18n(get_option('time_format'), strtotime($note->comment_date))) |
|
| 1129 | 1129 | ); |
| 1130 | 1130 | ?> |
| 1131 | 1131 | </em> |
@@ -1133,21 +1133,21 @@ discard block |
||
| 1133 | 1133 | |
| 1134 | 1134 | </div> |
| 1135 | 1135 | |
| 1136 | - <?php if ( is_admin() ) : ?> |
|
| 1136 | + <?php if (is_admin()) : ?> |
|
| 1137 | 1137 | |
| 1138 | 1138 | <p class="meta px-4 py-2"> |
| 1139 | - <abbr class="exact-date" title="<?php echo esc_attr( $note->comment_date ); ?>"> |
|
| 1139 | + <abbr class="exact-date" title="<?php echo esc_attr($note->comment_date); ?>"> |
|
| 1140 | 1140 | <?php |
| 1141 | 1141 | printf( |
| 1142 | - esc_html__( '%1$s - %2$s at %3$s', 'invoicing' ), |
|
| 1143 | - esc_html( $note->comment_author ), |
|
| 1144 | - esc_html( getpaid_format_date_value( $note->comment_date ) ), |
|
| 1145 | - esc_html( date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) ) |
|
| 1142 | + esc_html__('%1$s - %2$s at %3$s', 'invoicing'), |
|
| 1143 | + esc_html($note->comment_author), |
|
| 1144 | + esc_html(getpaid_format_date_value($note->comment_date)), |
|
| 1145 | + esc_html(date_i18n(get_option('time_format'), strtotime($note->comment_date))) |
|
| 1146 | 1146 | ); |
| 1147 | 1147 | ?> |
| 1148 | 1148 | </abbr> |
| 1149 | - <?php if ( $note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing() ) { ?> |
|
| 1150 | - <a href="#" class="delete_note" data-id="<?php echo esc_attr( $note->comment_ID ); ?>"><?php esc_html_e( 'Delete note', 'invoicing' ); ?></a> |
|
| 1149 | + <?php if ($note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing()) { ?> |
|
| 1150 | + <a href="#" class="delete_note" data-id="<?php echo esc_attr($note->comment_ID); ?>"><?php esc_html_e('Delete note', 'invoicing'); ?></a> |
|
| 1151 | 1151 | <?php } ?> |
| 1152 | 1152 | </p> |
| 1153 | 1153 | |
@@ -1156,10 +1156,10 @@ discard block |
||
| 1156 | 1156 | </li> |
| 1157 | 1157 | <?php |
| 1158 | 1158 | $note_content = ob_get_clean(); |
| 1159 | - $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo ); |
|
| 1159 | + $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo); |
|
| 1160 | 1160 | |
| 1161 | - if ( $echo ) { |
|
| 1162 | - echo wp_kses_post( $note_content ); |
|
| 1161 | + if ($echo) { |
|
| 1162 | + echo wp_kses_post($note_content); |
|
| 1163 | 1163 | } else { |
| 1164 | 1164 | return $note_content; |
| 1165 | 1165 | } |
@@ -1172,43 +1172,43 @@ discard block |
||
| 1172 | 1172 | * @return string |
| 1173 | 1173 | */ |
| 1174 | 1174 | function wpinv_get_policy_text() { |
| 1175 | - $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 ); |
|
| 1175 | + $privacy_page_id = get_option('wp_page_for_privacy_policy', 0); |
|
| 1176 | 1176 | |
| 1177 | - $text = wpinv_get_option( 'invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' ) ); |
|
| 1177 | + $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]')); |
|
| 1178 | 1178 | |
| 1179 | - if ( ! $privacy_page_id ) { |
|
| 1180 | - $privacy_page_id = wpinv_get_option( 'privacy_page', 0 ); |
|
| 1179 | + if (!$privacy_page_id) { |
|
| 1180 | + $privacy_page_id = wpinv_get_option('privacy_page', 0); |
|
| 1181 | 1181 | } |
| 1182 | 1182 | |
| 1183 | - $privacy_link = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' ); |
|
| 1183 | + $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing'); |
|
| 1184 | 1184 | |
| 1185 | 1185 | $find_replace = array( |
| 1186 | 1186 | '[wpinv_privacy_policy]' => $privacy_link, |
| 1187 | 1187 | ); |
| 1188 | 1188 | |
| 1189 | - $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text ); |
|
| 1189 | + $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text); |
|
| 1190 | 1190 | |
| 1191 | - return wp_kses_post( wpautop( $privacy_text ) ); |
|
| 1191 | + return wp_kses_post(wpautop($privacy_text)); |
|
| 1192 | 1192 | } |
| 1193 | 1193 | |
| 1194 | 1194 | function wpinv_oxygen_fix_conflict() { |
| 1195 | 1195 | global $ct_ignore_post_types; |
| 1196 | 1196 | |
| 1197 | - if ( ! is_array( $ct_ignore_post_types ) ) { |
|
| 1197 | + if (!is_array($ct_ignore_post_types)) { |
|
| 1198 | 1198 | $ct_ignore_post_types = array(); |
| 1199 | 1199 | } |
| 1200 | 1200 | |
| 1201 | - $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item', 'wpi_payment_form' ); |
|
| 1201 | + $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item', 'wpi_payment_form'); |
|
| 1202 | 1202 | |
| 1203 | - foreach ( $post_types as $post_type ) { |
|
| 1203 | + foreach ($post_types as $post_type) { |
|
| 1204 | 1204 | $ct_ignore_post_types[] = $post_type; |
| 1205 | 1205 | |
| 1206 | 1206 | // Ignore post type |
| 1207 | - add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 ); |
|
| 1207 | + add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999); |
|
| 1208 | 1208 | } |
| 1209 | 1209 | |
| 1210 | - remove_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
| 1211 | - add_filter( 'template_include', 'wpinv_template', 999, 1 ); |
|
| 1210 | + remove_filter('template_include', 'wpinv_template', 10, 1); |
|
| 1211 | + add_filter('template_include', 'wpinv_template', 999, 1); |
|
| 1212 | 1212 | } |
| 1213 | 1213 | |
| 1214 | 1214 | /** |
@@ -1216,10 +1216,10 @@ discard block |
||
| 1216 | 1216 | * |
| 1217 | 1217 | * @param GetPaid_Payment_Form $form |
| 1218 | 1218 | */ |
| 1219 | -function getpaid_display_payment_form( $form ) { |
|
| 1219 | +function getpaid_display_payment_form($form) { |
|
| 1220 | 1220 | |
| 1221 | - if ( is_numeric( $form ) ) { |
|
| 1222 | - $form = new GetPaid_Payment_Form( $form ); |
|
| 1221 | + if (is_numeric($form)) { |
|
| 1222 | + $form = new GetPaid_Payment_Form($form); |
|
| 1223 | 1223 | } |
| 1224 | 1224 | |
| 1225 | 1225 | $form->display(); |
@@ -1229,61 +1229,61 @@ discard block |
||
| 1229 | 1229 | /** |
| 1230 | 1230 | * Helper function to display a item payment form on the frontend. |
| 1231 | 1231 | */ |
| 1232 | -function getpaid_display_item_payment_form( $items ) { |
|
| 1232 | +function getpaid_display_item_payment_form($items) { |
|
| 1233 | 1233 | |
| 1234 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
| 1235 | - $form->set_items( $items ); |
|
| 1234 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
| 1235 | + $form->set_items($items); |
|
| 1236 | 1236 | |
| 1237 | - if ( 0 == count( $form->get_items() ) ) { |
|
| 1237 | + if (0 == count($form->get_items())) { |
|
| 1238 | 1238 | aui()->alert( |
| 1239 | 1239 | array( |
| 1240 | 1240 | 'type' => 'warning', |
| 1241 | - 'content' => __( 'No published items found', 'invoicing' ), |
|
| 1241 | + 'content' => __('No published items found', 'invoicing'), |
|
| 1242 | 1242 | ), |
| 1243 | 1243 | true |
| 1244 | 1244 | ); |
| 1245 | 1245 | return; |
| 1246 | 1246 | } |
| 1247 | 1247 | |
| 1248 | - $extra_items = esc_attr( getpaid_convert_items_to_string( $items ) ); |
|
| 1249 | - $extra_items_key = md5( NONCE_KEY . AUTH_KEY . $extra_items ); |
|
| 1248 | + $extra_items = esc_attr(getpaid_convert_items_to_string($items)); |
|
| 1249 | + $extra_items_key = md5(NONCE_KEY . AUTH_KEY . $extra_items); |
|
| 1250 | 1250 | $extra_items = "<input type='hidden' name='getpaid-form-items' value='$extra_items' />"; |
| 1251 | 1251 | $extra_items .= "<input type='hidden' name='getpaid-form-items-key' value='$extra_items_key' />"; |
| 1252 | 1252 | |
| 1253 | - $form->display( $extra_items ); |
|
| 1253 | + $form->display($extra_items); |
|
| 1254 | 1254 | } |
| 1255 | 1255 | |
| 1256 | 1256 | /** |
| 1257 | 1257 | * Helper function to display an invoice payment form on the frontend. |
| 1258 | 1258 | */ |
| 1259 | -function getpaid_display_invoice_payment_form( $invoice_id ) { |
|
| 1259 | +function getpaid_display_invoice_payment_form($invoice_id) { |
|
| 1260 | 1260 | |
| 1261 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1261 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1262 | 1262 | |
| 1263 | - if ( empty( $invoice ) ) { |
|
| 1263 | + if (empty($invoice)) { |
|
| 1264 | 1264 | aui()->alert( |
| 1265 | 1265 | array( |
| 1266 | 1266 | 'type' => 'warning', |
| 1267 | - 'content' => __( 'Invoice not found', 'invoicing' ), |
|
| 1267 | + 'content' => __('Invoice not found', 'invoicing'), |
|
| 1268 | 1268 | ), |
| 1269 | 1269 | true |
| 1270 | 1270 | ); |
| 1271 | 1271 | return; |
| 1272 | 1272 | } |
| 1273 | 1273 | |
| 1274 | - if ( $invoice->is_paid() ) { |
|
| 1274 | + if ($invoice->is_paid()) { |
|
| 1275 | 1275 | aui()->alert( |
| 1276 | 1276 | array( |
| 1277 | 1277 | 'type' => 'warning', |
| 1278 | - 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
| 1278 | + 'content' => __('Invoice has already been paid', 'invoicing'), |
|
| 1279 | 1279 | ), |
| 1280 | 1280 | true |
| 1281 | 1281 | ); |
| 1282 | 1282 | return; |
| 1283 | 1283 | } |
| 1284 | 1284 | |
| 1285 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
| 1286 | - $form->set_items( $invoice->get_items() ); |
|
| 1285 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
| 1286 | + $form->set_items($invoice->get_items()); |
|
| 1287 | 1287 | |
| 1288 | 1288 | $form->display(); |
| 1289 | 1289 | } |
@@ -1291,25 +1291,25 @@ discard block |
||
| 1291 | 1291 | /** |
| 1292 | 1292 | * Helper function to convert item string to array. |
| 1293 | 1293 | */ |
| 1294 | -function getpaid_convert_items_to_array( $items ) { |
|
| 1295 | - $items = array_filter( array_map( 'trim', explode( ',', $items ) ) ); |
|
| 1294 | +function getpaid_convert_items_to_array($items) { |
|
| 1295 | + $items = array_filter(array_map('trim', explode(',', $items))); |
|
| 1296 | 1296 | $prepared = array(); |
| 1297 | 1297 | |
| 1298 | - foreach ( $items as $item ) { |
|
| 1299 | - $data = array_map( 'trim', explode( '|', $item ) ); |
|
| 1298 | + foreach ($items as $item) { |
|
| 1299 | + $data = array_map('trim', explode('|', $item)); |
|
| 1300 | 1300 | |
| 1301 | - if ( empty( $data[0] ) || ! is_numeric( $data[0] ) ) { |
|
| 1301 | + if (empty($data[0]) || !is_numeric($data[0])) { |
|
| 1302 | 1302 | continue; |
| 1303 | 1303 | } |
| 1304 | 1304 | |
| 1305 | 1305 | $quantity = 1; |
| 1306 | - if ( isset( $data[1] ) && is_numeric( $data[1] ) ) { |
|
| 1306 | + if (isset($data[1]) && is_numeric($data[1])) { |
|
| 1307 | 1307 | $quantity = (float) $data[1]; |
| 1308 | 1308 | } |
| 1309 | 1309 | |
| 1310 | 1310 | // WPML support. |
| 1311 | - $item_id = apply_filters( 'wpml_object_id', $data[0], 'wpi_item', true ); |
|
| 1312 | - $prepared[ $item_id ] = $quantity; |
|
| 1311 | + $item_id = apply_filters('wpml_object_id', $data[0], 'wpi_item', true); |
|
| 1312 | + $prepared[$item_id] = $quantity; |
|
| 1313 | 1313 | |
| 1314 | 1314 | } |
| 1315 | 1315 | |
@@ -1319,13 +1319,13 @@ discard block |
||
| 1319 | 1319 | /** |
| 1320 | 1320 | * Helper function to convert item array to string. |
| 1321 | 1321 | */ |
| 1322 | -function getpaid_convert_items_to_string( $items ) { |
|
| 1322 | +function getpaid_convert_items_to_string($items) { |
|
| 1323 | 1323 | $prepared = array(); |
| 1324 | 1324 | |
| 1325 | - foreach ( $items as $item => $quantity ) { |
|
| 1325 | + foreach ($items as $item => $quantity) { |
|
| 1326 | 1326 | $prepared[] = "$item|$quantity"; |
| 1327 | 1327 | } |
| 1328 | - return implode( ',', $prepared ); |
|
| 1328 | + return implode(',', $prepared); |
|
| 1329 | 1329 | } |
| 1330 | 1330 | |
| 1331 | 1331 | /** |
@@ -1333,21 +1333,21 @@ discard block |
||
| 1333 | 1333 | * |
| 1334 | 1334 | * Provide a label and one of $form, $items or $invoice. |
| 1335 | 1335 | */ |
| 1336 | -function getpaid_get_payment_button( $label, $form = null, $items = null, $invoice = null ) { |
|
| 1337 | - $label = sanitize_text_field( $label ); |
|
| 1336 | +function getpaid_get_payment_button($label, $form = null, $items = null, $invoice = null) { |
|
| 1337 | + $label = sanitize_text_field($label); |
|
| 1338 | 1338 | |
| 1339 | - if ( ! empty( $form ) ) { |
|
| 1340 | - $form = esc_attr( $form ); |
|
| 1339 | + if (!empty($form)) { |
|
| 1340 | + $form = esc_attr($form); |
|
| 1341 | 1341 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-form='$form'>$label</button>"; |
| 1342 | 1342 | } |
| 1343 | 1343 | |
| 1344 | - if ( ! empty( $items ) ) { |
|
| 1345 | - $items = esc_attr( $items ); |
|
| 1344 | + if (!empty($items)) { |
|
| 1345 | + $items = esc_attr($items); |
|
| 1346 | 1346 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-item='$items'>$label</button>"; |
| 1347 | 1347 | } |
| 1348 | 1348 | |
| 1349 | - if ( ! empty( $invoice ) ) { |
|
| 1350 | - $invoice = esc_attr( $invoice ); |
|
| 1349 | + if (!empty($invoice)) { |
|
| 1350 | + $invoice = esc_attr($invoice); |
|
| 1351 | 1351 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-invoice='$invoice'>$label</button>"; |
| 1352 | 1352 | } |
| 1353 | 1353 | |
@@ -1358,17 +1358,17 @@ discard block |
||
| 1358 | 1358 | * |
| 1359 | 1359 | * @param WPInv_Invoice $invoice |
| 1360 | 1360 | */ |
| 1361 | -function getpaid_the_invoice_description( $invoice ) { |
|
| 1361 | +function getpaid_the_invoice_description($invoice) { |
|
| 1362 | 1362 | $description = $invoice->get_description(); |
| 1363 | 1363 | |
| 1364 | - if ( empty( $description ) ) { |
|
| 1364 | + if (empty($description)) { |
|
| 1365 | 1365 | return; |
| 1366 | 1366 | } |
| 1367 | 1367 | |
| 1368 | - echo "<small class='getpaid-invoice-description text-dark p-2 form-text' style='margin-bottom: 20px; border-left: 2px solid #2196F3;'><em>" . wp_kses_post( wpautop( $description ) ) . "</em></small>"; |
|
| 1368 | + echo "<small class='getpaid-invoice-description text-dark p-2 form-text' style='margin-bottom: 20px; border-left: 2px solid #2196F3;'><em>" . wp_kses_post(wpautop($description)) . "</em></small>"; |
|
| 1369 | 1369 | } |
| 1370 | -add_action( 'getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100 ); |
|
| 1371 | -add_action( 'wpinv_email_billing_details', 'getpaid_the_invoice_description', 100 ); |
|
| 1370 | +add_action('getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100); |
|
| 1371 | +add_action('wpinv_email_billing_details', 'getpaid_the_invoice_description', 100); |
|
| 1372 | 1372 | |
| 1373 | 1373 | /** |
| 1374 | 1374 | * Render element on a form. |
@@ -1376,79 +1376,79 @@ discard block |
||
| 1376 | 1376 | * @param array $element |
| 1377 | 1377 | * @param GetPaid_Payment_Form $form |
| 1378 | 1378 | */ |
| 1379 | -function getpaid_payment_form_element( $element, $form ) { |
|
| 1379 | +function getpaid_payment_form_element($element, $form) { |
|
| 1380 | 1380 | |
| 1381 | 1381 | // Set up the args. |
| 1382 | - $element_type = trim( $element['type'] ); |
|
| 1382 | + $element_type = trim($element['type']); |
|
| 1383 | 1383 | $element['form'] = $form; |
| 1384 | - extract( $element ); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract |
|
| 1384 | + extract($element); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract |
|
| 1385 | 1385 | |
| 1386 | 1386 | // Try to locate the appropriate template. |
| 1387 | - $located = wpinv_locate_template( "payment-forms/elements/$element_type.php" ); |
|
| 1387 | + $located = wpinv_locate_template("payment-forms/elements/$element_type.php"); |
|
| 1388 | 1388 | |
| 1389 | 1389 | // Abort if this is not our element. |
| 1390 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
| 1390 | + if (empty($located) || !file_exists($located)) { |
|
| 1391 | 1391 | return; |
| 1392 | 1392 | } |
| 1393 | 1393 | |
| 1394 | 1394 | // Generate the class and id of the element. |
| 1395 | - $wrapper_class = 'getpaid-payment-form-element-' . trim( esc_attr( $element_type ) ); |
|
| 1396 | - $id = isset( $id ) ? $id : uniqid( 'gp' ); |
|
| 1395 | + $wrapper_class = 'getpaid-payment-form-element-' . trim(esc_attr($element_type)); |
|
| 1396 | + $id = isset($id) ? $id : uniqid('gp'); |
|
| 1397 | 1397 | |
| 1398 | - $element_id = ! empty( $element['label'] ) ? sanitize_title( $element['label'] ) : $id; |
|
| 1399 | - $query_value = isset( $_GET[ $element_id ] ) ? wpinv_clean( urldecode_deep( $_GET[ $element_id ] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 1398 | + $element_id = !empty($element['label']) ? sanitize_title($element['label']) : $id; |
|
| 1399 | + $query_value = isset($_GET[$element_id]) ? wpinv_clean(urldecode_deep($_GET[$element_id])) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 1400 | 1400 | |
| 1401 | 1401 | $element_id = 'getpaid-' . $element_id; |
| 1402 | - if ( ! empty( $GLOBALS['rendered_getpaid_forms'][ $form->get_id() ] ) ) { |
|
| 1403 | - $element_id = $element_id . '-' . $GLOBALS['rendered_getpaid_forms'][ $form->get_id() ]; |
|
| 1402 | + if (!empty($GLOBALS['rendered_getpaid_forms'][$form->get_id()])) { |
|
| 1403 | + $element_id = $element_id . '-' . $GLOBALS['rendered_getpaid_forms'][$form->get_id()]; |
|
| 1404 | 1404 | } |
| 1405 | 1405 | |
| 1406 | 1406 | // Echo the opening wrapper. |
| 1407 | - echo "<div class='getpaid-payment-form-element " . esc_attr( $wrapper_class ) . "'>"; |
|
| 1407 | + echo "<div class='getpaid-payment-form-element " . esc_attr($wrapper_class) . "'>"; |
|
| 1408 | 1408 | |
| 1409 | 1409 | // Fires before displaying a given element type's content. |
| 1410 | - do_action( "getpaid_before_payment_form_{$element_type}_element", $element, $form ); |
|
| 1410 | + do_action("getpaid_before_payment_form_{$element_type}_element", $element, $form); |
|
| 1411 | 1411 | |
| 1412 | 1412 | // Include the template for the element. |
| 1413 | 1413 | include $located; |
| 1414 | 1414 | |
| 1415 | 1415 | // Fires after displaying a given element type's content. |
| 1416 | - do_action( "getpaid_payment_form_{$element_type}_element", $element, $form ); |
|
| 1416 | + do_action("getpaid_payment_form_{$element_type}_element", $element, $form); |
|
| 1417 | 1417 | |
| 1418 | 1418 | // Echo the closing wrapper. |
| 1419 | 1419 | echo '</div>'; |
| 1420 | 1420 | } |
| 1421 | -add_action( 'getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2 ); |
|
| 1421 | +add_action('getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2); |
|
| 1422 | 1422 | |
| 1423 | 1423 | /** |
| 1424 | 1424 | * Render an element's edit page. |
| 1425 | 1425 | * |
| 1426 | 1426 | * @param WP_Post $post |
| 1427 | 1427 | */ |
| 1428 | -function getpaid_payment_form_edit_element_template( $post ) { |
|
| 1428 | +function getpaid_payment_form_edit_element_template($post) { |
|
| 1429 | 1429 | |
| 1430 | 1430 | // Retrieve all elements. |
| 1431 | - $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' ); |
|
| 1431 | + $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type'); |
|
| 1432 | 1432 | |
| 1433 | - foreach ( $all_elements as $element ) { |
|
| 1433 | + foreach ($all_elements as $element) { |
|
| 1434 | 1434 | |
| 1435 | 1435 | // Try to locate the appropriate template. |
| 1436 | - $element = esc_attr( sanitize_key( $element ) ); |
|
| 1437 | - $located = wpinv_locate_template( "payment-forms-admin/edit/$element.php" ); |
|
| 1436 | + $element = esc_attr(sanitize_key($element)); |
|
| 1437 | + $located = wpinv_locate_template("payment-forms-admin/edit/$element.php"); |
|
| 1438 | 1438 | |
| 1439 | 1439 | // Continue if this is not our element. |
| 1440 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
| 1440 | + if (empty($located) || !file_exists($located)) { |
|
| 1441 | 1441 | continue; |
| 1442 | 1442 | } |
| 1443 | 1443 | |
| 1444 | 1444 | // Include the template for the element. |
| 1445 | - echo "<div v-if=\"active_form_element.type=='" . esc_attr( $element ) . "'\">"; |
|
| 1445 | + echo "<div v-if=\"active_form_element.type=='" . esc_attr($element) . "'\">"; |
|
| 1446 | 1446 | include $located; |
| 1447 | 1447 | echo '</div>'; |
| 1448 | 1448 | } |
| 1449 | 1449 | |
| 1450 | 1450 | } |
| 1451 | -add_action( 'getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template' ); |
|
| 1451 | +add_action('getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template'); |
|
| 1452 | 1452 | |
| 1453 | 1453 | /** |
| 1454 | 1454 | * Render an element's preview. |
@@ -1457,27 +1457,27 @@ discard block |
||
| 1457 | 1457 | function getpaid_payment_form_render_element_preview_template() { |
| 1458 | 1458 | |
| 1459 | 1459 | // Retrieve all elements. |
| 1460 | - $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' ); |
|
| 1460 | + $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type'); |
|
| 1461 | 1461 | |
| 1462 | - foreach ( $all_elements as $element ) { |
|
| 1462 | + foreach ($all_elements as $element) { |
|
| 1463 | 1463 | |
| 1464 | 1464 | // Try to locate the appropriate template. |
| 1465 | - $element = sanitize_key( $element ); |
|
| 1466 | - $located = wpinv_locate_template( "payment-forms-admin/previews/$element.php" ); |
|
| 1465 | + $element = sanitize_key($element); |
|
| 1466 | + $located = wpinv_locate_template("payment-forms-admin/previews/$element.php"); |
|
| 1467 | 1467 | |
| 1468 | 1468 | // Continue if this is not our element. |
| 1469 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
| 1469 | + if (empty($located) || !file_exists($located)) { |
|
| 1470 | 1470 | continue; |
| 1471 | 1471 | } |
| 1472 | 1472 | |
| 1473 | 1473 | // Include the template for the element. |
| 1474 | - echo "<div v-if=\"form_element.type=='" . esc_html( $element ) . "'\">"; |
|
| 1474 | + echo "<div v-if=\"form_element.type=='" . esc_html($element) . "'\">"; |
|
| 1475 | 1475 | include $located; |
| 1476 | 1476 | echo '</div>'; |
| 1477 | 1477 | } |
| 1478 | 1478 | |
| 1479 | 1479 | } |
| 1480 | -add_action( 'wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template' ); |
|
| 1480 | +add_action('wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template'); |
|
| 1481 | 1481 | |
| 1482 | 1482 | /** |
| 1483 | 1483 | * Shows a list of gateways that support recurring payments. |
@@ -1485,17 +1485,17 @@ discard block |
||
| 1485 | 1485 | function wpinv_get_recurring_gateways_text() { |
| 1486 | 1486 | $gateways = array(); |
| 1487 | 1487 | |
| 1488 | - foreach ( wpinv_get_payment_gateways() as $key => $gateway ) { |
|
| 1489 | - if ( wpinv_gateway_support_subscription( $key ) ) { |
|
| 1490 | - $gateways[] = sanitize_text_field( $gateway['admin_label'] ); |
|
| 1488 | + foreach (wpinv_get_payment_gateways() as $key => $gateway) { |
|
| 1489 | + if (wpinv_gateway_support_subscription($key)) { |
|
| 1490 | + $gateways[] = sanitize_text_field($gateway['admin_label']); |
|
| 1491 | 1491 | } |
| 1492 | 1492 | } |
| 1493 | 1493 | |
| 1494 | - if ( empty( $gateways ) ) { |
|
| 1495 | - return "<span class='form-text text-danger'>" . __( 'No active gateways support subscription payments.', 'invoicing' ) . '</span>'; |
|
| 1494 | + if (empty($gateways)) { |
|
| 1495 | + return "<span class='form-text text-danger'>" . __('No active gateways support subscription payments.', 'invoicing') . '</span>'; |
|
| 1496 | 1496 | } |
| 1497 | 1497 | |
| 1498 | - return "<span class='form-text text-muted'>" . wp_sprintf( __( 'Subscription payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ) . '</span>'; |
|
| 1498 | + return "<span class='form-text text-muted'>" . wp_sprintf(__('Subscription payments only supported by: %s', 'invoicing'), implode(', ', $gateways)) . '</span>'; |
|
| 1499 | 1499 | |
| 1500 | 1500 | } |
| 1501 | 1501 | |
@@ -1505,7 +1505,7 @@ discard block |
||
| 1505 | 1505 | * @return GetPaid_Template |
| 1506 | 1506 | */ |
| 1507 | 1507 | function getpaid_template() { |
| 1508 | - return getpaid()->get( 'template' ); |
|
| 1508 | + return getpaid()->get('template'); |
|
| 1509 | 1509 | } |
| 1510 | 1510 | |
| 1511 | 1511 | /** |
@@ -1514,8 +1514,8 @@ discard block |
||
| 1514 | 1514 | * @param array args |
| 1515 | 1515 | * @return string |
| 1516 | 1516 | */ |
| 1517 | -function getpaid_paginate_links( $args ) { |
|
| 1518 | - return str_replace( 'page-link dots', 'page-link text-dark', aui()->pagination( $args ) ); |
|
| 1517 | +function getpaid_paginate_links($args) { |
|
| 1518 | + return str_replace('page-link dots', 'page-link text-dark', aui()->pagination($args)); |
|
| 1519 | 1519 | } |
| 1520 | 1520 | |
| 1521 | 1521 | /** |
@@ -1525,22 +1525,22 @@ discard block |
||
| 1525 | 1525 | * @param string state |
| 1526 | 1526 | * @return string |
| 1527 | 1527 | */ |
| 1528 | -function getpaid_get_states_select_markup( $country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12', $field_name = 'wpinv_state', $echo = false ) { |
|
| 1528 | +function getpaid_get_states_select_markup($country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12', $field_name = 'wpinv_state', $echo = false) { |
|
| 1529 | 1529 | |
| 1530 | - $states = wpinv_get_country_states( $country ); |
|
| 1531 | - $uniqid = uniqid( '_' ); |
|
| 1530 | + $states = wpinv_get_country_states($country); |
|
| 1531 | + $uniqid = uniqid('_'); |
|
| 1532 | 1532 | |
| 1533 | - if ( ! empty( $states ) ) { |
|
| 1533 | + if (!empty($states)) { |
|
| 1534 | 1534 | |
| 1535 | 1535 | return aui()->select( |
| 1536 | 1536 | array( |
| 1537 | 1537 | 'options' => $states, |
| 1538 | - 'name' => esc_attr( $field_name ), |
|
| 1539 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
| 1540 | - 'value' => sanitize_text_field( $state ), |
|
| 1538 | + 'name' => esc_attr($field_name), |
|
| 1539 | + 'id' => sanitize_html_class($field_name) . $uniqid, |
|
| 1540 | + 'value' => sanitize_text_field($state), |
|
| 1541 | 1541 | 'placeholder' => $placeholder, |
| 1542 | 1542 | 'required' => $required, |
| 1543 | - 'label' => wp_kses_post( $label ), |
|
| 1543 | + 'label' => wp_kses_post($label), |
|
| 1544 | 1544 | 'label_type' => 'vertical', |
| 1545 | 1545 | 'help_text' => $help_text, |
| 1546 | 1546 | 'class' => 'getpaid-address-field wpinv_state', |
@@ -1557,14 +1557,14 @@ discard block |
||
| 1557 | 1557 | |
| 1558 | 1558 | return aui()->input( |
| 1559 | 1559 | array( |
| 1560 | - 'name' => esc_attr( $field_name ), |
|
| 1561 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
| 1560 | + 'name' => esc_attr($field_name), |
|
| 1561 | + 'id' => sanitize_html_class($field_name) . $uniqid, |
|
| 1562 | 1562 | 'placeholder' => $placeholder, |
| 1563 | 1563 | 'required' => $required, |
| 1564 | - 'label' => wp_kses_post( $label ), |
|
| 1564 | + 'label' => wp_kses_post($label), |
|
| 1565 | 1565 | 'label_type' => 'vertical', |
| 1566 | 1566 | 'help_text' => $help_text, |
| 1567 | - 'value' => sanitize_text_field( $state ), |
|
| 1567 | + 'value' => sanitize_text_field($state), |
|
| 1568 | 1568 | 'class' => 'getpaid-address-field wpinv_state', |
| 1569 | 1569 | 'wrap_class' => "$wrapper_class getpaid-address-field-wrapper__state", |
| 1570 | 1570 | 'label_class' => 'getpaid-address-field-label getpaid-address-field-label__state', |
@@ -1583,16 +1583,16 @@ discard block |
||
| 1583 | 1583 | * @param array $element |
| 1584 | 1584 | * @return string |
| 1585 | 1585 | */ |
| 1586 | -function getpaid_get_form_element_grid_class( $element ) { |
|
| 1586 | +function getpaid_get_form_element_grid_class($element) { |
|
| 1587 | 1587 | |
| 1588 | 1588 | $class = 'col-12'; |
| 1589 | - $width = empty( $element['grid_width'] ) ? 'full' : $element['grid_width']; |
|
| 1589 | + $width = empty($element['grid_width']) ? 'full' : $element['grid_width']; |
|
| 1590 | 1590 | |
| 1591 | - if ( $width == 'half' ) { |
|
| 1591 | + if ($width == 'half') { |
|
| 1592 | 1592 | $class .= ' col-md-6'; |
| 1593 | 1593 | } |
| 1594 | 1594 | |
| 1595 | - if ( $width == 'third' ) { |
|
| 1595 | + if ($width == 'third') { |
|
| 1596 | 1596 | $class .= ' col-md-4'; |
| 1597 | 1597 | } |
| 1598 | 1598 | |
@@ -1607,15 +1607,15 @@ discard block |
||
| 1607 | 1607 | * |
| 1608 | 1608 | * @return string |
| 1609 | 1609 | */ |
| 1610 | -function getpaid_embed_url( $payment_form = false, $items = false ) { |
|
| 1610 | +function getpaid_embed_url($payment_form = false, $items = false) { |
|
| 1611 | 1611 | |
| 1612 | 1612 | return add_query_arg( |
| 1613 | 1613 | array( |
| 1614 | 1614 | 'getpaid_embed' => 1, |
| 1615 | - 'form' => $payment_form ? absint( $payment_form ) : false, |
|
| 1616 | - 'item' => $items ? urlencode( $items ) : false, |
|
| 1615 | + 'form' => $payment_form ? absint($payment_form) : false, |
|
| 1616 | + 'item' => $items ? urlencode($items) : false, |
|
| 1617 | 1617 | ), |
| 1618 | - home_url( 'index.php' ) |
|
| 1618 | + home_url('index.php') |
|
| 1619 | 1619 | ); |
| 1620 | 1620 | |
| 1621 | 1621 | } |
@@ -1625,13 +1625,13 @@ discard block |
||
| 1625 | 1625 | * |
| 1626 | 1626 | * @return string |
| 1627 | 1627 | */ |
| 1628 | -function getpaid_filter_embed_template( $template ) { |
|
| 1628 | +function getpaid_filter_embed_template($template) { |
|
| 1629 | 1629 | |
| 1630 | - if ( isset( $_GET['getpaid_embed'] ) ) { |
|
| 1631 | - wpinv_get_template( 'payment-forms/embed.php' ); |
|
| 1630 | + if (isset($_GET['getpaid_embed'])) { |
|
| 1631 | + wpinv_get_template('payment-forms/embed.php'); |
|
| 1632 | 1632 | exit; |
| 1633 | 1633 | } |
| 1634 | 1634 | |
| 1635 | 1635 | return $template; |
| 1636 | 1636 | } |
| 1637 | -add_filter( 'template_include', 'getpaid_filter_embed_template' ); |
|
| 1637 | +add_filter('template_include', 'getpaid_filter_embed_template'); |
|
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | * Bail if we are not in WP. |
| 14 | 14 | */ |
| 15 | 15 | if ( ! defined( 'ABSPATH' ) ) { |
| 16 | - exit; |
|
| 16 | + exit; |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | /** |
@@ -21,422 +21,422 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | if ( ! class_exists( 'AyeCode_UI_Settings' ) ) { |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * A Class to be able to change settings for Font Awesome. |
|
| 26 | - * |
|
| 27 | - * Class AyeCode_UI_Settings |
|
| 28 | - * @ver 1.0.0 |
|
| 29 | - * @todo decide how to implement textdomain |
|
| 30 | - */ |
|
| 31 | - class AyeCode_UI_Settings { |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * Class version version. |
|
| 35 | - * |
|
| 36 | - * @var string |
|
| 37 | - */ |
|
| 38 | - public $version = '0.1.77'; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * Class textdomain. |
|
| 42 | - * |
|
| 43 | - * @var string |
|
| 44 | - */ |
|
| 45 | - public $textdomain = 'aui'; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * Latest version of Bootstrap at time of publish published. |
|
| 49 | - * |
|
| 50 | - * @var string |
|
| 51 | - */ |
|
| 52 | - public $latest = "4.5.3"; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * Current version of select2 being used. |
|
| 56 | - * |
|
| 57 | - * @var string |
|
| 58 | - */ |
|
| 59 | - public $select2_version = "4.0.11"; |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * The title. |
|
| 63 | - * |
|
| 64 | - * @var string |
|
| 65 | - */ |
|
| 66 | - public $name = 'AyeCode UI'; |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * The relative url to the assets. |
|
| 70 | - * |
|
| 71 | - * @var string |
|
| 72 | - */ |
|
| 73 | - public $url = ''; |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * Holds the settings values. |
|
| 77 | - * |
|
| 78 | - * @var array |
|
| 79 | - */ |
|
| 80 | - private $settings; |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * AyeCode_UI_Settings instance. |
|
| 84 | - * |
|
| 85 | - * @access private |
|
| 86 | - * @since 1.0.0 |
|
| 87 | - * @var AyeCode_UI_Settings There can be only one! |
|
| 88 | - */ |
|
| 89 | - private static $instance = null; |
|
| 90 | - |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * Main AyeCode_UI_Settings Instance. |
|
| 94 | - * |
|
| 95 | - * Ensures only one instance of AyeCode_UI_Settings is loaded or can be loaded. |
|
| 96 | - * |
|
| 97 | - * @since 1.0.0 |
|
| 98 | - * @static |
|
| 99 | - * @return AyeCode_UI_Settings - Main instance. |
|
| 100 | - */ |
|
| 101 | - public static function instance() { |
|
| 102 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) { |
|
| 103 | - |
|
| 104 | - self::$instance = new AyeCode_UI_Settings; |
|
| 105 | - |
|
| 106 | - add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
| 107 | - |
|
| 108 | - if ( is_admin() ) { |
|
| 109 | - add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
|
| 110 | - add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
|
| 111 | - |
|
| 112 | - // Maybe show example page |
|
| 113 | - add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) ); |
|
| 114 | - |
|
| 115 | - if ( defined( 'BLOCKSTRAP_VERSION' ) ) { |
|
| 116 | - add_filter( 'sd_aui_colors', array( self::$instance,'sd_aui_colors' ), 10, 3 ); |
|
| 117 | - } |
|
| 118 | - } |
|
| 24 | + /** |
|
| 25 | + * A Class to be able to change settings for Font Awesome. |
|
| 26 | + * |
|
| 27 | + * Class AyeCode_UI_Settings |
|
| 28 | + * @ver 1.0.0 |
|
| 29 | + * @todo decide how to implement textdomain |
|
| 30 | + */ |
|
| 31 | + class AyeCode_UI_Settings { |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * Class version version. |
|
| 35 | + * |
|
| 36 | + * @var string |
|
| 37 | + */ |
|
| 38 | + public $version = '0.1.77'; |
|
| 119 | 39 | |
| 120 | - add_action( 'customize_register', array( self::$instance, 'customizer_settings' )); |
|
| 40 | + /** |
|
| 41 | + * Class textdomain. |
|
| 42 | + * |
|
| 43 | + * @var string |
|
| 44 | + */ |
|
| 45 | + public $textdomain = 'aui'; |
|
| 121 | 46 | |
| 122 | - do_action( 'ayecode_ui_settings_loaded' ); |
|
| 123 | - } |
|
| 47 | + /** |
|
| 48 | + * Latest version of Bootstrap at time of publish published. |
|
| 49 | + * |
|
| 50 | + * @var string |
|
| 51 | + */ |
|
| 52 | + public $latest = "4.5.3"; |
|
| 124 | 53 | |
| 125 | - return self::$instance; |
|
| 126 | - } |
|
| 54 | + /** |
|
| 55 | + * Current version of select2 being used. |
|
| 56 | + * |
|
| 57 | + * @var string |
|
| 58 | + */ |
|
| 59 | + public $select2_version = "4.0.11"; |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * The title. |
|
| 63 | + * |
|
| 64 | + * @var string |
|
| 65 | + */ |
|
| 66 | + public $name = 'AyeCode UI'; |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * The relative url to the assets. |
|
| 70 | + * |
|
| 71 | + * @var string |
|
| 72 | + */ |
|
| 73 | + public $url = ''; |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * Holds the settings values. |
|
| 77 | + * |
|
| 78 | + * @var array |
|
| 79 | + */ |
|
| 80 | + private $settings; |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * AyeCode_UI_Settings instance. |
|
| 84 | + * |
|
| 85 | + * @access private |
|
| 86 | + * @since 1.0.0 |
|
| 87 | + * @var AyeCode_UI_Settings There can be only one! |
|
| 88 | + */ |
|
| 89 | + private static $instance = null; |
|
| 90 | + |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * Main AyeCode_UI_Settings Instance. |
|
| 94 | + * |
|
| 95 | + * Ensures only one instance of AyeCode_UI_Settings is loaded or can be loaded. |
|
| 96 | + * |
|
| 97 | + * @since 1.0.0 |
|
| 98 | + * @static |
|
| 99 | + * @return AyeCode_UI_Settings - Main instance. |
|
| 100 | + */ |
|
| 101 | + public static function instance() { |
|
| 102 | + if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) { |
|
| 103 | + |
|
| 104 | + self::$instance = new AyeCode_UI_Settings; |
|
| 105 | + |
|
| 106 | + add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
| 107 | + |
|
| 108 | + if ( is_admin() ) { |
|
| 109 | + add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
|
| 110 | + add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
|
| 127 | 111 | |
| 128 | - /** |
|
| 112 | + // Maybe show example page |
|
| 113 | + add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) ); |
|
| 114 | + |
|
| 115 | + if ( defined( 'BLOCKSTRAP_VERSION' ) ) { |
|
| 116 | + add_filter( 'sd_aui_colors', array( self::$instance,'sd_aui_colors' ), 10, 3 ); |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + add_action( 'customize_register', array( self::$instance, 'customizer_settings' )); |
|
| 121 | + |
|
| 122 | + do_action( 'ayecode_ui_settings_loaded' ); |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + return self::$instance; |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + /** |
|
| 129 | 129 | * Add custom colors to the color selector. |
| 130 | 130 | * |
| 131 | - * @param $theme_colors |
|
| 132 | - * @param $include_outlines |
|
| 133 | - * @param $include_branding |
|
| 134 | - * |
|
| 135 | - * @return mixed |
|
| 136 | - */ |
|
| 137 | - public function sd_aui_colors( $theme_colors, $include_outlines, $include_branding ){ |
|
| 131 | + * @param $theme_colors |
|
| 132 | + * @param $include_outlines |
|
| 133 | + * @param $include_branding |
|
| 134 | + * |
|
| 135 | + * @return mixed |
|
| 136 | + */ |
|
| 137 | + public function sd_aui_colors( $theme_colors, $include_outlines, $include_branding ){ |
|
| 138 | 138 | |
| 139 | 139 | |
| 140 | - $setting = wp_get_global_settings(); |
|
| 140 | + $setting = wp_get_global_settings(); |
|
| 141 | 141 | |
| 142 | - if(!empty($setting['color']['palette']['custom'])){ |
|
| 143 | - foreach($setting['color']['palette']['custom'] as $color){ |
|
| 144 | - $theme_colors[$color['slug']] = esc_attr($color['name']); |
|
| 145 | - } |
|
| 146 | - } |
|
| 142 | + if(!empty($setting['color']['palette']['custom'])){ |
|
| 143 | + foreach($setting['color']['palette']['custom'] as $color){ |
|
| 144 | + $theme_colors[$color['slug']] = esc_attr($color['name']); |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - return $theme_colors; |
|
| 149 | - } |
|
| 148 | + return $theme_colors; |
|
| 149 | + } |
|
| 150 | 150 | |
| 151 | - /** |
|
| 152 | - * Setup some constants. |
|
| 153 | - */ |
|
| 154 | - public function constants(){ |
|
| 155 | - define( 'AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be" ); |
|
| 156 | - define( 'AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d' ); |
|
| 157 | - define( 'AUI_INFO_COLOR_ORIGINAL', '#17a2b8' ); |
|
| 158 | - define( 'AUI_WARNING_COLOR_ORIGINAL', '#ffc107' ); |
|
| 159 | - define( 'AUI_DANGER_COLOR_ORIGINAL', '#dc3545' ); |
|
| 160 | - define( 'AUI_SUCCESS_COLOR_ORIGINAL', '#44c553' ); |
|
| 161 | - define( 'AUI_LIGHT_COLOR_ORIGINAL', '#f8f9fa' ); |
|
| 162 | - define( 'AUI_DARK_COLOR_ORIGINAL', '#343a40' ); |
|
| 163 | - define( 'AUI_WHITE_COLOR_ORIGINAL', '#fff' ); |
|
| 164 | - define( 'AUI_PURPLE_COLOR_ORIGINAL', '#ad6edd' ); |
|
| 165 | - define( 'AUI_SALMON_COLOR_ORIGINAL', '#ff977a' ); |
|
| 166 | - define( 'AUI_CYAN_COLOR_ORIGINAL', '#35bdff' ); |
|
| 167 | - define( 'AUI_GRAY_COLOR_ORIGINAL', '#ced4da' ); |
|
| 168 | - define( 'AUI_INDIGO_COLOR_ORIGINAL', '#502c6c' ); |
|
| 169 | - define( 'AUI_ORANGE_COLOR_ORIGINAL', '#orange' ); |
|
| 170 | - define( 'AUI_BLACK_COLOR_ORIGINAL', '#000' ); |
|
| 171 | - |
|
| 172 | - if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) { |
|
| 173 | - define( 'AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL ); |
|
| 174 | - } |
|
| 175 | - if ( ! defined( 'AUI_SECONDARY_COLOR' ) ) { |
|
| 176 | - define( 'AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL ); |
|
| 177 | - } |
|
| 178 | - if ( ! defined( 'AUI_INFO_COLOR' ) ) { |
|
| 179 | - define( 'AUI_INFO_COLOR', AUI_INFO_COLOR_ORIGINAL ); |
|
| 180 | - } |
|
| 181 | - if ( ! defined( 'AUI_WARNING_COLOR' ) ) { |
|
| 182 | - define( 'AUI_WARNING_COLOR', AUI_WARNING_COLOR_ORIGINAL ); |
|
| 183 | - } |
|
| 184 | - if ( ! defined( 'AUI_DANGER_COLOR' ) ) { |
|
| 185 | - define( 'AUI_DANGER_COLOR', AUI_DANGER_COLOR_ORIGINAL ); |
|
| 186 | - } |
|
| 187 | - if ( ! defined( 'AUI_SUCCESS_COLOR' ) ) { |
|
| 188 | - define( 'AUI_SUCCESS_COLOR', AUI_SUCCESS_COLOR_ORIGINAL ); |
|
| 189 | - } |
|
| 190 | - if ( ! defined( 'AUI_LIGHT_COLOR' ) ) { |
|
| 191 | - define( 'AUI_LIGHT_COLOR', AUI_LIGHT_COLOR_ORIGINAL ); |
|
| 192 | - } |
|
| 193 | - if ( ! defined( 'AUI_DARK_COLOR' ) ) { |
|
| 194 | - define( 'AUI_DARK_COLOR', AUI_DARK_COLOR_ORIGINAL ); |
|
| 195 | - } |
|
| 196 | - if ( ! defined( 'AUI_WHITE_COLOR' ) ) { |
|
| 197 | - define( 'AUI_WHITE_COLOR', AUI_WHITE_COLOR_ORIGINAL ); |
|
| 198 | - } |
|
| 199 | - if ( ! defined( 'AUI_PURPLE_COLOR' ) ) { |
|
| 200 | - define( 'AUI_PURPLE_COLOR', AUI_PURPLE_COLOR_ORIGINAL ); |
|
| 201 | - } |
|
| 202 | - if ( ! defined( 'AUI_SALMON_COLOR' ) ) { |
|
| 203 | - define( 'AUI_SALMON_COLOR', AUI_SALMON_COLOR_ORIGINAL ); |
|
| 204 | - } |
|
| 205 | - if ( ! defined( 'AUI_CYAN_COLOR' ) ) { |
|
| 206 | - define( 'AUI_CYAN_COLOR', AUI_CYAN_COLOR_ORIGINAL ); |
|
| 207 | - } |
|
| 208 | - if ( ! defined( 'AUI_GRAY_COLOR' ) ) { |
|
| 209 | - define( 'AUI_GRAY_COLOR', AUI_GRAY_COLOR_ORIGINAL ); |
|
| 210 | - } |
|
| 211 | - if ( ! defined( 'AUI_INDIGO_COLOR' ) ) { |
|
| 212 | - define( 'AUI_INDIGO_COLOR', AUI_INDIGO_COLOR_ORIGINAL ); |
|
| 213 | - } |
|
| 214 | - if ( ! defined( 'AUI_ORANGE_COLOR' ) ) { |
|
| 215 | - define( 'AUI_ORANGE_COLOR', AUI_ORANGE_COLOR_ORIGINAL ); |
|
| 216 | - } |
|
| 217 | - if ( ! defined( 'AUI_BLACK_COLOR' ) ) { |
|
| 218 | - define( 'AUI_BLACK_COLOR', AUI_BLACK_COLOR_ORIGINAL ); |
|
| 219 | - } |
|
| 151 | + /** |
|
| 152 | + * Setup some constants. |
|
| 153 | + */ |
|
| 154 | + public function constants(){ |
|
| 155 | + define( 'AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be" ); |
|
| 156 | + define( 'AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d' ); |
|
| 157 | + define( 'AUI_INFO_COLOR_ORIGINAL', '#17a2b8' ); |
|
| 158 | + define( 'AUI_WARNING_COLOR_ORIGINAL', '#ffc107' ); |
|
| 159 | + define( 'AUI_DANGER_COLOR_ORIGINAL', '#dc3545' ); |
|
| 160 | + define( 'AUI_SUCCESS_COLOR_ORIGINAL', '#44c553' ); |
|
| 161 | + define( 'AUI_LIGHT_COLOR_ORIGINAL', '#f8f9fa' ); |
|
| 162 | + define( 'AUI_DARK_COLOR_ORIGINAL', '#343a40' ); |
|
| 163 | + define( 'AUI_WHITE_COLOR_ORIGINAL', '#fff' ); |
|
| 164 | + define( 'AUI_PURPLE_COLOR_ORIGINAL', '#ad6edd' ); |
|
| 165 | + define( 'AUI_SALMON_COLOR_ORIGINAL', '#ff977a' ); |
|
| 166 | + define( 'AUI_CYAN_COLOR_ORIGINAL', '#35bdff' ); |
|
| 167 | + define( 'AUI_GRAY_COLOR_ORIGINAL', '#ced4da' ); |
|
| 168 | + define( 'AUI_INDIGO_COLOR_ORIGINAL', '#502c6c' ); |
|
| 169 | + define( 'AUI_ORANGE_COLOR_ORIGINAL', '#orange' ); |
|
| 170 | + define( 'AUI_BLACK_COLOR_ORIGINAL', '#000' ); |
|
| 171 | + |
|
| 172 | + if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) { |
|
| 173 | + define( 'AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL ); |
|
| 174 | + } |
|
| 175 | + if ( ! defined( 'AUI_SECONDARY_COLOR' ) ) { |
|
| 176 | + define( 'AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL ); |
|
| 177 | + } |
|
| 178 | + if ( ! defined( 'AUI_INFO_COLOR' ) ) { |
|
| 179 | + define( 'AUI_INFO_COLOR', AUI_INFO_COLOR_ORIGINAL ); |
|
| 180 | + } |
|
| 181 | + if ( ! defined( 'AUI_WARNING_COLOR' ) ) { |
|
| 182 | + define( 'AUI_WARNING_COLOR', AUI_WARNING_COLOR_ORIGINAL ); |
|
| 183 | + } |
|
| 184 | + if ( ! defined( 'AUI_DANGER_COLOR' ) ) { |
|
| 185 | + define( 'AUI_DANGER_COLOR', AUI_DANGER_COLOR_ORIGINAL ); |
|
| 186 | + } |
|
| 187 | + if ( ! defined( 'AUI_SUCCESS_COLOR' ) ) { |
|
| 188 | + define( 'AUI_SUCCESS_COLOR', AUI_SUCCESS_COLOR_ORIGINAL ); |
|
| 189 | + } |
|
| 190 | + if ( ! defined( 'AUI_LIGHT_COLOR' ) ) { |
|
| 191 | + define( 'AUI_LIGHT_COLOR', AUI_LIGHT_COLOR_ORIGINAL ); |
|
| 192 | + } |
|
| 193 | + if ( ! defined( 'AUI_DARK_COLOR' ) ) { |
|
| 194 | + define( 'AUI_DARK_COLOR', AUI_DARK_COLOR_ORIGINAL ); |
|
| 195 | + } |
|
| 196 | + if ( ! defined( 'AUI_WHITE_COLOR' ) ) { |
|
| 197 | + define( 'AUI_WHITE_COLOR', AUI_WHITE_COLOR_ORIGINAL ); |
|
| 198 | + } |
|
| 199 | + if ( ! defined( 'AUI_PURPLE_COLOR' ) ) { |
|
| 200 | + define( 'AUI_PURPLE_COLOR', AUI_PURPLE_COLOR_ORIGINAL ); |
|
| 201 | + } |
|
| 202 | + if ( ! defined( 'AUI_SALMON_COLOR' ) ) { |
|
| 203 | + define( 'AUI_SALMON_COLOR', AUI_SALMON_COLOR_ORIGINAL ); |
|
| 204 | + } |
|
| 205 | + if ( ! defined( 'AUI_CYAN_COLOR' ) ) { |
|
| 206 | + define( 'AUI_CYAN_COLOR', AUI_CYAN_COLOR_ORIGINAL ); |
|
| 207 | + } |
|
| 208 | + if ( ! defined( 'AUI_GRAY_COLOR' ) ) { |
|
| 209 | + define( 'AUI_GRAY_COLOR', AUI_GRAY_COLOR_ORIGINAL ); |
|
| 210 | + } |
|
| 211 | + if ( ! defined( 'AUI_INDIGO_COLOR' ) ) { |
|
| 212 | + define( 'AUI_INDIGO_COLOR', AUI_INDIGO_COLOR_ORIGINAL ); |
|
| 213 | + } |
|
| 214 | + if ( ! defined( 'AUI_ORANGE_COLOR' ) ) { |
|
| 215 | + define( 'AUI_ORANGE_COLOR', AUI_ORANGE_COLOR_ORIGINAL ); |
|
| 216 | + } |
|
| 217 | + if ( ! defined( 'AUI_BLACK_COLOR' ) ) { |
|
| 218 | + define( 'AUI_BLACK_COLOR', AUI_BLACK_COLOR_ORIGINAL ); |
|
| 219 | + } |
|
| 220 | 220 | |
| 221 | - } |
|
| 221 | + } |
|
| 222 | 222 | |
| 223 | 223 | public static function get_colors( $original = false){ |
| 224 | 224 | |
| 225 | - if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) { |
|
| 225 | + if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) { |
|
| 226 | 226 | return array(); |
| 227 | - } |
|
| 228 | - if ( $original ) { |
|
| 227 | + } |
|
| 228 | + if ( $original ) { |
|
| 229 | 229 | return array( |
| 230 | - 'primary' => AUI_PRIMARY_COLOR_ORIGINAL, |
|
| 231 | - 'secondary' => AUI_SECONDARY_COLOR_ORIGINAL, |
|
| 232 | - 'info' => AUI_INFO_COLOR_ORIGINAL, |
|
| 233 | - 'warning' => AUI_WARNING_COLOR_ORIGINAL, |
|
| 234 | - 'danger' => AUI_DANGER_COLOR_ORIGINAL, |
|
| 235 | - 'success' => AUI_SUCCESS_COLOR_ORIGINAL, |
|
| 236 | - 'light' => AUI_LIGHT_COLOR_ORIGINAL, |
|
| 237 | - 'dark' => AUI_DARK_COLOR_ORIGINAL, |
|
| 238 | - 'white' => AUI_WHITE_COLOR_ORIGINAL, |
|
| 239 | - 'purple' => AUI_PURPLE_COLOR_ORIGINAL, |
|
| 240 | - 'salmon' => AUI_SALMON_COLOR_ORIGINAL, |
|
| 241 | - 'cyan' => AUI_CYAN_COLOR_ORIGINAL, |
|
| 242 | - 'gray' => AUI_GRAY_COLOR_ORIGINAL, |
|
| 243 | - 'indigo' => AUI_INDIGO_COLOR_ORIGINAL, |
|
| 244 | - 'orange' => AUI_ORANGE_COLOR_ORIGINAL, |
|
| 245 | - 'black' => AUI_BLACK_COLOR_ORIGINAL, |
|
| 230 | + 'primary' => AUI_PRIMARY_COLOR_ORIGINAL, |
|
| 231 | + 'secondary' => AUI_SECONDARY_COLOR_ORIGINAL, |
|
| 232 | + 'info' => AUI_INFO_COLOR_ORIGINAL, |
|
| 233 | + 'warning' => AUI_WARNING_COLOR_ORIGINAL, |
|
| 234 | + 'danger' => AUI_DANGER_COLOR_ORIGINAL, |
|
| 235 | + 'success' => AUI_SUCCESS_COLOR_ORIGINAL, |
|
| 236 | + 'light' => AUI_LIGHT_COLOR_ORIGINAL, |
|
| 237 | + 'dark' => AUI_DARK_COLOR_ORIGINAL, |
|
| 238 | + 'white' => AUI_WHITE_COLOR_ORIGINAL, |
|
| 239 | + 'purple' => AUI_PURPLE_COLOR_ORIGINAL, |
|
| 240 | + 'salmon' => AUI_SALMON_COLOR_ORIGINAL, |
|
| 241 | + 'cyan' => AUI_CYAN_COLOR_ORIGINAL, |
|
| 242 | + 'gray' => AUI_GRAY_COLOR_ORIGINAL, |
|
| 243 | + 'indigo' => AUI_INDIGO_COLOR_ORIGINAL, |
|
| 244 | + 'orange' => AUI_ORANGE_COLOR_ORIGINAL, |
|
| 245 | + 'black' => AUI_BLACK_COLOR_ORIGINAL, |
|
| 246 | 246 | ); |
| 247 | - } |
|
| 247 | + } |
|
| 248 | 248 | |
| 249 | 249 | return array( |
| 250 | - 'primary' => AUI_PRIMARY_COLOR, |
|
| 251 | - 'secondary' => AUI_SECONDARY_COLOR, |
|
| 252 | - 'info' => AUI_INFO_COLOR, |
|
| 253 | - 'warning' => AUI_WARNING_COLOR, |
|
| 254 | - 'danger' => AUI_DANGER_COLOR, |
|
| 255 | - 'success' => AUI_SUCCESS_COLOR, |
|
| 256 | - 'light' => AUI_LIGHT_COLOR, |
|
| 257 | - 'dark' => AUI_DARK_COLOR, |
|
| 258 | - 'white' => AUI_WHITE_COLOR, |
|
| 259 | - 'purple' => AUI_PURPLE_COLOR, |
|
| 260 | - 'salmon' => AUI_SALMON_COLOR, |
|
| 261 | - 'cyan' => AUI_CYAN_COLOR, |
|
| 262 | - 'gray' => AUI_GRAY_COLOR, |
|
| 263 | - 'indigo' => AUI_INDIGO_COLOR, |
|
| 264 | - 'orange' => AUI_ORANGE_COLOR, |
|
| 265 | - 'black' => AUI_BLACK_COLOR, |
|
| 250 | + 'primary' => AUI_PRIMARY_COLOR, |
|
| 251 | + 'secondary' => AUI_SECONDARY_COLOR, |
|
| 252 | + 'info' => AUI_INFO_COLOR, |
|
| 253 | + 'warning' => AUI_WARNING_COLOR, |
|
| 254 | + 'danger' => AUI_DANGER_COLOR, |
|
| 255 | + 'success' => AUI_SUCCESS_COLOR, |
|
| 256 | + 'light' => AUI_LIGHT_COLOR, |
|
| 257 | + 'dark' => AUI_DARK_COLOR, |
|
| 258 | + 'white' => AUI_WHITE_COLOR, |
|
| 259 | + 'purple' => AUI_PURPLE_COLOR, |
|
| 260 | + 'salmon' => AUI_SALMON_COLOR, |
|
| 261 | + 'cyan' => AUI_CYAN_COLOR, |
|
| 262 | + 'gray' => AUI_GRAY_COLOR, |
|
| 263 | + 'indigo' => AUI_INDIGO_COLOR, |
|
| 264 | + 'orange' => AUI_ORANGE_COLOR, |
|
| 265 | + 'black' => AUI_BLACK_COLOR, |
|
| 266 | 266 | ); |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - /** |
|
| 270 | - * Initiate the settings and add the required action hooks. |
|
| 271 | - */ |
|
| 272 | - public function init() { |
|
| 273 | - |
|
| 274 | - // Maybe fix settings |
|
| 275 | - if ( ! empty( $_REQUEST['aui-fix-admin'] ) && !empty($_REQUEST['nonce']) && wp_verify_nonce( $_REQUEST['nonce'], "aui-fix-admin" ) ) { |
|
| 276 | - $db_settings = get_option( 'ayecode-ui-settings' ); |
|
| 277 | - if ( ! empty( $db_settings ) ) { |
|
| 278 | - $db_settings['css_backend'] = 'compatibility'; |
|
| 279 | - $db_settings['js_backend'] = 'core-popper'; |
|
| 280 | - update_option( 'ayecode-ui-settings', $db_settings ); |
|
| 281 | - wp_safe_redirect(admin_url("options-general.php?page=ayecode-ui-settings&updated=true")); |
|
| 282 | - } |
|
| 283 | - } |
|
| 269 | + /** |
|
| 270 | + * Initiate the settings and add the required action hooks. |
|
| 271 | + */ |
|
| 272 | + public function init() { |
|
| 273 | + |
|
| 274 | + // Maybe fix settings |
|
| 275 | + if ( ! empty( $_REQUEST['aui-fix-admin'] ) && !empty($_REQUEST['nonce']) && wp_verify_nonce( $_REQUEST['nonce'], "aui-fix-admin" ) ) { |
|
| 276 | + $db_settings = get_option( 'ayecode-ui-settings' ); |
|
| 277 | + if ( ! empty( $db_settings ) ) { |
|
| 278 | + $db_settings['css_backend'] = 'compatibility'; |
|
| 279 | + $db_settings['js_backend'] = 'core-popper'; |
|
| 280 | + update_option( 'ayecode-ui-settings', $db_settings ); |
|
| 281 | + wp_safe_redirect(admin_url("options-general.php?page=ayecode-ui-settings&updated=true")); |
|
| 282 | + } |
|
| 283 | + } |
|
| 284 | 284 | |
| 285 | - $this->constants(); |
|
| 286 | - $this->settings = $this->get_settings(); |
|
| 287 | - $this->url = $this->get_url(); |
|
| 285 | + $this->constants(); |
|
| 286 | + $this->settings = $this->get_settings(); |
|
| 287 | + $this->url = $this->get_url(); |
|
| 288 | + |
|
| 289 | + /** |
|
| 290 | + * Maybe load CSS |
|
| 291 | + * |
|
| 292 | + * We load super early in case there is a theme version that might change the colors |
|
| 293 | + */ |
|
| 294 | + if ( $this->settings['css'] ) { |
|
| 295 | + $priority = $this->is_bs3_compat() ? 100 : 1; |
|
| 296 | + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), $priority ); |
|
| 297 | + } |
|
| 298 | + if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) { |
|
| 299 | + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
| 300 | + } |
|
| 288 | 301 | |
| 289 | - /** |
|
| 290 | - * Maybe load CSS |
|
| 291 | - * |
|
| 292 | - * We load super early in case there is a theme version that might change the colors |
|
| 293 | - */ |
|
| 294 | - if ( $this->settings['css'] ) { |
|
| 295 | - $priority = $this->is_bs3_compat() ? 100 : 1; |
|
| 296 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), $priority ); |
|
| 297 | - } |
|
| 298 | - if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) { |
|
| 299 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
| 300 | - } |
|
| 301 | - |
|
| 302 | - // maybe load JS |
|
| 303 | - if ( $this->settings['js'] ) { |
|
| 304 | - $priority = $this->is_bs3_compat() ? 100 : 1; |
|
| 305 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority ); |
|
| 306 | - } |
|
| 307 | - if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) { |
|
| 308 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); |
|
| 309 | - } |
|
| 310 | - |
|
| 311 | - // Maybe set the HTML font size |
|
| 312 | - if ( $this->settings['html_font_size'] ) { |
|
| 313 | - add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 ); |
|
| 314 | - } |
|
| 315 | - |
|
| 316 | - // Maybe show backend style error |
|
| 317 | - if( $this->settings['css_backend'] != 'compatibility' || $this->settings['js_backend'] != 'core-popper' ){ |
|
| 318 | - add_action( 'admin_notices', array( $this, 'show_admin_style_notice' ) ); |
|
| 319 | - } |
|
| 302 | + // maybe load JS |
|
| 303 | + if ( $this->settings['js'] ) { |
|
| 304 | + $priority = $this->is_bs3_compat() ? 100 : 1; |
|
| 305 | + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority ); |
|
| 306 | + } |
|
| 307 | + if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) { |
|
| 308 | + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); |
|
| 309 | + } |
|
| 320 | 310 | |
| 321 | - } |
|
| 311 | + // Maybe set the HTML font size |
|
| 312 | + if ( $this->settings['html_font_size'] ) { |
|
| 313 | + add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 ); |
|
| 314 | + } |
|
| 322 | 315 | |
| 323 | - /** |
|
| 324 | - * Show admin notice if backend scripts not loaded. |
|
| 325 | - */ |
|
| 326 | - public function show_admin_style_notice(){ |
|
| 327 | - $fix_url = admin_url("options-general.php?page=ayecode-ui-settings&aui-fix-admin=true&nonce=".wp_create_nonce('aui-fix-admin')); |
|
| 328 | - $button = '<a href="'.esc_url($fix_url).'" class="button-primary">Fix Now</a>'; |
|
| 329 | - $message = __( '<b>Style Issue:</b> AyeCode UI is disable or set wrong.')." " .$button; |
|
| 330 | - echo '<div class="notice notice-error aui-settings-error-notice"><p>'.$message.'</p></div>'; |
|
| 331 | - } |
|
| 316 | + // Maybe show backend style error |
|
| 317 | + if( $this->settings['css_backend'] != 'compatibility' || $this->settings['js_backend'] != 'core-popper' ){ |
|
| 318 | + add_action( 'admin_notices', array( $this, 'show_admin_style_notice' ) ); |
|
| 319 | + } |
|
| 332 | 320 | |
| 333 | - /** |
|
| 334 | - * Check if we should load the admin scripts or not. |
|
| 335 | - * |
|
| 336 | - * @return bool |
|
| 337 | - */ |
|
| 338 | - public function load_admin_scripts(){ |
|
| 339 | - $result = true; |
|
| 340 | - |
|
| 341 | - // check if specifically disabled |
|
| 342 | - if(!empty($this->settings['disable_admin'])){ |
|
| 343 | - $url_parts = explode("\n",$this->settings['disable_admin']); |
|
| 344 | - foreach($url_parts as $part){ |
|
| 345 | - if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){ |
|
| 346 | - return false; // return early, no point checking further |
|
| 347 | - } |
|
| 348 | - } |
|
| 349 | - } |
|
| 321 | + } |
|
| 350 | 322 | |
| 351 | - return $result; |
|
| 352 | - } |
|
| 323 | + /** |
|
| 324 | + * Show admin notice if backend scripts not loaded. |
|
| 325 | + */ |
|
| 326 | + public function show_admin_style_notice(){ |
|
| 327 | + $fix_url = admin_url("options-general.php?page=ayecode-ui-settings&aui-fix-admin=true&nonce=".wp_create_nonce('aui-fix-admin')); |
|
| 328 | + $button = '<a href="'.esc_url($fix_url).'" class="button-primary">Fix Now</a>'; |
|
| 329 | + $message = __( '<b>Style Issue:</b> AyeCode UI is disable or set wrong.')." " .$button; |
|
| 330 | + echo '<div class="notice notice-error aui-settings-error-notice"><p>'.$message.'</p></div>'; |
|
| 331 | + } |
|
| 353 | 332 | |
| 354 | - /** |
|
| 355 | - * Add a html font size to the footer. |
|
| 356 | - */ |
|
| 357 | - public function html_font_size(){ |
|
| 358 | - $this->settings = $this->get_settings(); |
|
| 359 | - echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>"; |
|
| 360 | - } |
|
| 333 | + /** |
|
| 334 | + * Check if we should load the admin scripts or not. |
|
| 335 | + * |
|
| 336 | + * @return bool |
|
| 337 | + */ |
|
| 338 | + public function load_admin_scripts(){ |
|
| 339 | + $result = true; |
|
| 340 | + |
|
| 341 | + // check if specifically disabled |
|
| 342 | + if(!empty($this->settings['disable_admin'])){ |
|
| 343 | + $url_parts = explode("\n",$this->settings['disable_admin']); |
|
| 344 | + foreach($url_parts as $part){ |
|
| 345 | + if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){ |
|
| 346 | + return false; // return early, no point checking further |
|
| 347 | + } |
|
| 348 | + } |
|
| 349 | + } |
|
| 350 | + |
|
| 351 | + return $result; |
|
| 352 | + } |
|
| 353 | + |
|
| 354 | + /** |
|
| 355 | + * Add a html font size to the footer. |
|
| 356 | + */ |
|
| 357 | + public function html_font_size(){ |
|
| 358 | + $this->settings = $this->get_settings(); |
|
| 359 | + echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>"; |
|
| 360 | + } |
|
| 361 | 361 | |
| 362 | - /** |
|
| 363 | - * Check if the current admin screen should load scripts. |
|
| 364 | - * |
|
| 365 | - * @return bool |
|
| 366 | - */ |
|
| 367 | - public function is_aui_screen(){ |
|
| 362 | + /** |
|
| 363 | + * Check if the current admin screen should load scripts. |
|
| 364 | + * |
|
| 365 | + * @return bool |
|
| 366 | + */ |
|
| 367 | + public function is_aui_screen(){ |
|
| 368 | 368 | // echo '###';exit; |
| 369 | - $load = false; |
|
| 370 | - // check if we should load or not |
|
| 371 | - if ( is_admin() ) { |
|
| 372 | - // Only enable on set pages |
|
| 373 | - $aui_screens = array( |
|
| 374 | - 'page', |
|
| 375 | - 'post', |
|
| 376 | - 'settings_page_ayecode-ui-settings', |
|
| 377 | - 'appearance_page_gutenberg-widgets', |
|
| 378 | - 'widgets', |
|
| 379 | - 'ayecode-ui-settings', |
|
| 380 | - 'site-editor' |
|
| 381 | - ); |
|
| 382 | - $screen_ids = apply_filters( 'aui_screen_ids', $aui_screens ); |
|
| 383 | - |
|
| 384 | - $screen = get_current_screen(); |
|
| 369 | + $load = false; |
|
| 370 | + // check if we should load or not |
|
| 371 | + if ( is_admin() ) { |
|
| 372 | + // Only enable on set pages |
|
| 373 | + $aui_screens = array( |
|
| 374 | + 'page', |
|
| 375 | + 'post', |
|
| 376 | + 'settings_page_ayecode-ui-settings', |
|
| 377 | + 'appearance_page_gutenberg-widgets', |
|
| 378 | + 'widgets', |
|
| 379 | + 'ayecode-ui-settings', |
|
| 380 | + 'site-editor' |
|
| 381 | + ); |
|
| 382 | + $screen_ids = apply_filters( 'aui_screen_ids', $aui_screens ); |
|
| 383 | + |
|
| 384 | + $screen = get_current_screen(); |
|
| 385 | 385 | |
| 386 | 386 | // echo '###'.$screen->id; |
| 387 | 387 | |
| 388 | - // check if we are on a AUI screen |
|
| 389 | - if ( $screen && in_array( $screen->id, $screen_ids ) ) { |
|
| 390 | - $load = true; |
|
| 391 | - } |
|
| 388 | + // check if we are on a AUI screen |
|
| 389 | + if ( $screen && in_array( $screen->id, $screen_ids ) ) { |
|
| 390 | + $load = true; |
|
| 391 | + } |
|
| 392 | 392 | |
| 393 | - //load for widget previews in WP 5.8 |
|
| 394 | - if( !empty($_REQUEST['legacy-widget-preview'])){ |
|
| 395 | - $load = true; |
|
| 396 | - } |
|
| 397 | - } |
|
| 393 | + //load for widget previews in WP 5.8 |
|
| 394 | + if( !empty($_REQUEST['legacy-widget-preview'])){ |
|
| 395 | + $load = true; |
|
| 396 | + } |
|
| 397 | + } |
|
| 398 | 398 | |
| 399 | - return apply_filters( 'aui_load_on_admin' , $load ); |
|
| 400 | - } |
|
| 399 | + return apply_filters( 'aui_load_on_admin' , $load ); |
|
| 400 | + } |
|
| 401 | 401 | |
| 402 | - /** |
|
| 402 | + /** |
|
| 403 | 403 | * Check if the current theme is a block theme. |
| 404 | 404 | * |
| 405 | - * @return bool |
|
| 406 | - */ |
|
| 407 | - public static function is_block_theme() { |
|
| 408 | - if ( function_exists( 'wp_is_block_theme' && wp_is_block_theme() ) ) { |
|
| 409 | - return true; |
|
| 410 | - } |
|
| 411 | - |
|
| 412 | - return false; |
|
| 413 | - } |
|
| 405 | + * @return bool |
|
| 406 | + */ |
|
| 407 | + public static function is_block_theme() { |
|
| 408 | + if ( function_exists( 'wp_is_block_theme' && wp_is_block_theme() ) ) { |
|
| 409 | + return true; |
|
| 410 | + } |
|
| 414 | 411 | |
| 415 | - /** |
|
| 416 | - * Adds the styles. |
|
| 417 | - */ |
|
| 418 | - public function enqueue_style() { |
|
| 412 | + return false; |
|
| 413 | + } |
|
| 419 | 414 | |
| 415 | + /** |
|
| 416 | + * Adds the styles. |
|
| 417 | + */ |
|
| 418 | + public function enqueue_style() { |
|
| 420 | 419 | |
| 421 | - if( is_admin() && !$this->is_aui_screen()){ |
|
| 422 | - // don't add wp-admin scripts if not requested to |
|
| 423 | - }else{ |
|
| 424 | - $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
|
| 425 | 420 | |
| 426 | - $rtl = is_rtl() ? '-rtl' : ''; |
|
| 421 | + if( is_admin() && !$this->is_aui_screen()){ |
|
| 422 | + // don't add wp-admin scripts if not requested to |
|
| 423 | + }else{ |
|
| 424 | + $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
|
| 427 | 425 | |
| 428 | - if($this->settings[$css_setting]){ |
|
| 429 | - $compatibility = $this->settings[$css_setting]=='core' ? false : true; |
|
| 430 | - $url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets/css/ayecode-ui-compatibility'.$rtl.'.css'; |
|
| 431 | - wp_register_style( 'ayecode-ui', $url, array(), $this->version ); |
|
| 432 | - wp_enqueue_style( 'ayecode-ui' ); |
|
| 426 | + $rtl = is_rtl() ? '-rtl' : ''; |
|
| 433 | 427 | |
| 434 | - // flatpickr |
|
| 435 | - wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->version ); |
|
| 428 | + if($this->settings[$css_setting]){ |
|
| 429 | + $compatibility = $this->settings[$css_setting]=='core' ? false : true; |
|
| 430 | + $url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets/css/ayecode-ui-compatibility'.$rtl.'.css'; |
|
| 431 | + wp_register_style( 'ayecode-ui', $url, array(), $this->version ); |
|
| 432 | + wp_enqueue_style( 'ayecode-ui' ); |
|
| 436 | 433 | |
| 437 | - // fix some wp-admin issues |
|
| 438 | - if(is_admin()){ |
|
| 439 | - $custom_css = " |
|
| 434 | + // flatpickr |
|
| 435 | + wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->version ); |
|
| 436 | + |
|
| 437 | + // fix some wp-admin issues |
|
| 438 | + if(is_admin()){ |
|
| 439 | + $custom_css = " |
|
| 440 | 440 | body{ |
| 441 | 441 | background-color: #f1f1f1; |
| 442 | 442 | font-family: -apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Oxygen-Sans,Ubuntu,Cantarell,\"Helvetica Neue\",sans-serif; |
@@ -482,35 +482,35 @@ discard block |
||
| 482 | 482 | } |
| 483 | 483 | "; |
| 484 | 484 | |
| 485 | - // @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377 |
|
| 486 | - $custom_css .= " |
|
| 485 | + // @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377 |
|
| 486 | + $custom_css .= " |
|
| 487 | 487 | .edit-post-sidebar input[type=color].components-text-control__input{ |
| 488 | 488 | padding: 0; |
| 489 | 489 | } |
| 490 | 490 | "; |
| 491 | - wp_add_inline_style( 'ayecode-ui', $custom_css ); |
|
| 492 | - } |
|
| 491 | + wp_add_inline_style( 'ayecode-ui', $custom_css ); |
|
| 492 | + } |
|
| 493 | 493 | |
| 494 | - // custom changes |
|
| 495 | - wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); |
|
| 494 | + // custom changes |
|
| 495 | + wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); |
|
| 496 | 496 | |
| 497 | - } |
|
| 498 | - } |
|
| 497 | + } |
|
| 498 | + } |
|
| 499 | 499 | |
| 500 | 500 | |
| 501 | - } |
|
| 501 | + } |
|
| 502 | 502 | |
| 503 | - /** |
|
| 504 | - * Get inline script used if bootstrap enqueued |
|
| 505 | - * |
|
| 506 | - * If this remains small then its best to use this than to add another JS file. |
|
| 507 | - */ |
|
| 508 | - public function inline_script() { |
|
| 509 | - // Flatpickr calendar locale |
|
| 510 | - $flatpickr_locale = self::flatpickr_locale(); |
|
| 511 | - |
|
| 512 | - ob_start(); |
|
| 513 | - ?> |
|
| 503 | + /** |
|
| 504 | + * Get inline script used if bootstrap enqueued |
|
| 505 | + * |
|
| 506 | + * If this remains small then its best to use this than to add another JS file. |
|
| 507 | + */ |
|
| 508 | + public function inline_script() { |
|
| 509 | + // Flatpickr calendar locale |
|
| 510 | + $flatpickr_locale = self::flatpickr_locale(); |
|
| 511 | + |
|
| 512 | + ob_start(); |
|
| 513 | + ?> |
|
| 514 | 514 | <script> |
| 515 | 515 | /** |
| 516 | 516 | * An AUI bootstrap adaptation of GreedyNav.js ( by Luke Jackson ). |
@@ -1479,29 +1479,29 @@ discard block |
||
| 1479 | 1479 | |
| 1480 | 1480 | </script> |
| 1481 | 1481 | <?php |
| 1482 | - $output = ob_get_clean(); |
|
| 1482 | + $output = ob_get_clean(); |
|
| 1483 | 1483 | |
| 1484 | 1484 | |
| 1485 | 1485 | |
| 1486 | - /* |
|
| 1486 | + /* |
|
| 1487 | 1487 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1488 | 1488 | */ |
| 1489 | - return str_replace( array( |
|
| 1490 | - '<script>', |
|
| 1491 | - '</script>' |
|
| 1492 | - ), '', self::minify_js($output) ); |
|
| 1493 | - } |
|
| 1489 | + return str_replace( array( |
|
| 1490 | + '<script>', |
|
| 1491 | + '</script>' |
|
| 1492 | + ), '', self::minify_js($output) ); |
|
| 1493 | + } |
|
| 1494 | 1494 | |
| 1495 | 1495 | |
| 1496 | - /** |
|
| 1497 | - * JS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
| 1498 | - * |
|
| 1499 | - * @TODO we may need this when other conflicts arrise. |
|
| 1500 | - * @return mixed |
|
| 1501 | - */ |
|
| 1502 | - public static function bs3_compat_js() { |
|
| 1503 | - ob_start(); |
|
| 1504 | - ?> |
|
| 1496 | + /** |
|
| 1497 | + * JS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
| 1498 | + * |
|
| 1499 | + * @TODO we may need this when other conflicts arrise. |
|
| 1500 | + * @return mixed |
|
| 1501 | + */ |
|
| 1502 | + public static function bs3_compat_js() { |
|
| 1503 | + ob_start(); |
|
| 1504 | + ?> |
|
| 1505 | 1505 | <script> |
| 1506 | 1506 | <?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?> |
| 1507 | 1507 | /* With Avada builder */ |
@@ -1509,20 +1509,20 @@ discard block |
||
| 1509 | 1509 | <?php } ?> |
| 1510 | 1510 | </script> |
| 1511 | 1511 | <?php |
| 1512 | - return str_replace( array( |
|
| 1513 | - '<script>', |
|
| 1514 | - '</script>' |
|
| 1515 | - ), '', ob_get_clean()); |
|
| 1516 | - } |
|
| 1512 | + return str_replace( array( |
|
| 1513 | + '<script>', |
|
| 1514 | + '</script>' |
|
| 1515 | + ), '', ob_get_clean()); |
|
| 1516 | + } |
|
| 1517 | 1517 | |
| 1518 | - /** |
|
| 1519 | - * Get inline script used if bootstrap file browser enqueued. |
|
| 1520 | - * |
|
| 1521 | - * If this remains small then its best to use this than to add another JS file. |
|
| 1522 | - */ |
|
| 1523 | - public function inline_script_file_browser(){ |
|
| 1524 | - ob_start(); |
|
| 1525 | - ?> |
|
| 1518 | + /** |
|
| 1519 | + * Get inline script used if bootstrap file browser enqueued. |
|
| 1520 | + * |
|
| 1521 | + * If this remains small then its best to use this than to add another JS file. |
|
| 1522 | + */ |
|
| 1523 | + public function inline_script_file_browser(){ |
|
| 1524 | + ob_start(); |
|
| 1525 | + ?> |
|
| 1526 | 1526 | <script> |
| 1527 | 1527 | // run on doc ready |
| 1528 | 1528 | jQuery(document).ready(function () { |
@@ -1530,224 +1530,224 @@ discard block |
||
| 1530 | 1530 | }); |
| 1531 | 1531 | </script> |
| 1532 | 1532 | <?php |
| 1533 | - $output = ob_get_clean(); |
|
| 1533 | + $output = ob_get_clean(); |
|
| 1534 | 1534 | |
| 1535 | - /* |
|
| 1535 | + /* |
|
| 1536 | 1536 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1537 | 1537 | */ |
| 1538 | - return str_replace( array( |
|
| 1539 | - '<script>', |
|
| 1540 | - '</script>' |
|
| 1541 | - ), '', $output ); |
|
| 1542 | - } |
|
| 1538 | + return str_replace( array( |
|
| 1539 | + '<script>', |
|
| 1540 | + '</script>' |
|
| 1541 | + ), '', $output ); |
|
| 1542 | + } |
|
| 1543 | 1543 | |
| 1544 | - /** |
|
| 1545 | - * Adds the Font Awesome JS. |
|
| 1546 | - */ |
|
| 1547 | - public function enqueue_scripts() { |
|
| 1544 | + /** |
|
| 1545 | + * Adds the Font Awesome JS. |
|
| 1546 | + */ |
|
| 1547 | + public function enqueue_scripts() { |
|
| 1548 | 1548 | |
| 1549 | - if( is_admin() && !$this->is_aui_screen()){ |
|
| 1550 | - // don't add wp-admin scripts if not requested to |
|
| 1551 | - }else { |
|
| 1549 | + if( is_admin() && !$this->is_aui_screen()){ |
|
| 1550 | + // don't add wp-admin scripts if not requested to |
|
| 1551 | + }else { |
|
| 1552 | 1552 | |
| 1553 | - $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
|
| 1553 | + $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
|
| 1554 | 1554 | |
| 1555 | - // select2 |
|
| 1556 | - wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version ); |
|
| 1555 | + // select2 |
|
| 1556 | + wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version ); |
|
| 1557 | 1557 | |
| 1558 | - // flatpickr |
|
| 1559 | - wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->version ); |
|
| 1558 | + // flatpickr |
|
| 1559 | + wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->version ); |
|
| 1560 | 1560 | |
| 1561 | - // flatpickr |
|
| 1562 | - wp_register_script( 'iconpicker', $this->url . 'assets/js/fa-iconpicker.min.js', array(), $this->version ); |
|
| 1561 | + // flatpickr |
|
| 1562 | + wp_register_script( 'iconpicker', $this->url . 'assets/js/fa-iconpicker.min.js', array(), $this->version ); |
|
| 1563 | 1563 | |
| 1564 | - // Bootstrap file browser |
|
| 1565 | - wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version ); |
|
| 1566 | - wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() ); |
|
| 1567 | - |
|
| 1568 | - $load_inline = false; |
|
| 1569 | - |
|
| 1570 | - if ( $this->settings[ $js_setting ] == 'core-popper' ) { |
|
| 1571 | - // Bootstrap bundle |
|
| 1572 | - $url = $this->url . 'assets/js/bootstrap.bundle.min.js'; |
|
| 1573 | - wp_register_script( 'bootstrap-js-bundle', $url, array( |
|
| 1574 | - 'select2', |
|
| 1575 | - 'jquery' |
|
| 1576 | - ), $this->version, $this->is_bs3_compat() ); |
|
| 1577 | - // if in admin then add to footer for compatibility. |
|
| 1578 | - is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' ); |
|
| 1579 | - $script = $this->inline_script(); |
|
| 1580 | - wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
|
| 1581 | - } elseif ( $this->settings[ $js_setting ] == 'popper' ) { |
|
| 1582 | - $url = $this->url . 'assets/js/popper.min.js'; |
|
| 1583 | - wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->version ); |
|
| 1584 | - wp_enqueue_script( 'bootstrap-js-popper' ); |
|
| 1585 | - $load_inline = true; |
|
| 1586 | - } else { |
|
| 1587 | - $load_inline = true; |
|
| 1588 | - } |
|
| 1564 | + // Bootstrap file browser |
|
| 1565 | + wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version ); |
|
| 1566 | + wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() ); |
|
| 1567 | + |
|
| 1568 | + $load_inline = false; |
|
| 1569 | + |
|
| 1570 | + if ( $this->settings[ $js_setting ] == 'core-popper' ) { |
|
| 1571 | + // Bootstrap bundle |
|
| 1572 | + $url = $this->url . 'assets/js/bootstrap.bundle.min.js'; |
|
| 1573 | + wp_register_script( 'bootstrap-js-bundle', $url, array( |
|
| 1574 | + 'select2', |
|
| 1575 | + 'jquery' |
|
| 1576 | + ), $this->version, $this->is_bs3_compat() ); |
|
| 1577 | + // if in admin then add to footer for compatibility. |
|
| 1578 | + is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' ); |
|
| 1579 | + $script = $this->inline_script(); |
|
| 1580 | + wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
|
| 1581 | + } elseif ( $this->settings[ $js_setting ] == 'popper' ) { |
|
| 1582 | + $url = $this->url . 'assets/js/popper.min.js'; |
|
| 1583 | + wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->version ); |
|
| 1584 | + wp_enqueue_script( 'bootstrap-js-popper' ); |
|
| 1585 | + $load_inline = true; |
|
| 1586 | + } else { |
|
| 1587 | + $load_inline = true; |
|
| 1588 | + } |
|
| 1589 | 1589 | |
| 1590 | - // Load needed inline scripts by faking the loading of a script if the main script is not being loaded |
|
| 1591 | - if ( $load_inline ) { |
|
| 1592 | - wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) ); |
|
| 1593 | - wp_enqueue_script( 'bootstrap-dummy' ); |
|
| 1594 | - $script = $this->inline_script(); |
|
| 1595 | - wp_add_inline_script( 'bootstrap-dummy', $script ); |
|
| 1596 | - } |
|
| 1597 | - } |
|
| 1590 | + // Load needed inline scripts by faking the loading of a script if the main script is not being loaded |
|
| 1591 | + if ( $load_inline ) { |
|
| 1592 | + wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) ); |
|
| 1593 | + wp_enqueue_script( 'bootstrap-dummy' ); |
|
| 1594 | + $script = $this->inline_script(); |
|
| 1595 | + wp_add_inline_script( 'bootstrap-dummy', $script ); |
|
| 1596 | + } |
|
| 1597 | + } |
|
| 1598 | 1598 | |
| 1599 | - } |
|
| 1599 | + } |
|
| 1600 | 1600 | |
| 1601 | - /** |
|
| 1602 | - * Enqueue flatpickr if called. |
|
| 1603 | - */ |
|
| 1604 | - public function enqueue_flatpickr(){ |
|
| 1605 | - wp_enqueue_style( 'flatpickr' ); |
|
| 1606 | - wp_enqueue_script( 'flatpickr' ); |
|
| 1607 | - } |
|
| 1601 | + /** |
|
| 1602 | + * Enqueue flatpickr if called. |
|
| 1603 | + */ |
|
| 1604 | + public function enqueue_flatpickr(){ |
|
| 1605 | + wp_enqueue_style( 'flatpickr' ); |
|
| 1606 | + wp_enqueue_script( 'flatpickr' ); |
|
| 1607 | + } |
|
| 1608 | 1608 | |
| 1609 | - /** |
|
| 1610 | - * Enqueue iconpicker if called. |
|
| 1611 | - */ |
|
| 1612 | - public function enqueue_iconpicker(){ |
|
| 1613 | - wp_enqueue_style( 'iconpicker' ); |
|
| 1614 | - wp_enqueue_script( 'iconpicker' ); |
|
| 1615 | - } |
|
| 1609 | + /** |
|
| 1610 | + * Enqueue iconpicker if called. |
|
| 1611 | + */ |
|
| 1612 | + public function enqueue_iconpicker(){ |
|
| 1613 | + wp_enqueue_style( 'iconpicker' ); |
|
| 1614 | + wp_enqueue_script( 'iconpicker' ); |
|
| 1615 | + } |
|
| 1616 | 1616 | |
| 1617 | - /** |
|
| 1618 | - * Get the url path to the current folder. |
|
| 1619 | - * |
|
| 1620 | - * @return string |
|
| 1621 | - */ |
|
| 1622 | - public function get_url() { |
|
| 1623 | - $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) ); |
|
| 1624 | - $content_url = untrailingslashit( WP_CONTENT_URL ); |
|
| 1625 | - |
|
| 1626 | - // Replace http:// to https://. |
|
| 1627 | - if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) { |
|
| 1628 | - $content_url = str_replace( 'http://', 'https://', $content_url ); |
|
| 1629 | - } |
|
| 1630 | - |
|
| 1631 | - // Check if we are inside a plugin |
|
| 1632 | - $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 1633 | - $url = str_replace( $content_dir, $content_url, $file_dir ); |
|
| 1634 | - |
|
| 1635 | - return trailingslashit( $url ); |
|
| 1636 | - } |
|
| 1617 | + /** |
|
| 1618 | + * Get the url path to the current folder. |
|
| 1619 | + * |
|
| 1620 | + * @return string |
|
| 1621 | + */ |
|
| 1622 | + public function get_url() { |
|
| 1623 | + $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) ); |
|
| 1624 | + $content_url = untrailingslashit( WP_CONTENT_URL ); |
|
| 1625 | + |
|
| 1626 | + // Replace http:// to https://. |
|
| 1627 | + if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) { |
|
| 1628 | + $content_url = str_replace( 'http://', 'https://', $content_url ); |
|
| 1629 | + } |
|
| 1630 | + |
|
| 1631 | + // Check if we are inside a plugin |
|
| 1632 | + $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 1633 | + $url = str_replace( $content_dir, $content_url, $file_dir ); |
|
| 1634 | + |
|
| 1635 | + return trailingslashit( $url ); |
|
| 1636 | + } |
|
| 1637 | 1637 | |
| 1638 | - /** |
|
| 1639 | - * Get the url path to the current folder. |
|
| 1640 | - * |
|
| 1641 | - * @return string |
|
| 1642 | - */ |
|
| 1643 | - public function get_url_old() { |
|
| 1638 | + /** |
|
| 1639 | + * Get the url path to the current folder. |
|
| 1640 | + * |
|
| 1641 | + * @return string |
|
| 1642 | + */ |
|
| 1643 | + public function get_url_old() { |
|
| 1644 | 1644 | |
| 1645 | - $url = ''; |
|
| 1646 | - // check if we are inside a plugin |
|
| 1647 | - $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 1645 | + $url = ''; |
|
| 1646 | + // check if we are inside a plugin |
|
| 1647 | + $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 1648 | 1648 | |
| 1649 | - // add check in-case user has changed wp-content dir name. |
|
| 1650 | - $wp_content_folder_name = basename(WP_CONTENT_DIR); |
|
| 1651 | - $dir_parts = explode("/$wp_content_folder_name/",$file_dir); |
|
| 1652 | - $url_parts = explode("/$wp_content_folder_name/",plugins_url()); |
|
| 1649 | + // add check in-case user has changed wp-content dir name. |
|
| 1650 | + $wp_content_folder_name = basename(WP_CONTENT_DIR); |
|
| 1651 | + $dir_parts = explode("/$wp_content_folder_name/",$file_dir); |
|
| 1652 | + $url_parts = explode("/$wp_content_folder_name/",plugins_url()); |
|
| 1653 | 1653 | |
| 1654 | - if(!empty($url_parts[0]) && !empty($dir_parts[1])){ |
|
| 1655 | - $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); |
|
| 1656 | - } |
|
| 1654 | + if(!empty($url_parts[0]) && !empty($dir_parts[1])){ |
|
| 1655 | + $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); |
|
| 1656 | + } |
|
| 1657 | 1657 | |
| 1658 | - return $url; |
|
| 1659 | - } |
|
| 1658 | + return $url; |
|
| 1659 | + } |
|
| 1660 | 1660 | |
| 1661 | - /** |
|
| 1662 | - * Register the database settings with WordPress. |
|
| 1663 | - */ |
|
| 1664 | - public function register_settings() { |
|
| 1665 | - register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); |
|
| 1666 | - } |
|
| 1661 | + /** |
|
| 1662 | + * Register the database settings with WordPress. |
|
| 1663 | + */ |
|
| 1664 | + public function register_settings() { |
|
| 1665 | + register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); |
|
| 1666 | + } |
|
| 1667 | 1667 | |
| 1668 | - /** |
|
| 1669 | - * Add the WordPress settings menu item. |
|
| 1670 | - * @since 1.0.10 Calling function name direct will fail theme check so we don't. |
|
| 1671 | - */ |
|
| 1672 | - public function menu_item() { |
|
| 1673 | - $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
|
| 1674 | - call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
| 1675 | - $this, |
|
| 1676 | - 'settings_page' |
|
| 1677 | - ) ); |
|
| 1678 | - } |
|
| 1668 | + /** |
|
| 1669 | + * Add the WordPress settings menu item. |
|
| 1670 | + * @since 1.0.10 Calling function name direct will fail theme check so we don't. |
|
| 1671 | + */ |
|
| 1672 | + public function menu_item() { |
|
| 1673 | + $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
|
| 1674 | + call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
| 1675 | + $this, |
|
| 1676 | + 'settings_page' |
|
| 1677 | + ) ); |
|
| 1678 | + } |
|
| 1679 | 1679 | |
| 1680 | - /** |
|
| 1681 | - * Get a list of themes and their default JS settings. |
|
| 1682 | - * |
|
| 1683 | - * @return array |
|
| 1684 | - */ |
|
| 1685 | - public function theme_js_settings(){ |
|
| 1686 | - return array( |
|
| 1687 | - 'ayetheme' => 'popper', |
|
| 1688 | - 'listimia' => 'required', |
|
| 1689 | - 'listimia_backend' => 'core-popper', |
|
| 1690 | - //'avada' => 'required', // removed as we now add compatibility |
|
| 1691 | - ); |
|
| 1692 | - } |
|
| 1680 | + /** |
|
| 1681 | + * Get a list of themes and their default JS settings. |
|
| 1682 | + * |
|
| 1683 | + * @return array |
|
| 1684 | + */ |
|
| 1685 | + public function theme_js_settings(){ |
|
| 1686 | + return array( |
|
| 1687 | + 'ayetheme' => 'popper', |
|
| 1688 | + 'listimia' => 'required', |
|
| 1689 | + 'listimia_backend' => 'core-popper', |
|
| 1690 | + //'avada' => 'required', // removed as we now add compatibility |
|
| 1691 | + ); |
|
| 1692 | + } |
|
| 1693 | 1693 | |
| 1694 | - /** |
|
| 1695 | - * Get the current Font Awesome output settings. |
|
| 1696 | - * |
|
| 1697 | - * @return array The array of settings. |
|
| 1698 | - */ |
|
| 1699 | - public function get_settings() { |
|
| 1700 | - |
|
| 1701 | - $db_settings = get_option( 'ayecode-ui-settings' ); |
|
| 1702 | - $js_default = 'core-popper'; |
|
| 1703 | - $js_default_backend = $js_default; |
|
| 1704 | - |
|
| 1705 | - // maybe set defaults (if no settings set) |
|
| 1706 | - if(empty($db_settings)){ |
|
| 1707 | - $active_theme = strtolower( get_template() ); // active parent theme. |
|
| 1708 | - $theme_js_settings = self::theme_js_settings(); |
|
| 1709 | - if(isset($theme_js_settings[$active_theme])){ |
|
| 1710 | - $js_default = $theme_js_settings[$active_theme]; |
|
| 1711 | - $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default; |
|
| 1712 | - } |
|
| 1713 | - } |
|
| 1714 | - |
|
| 1715 | - $defaults = array( |
|
| 1716 | - 'css' => 'compatibility', // core, compatibility |
|
| 1717 | - 'js' => $js_default, // js to load, core-popper, popper |
|
| 1718 | - 'html_font_size' => '16', // js to load, core-popper, popper |
|
| 1719 | - 'css_backend' => 'compatibility', // core, compatibility |
|
| 1720 | - 'js_backend' => $js_default_backend, // js to load, core-popper, popper |
|
| 1721 | - 'disable_admin' => '', // URL snippets to disable loading on admin |
|
| 1722 | - ); |
|
| 1723 | - |
|
| 1724 | - $settings = wp_parse_args( $db_settings, $defaults ); |
|
| 1725 | - |
|
| 1726 | - /** |
|
| 1727 | - * Filter the Bootstrap settings. |
|
| 1728 | - * |
|
| 1729 | - * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
|
| 1730 | - */ |
|
| 1731 | - return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); |
|
| 1732 | - } |
|
| 1694 | + /** |
|
| 1695 | + * Get the current Font Awesome output settings. |
|
| 1696 | + * |
|
| 1697 | + * @return array The array of settings. |
|
| 1698 | + */ |
|
| 1699 | + public function get_settings() { |
|
| 1700 | + |
|
| 1701 | + $db_settings = get_option( 'ayecode-ui-settings' ); |
|
| 1702 | + $js_default = 'core-popper'; |
|
| 1703 | + $js_default_backend = $js_default; |
|
| 1704 | + |
|
| 1705 | + // maybe set defaults (if no settings set) |
|
| 1706 | + if(empty($db_settings)){ |
|
| 1707 | + $active_theme = strtolower( get_template() ); // active parent theme. |
|
| 1708 | + $theme_js_settings = self::theme_js_settings(); |
|
| 1709 | + if(isset($theme_js_settings[$active_theme])){ |
|
| 1710 | + $js_default = $theme_js_settings[$active_theme]; |
|
| 1711 | + $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default; |
|
| 1712 | + } |
|
| 1713 | + } |
|
| 1714 | + |
|
| 1715 | + $defaults = array( |
|
| 1716 | + 'css' => 'compatibility', // core, compatibility |
|
| 1717 | + 'js' => $js_default, // js to load, core-popper, popper |
|
| 1718 | + 'html_font_size' => '16', // js to load, core-popper, popper |
|
| 1719 | + 'css_backend' => 'compatibility', // core, compatibility |
|
| 1720 | + 'js_backend' => $js_default_backend, // js to load, core-popper, popper |
|
| 1721 | + 'disable_admin' => '', // URL snippets to disable loading on admin |
|
| 1722 | + ); |
|
| 1733 | 1723 | |
| 1724 | + $settings = wp_parse_args( $db_settings, $defaults ); |
|
| 1734 | 1725 | |
| 1735 | - /** |
|
| 1736 | - * The settings page html output. |
|
| 1737 | - */ |
|
| 1738 | - public function settings_page() { |
|
| 1739 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 1740 | - wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) ); |
|
| 1741 | - } |
|
| 1742 | - ?> |
|
| 1726 | + /** |
|
| 1727 | + * Filter the Bootstrap settings. |
|
| 1728 | + * |
|
| 1729 | + * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
|
| 1730 | + */ |
|
| 1731 | + return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); |
|
| 1732 | + } |
|
| 1733 | + |
|
| 1734 | + |
|
| 1735 | + /** |
|
| 1736 | + * The settings page html output. |
|
| 1737 | + */ |
|
| 1738 | + public function settings_page() { |
|
| 1739 | + if ( ! current_user_can( 'manage_options' ) ) { |
|
| 1740 | + wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) ); |
|
| 1741 | + } |
|
| 1742 | + ?> |
|
| 1743 | 1743 | <div class="wrap"> |
| 1744 | 1744 | <h1><?php echo $this->name; ?></h1> |
| 1745 | 1745 | <p><?php _e("Here you can adjust settings if you are having compatibility issues.",'aui');?></p> |
| 1746 | 1746 | <form method="post" action="options.php"> |
| 1747 | 1747 | <?php |
| 1748 | - settings_fields( 'ayecode-ui-settings' ); |
|
| 1749 | - do_settings_sections( 'ayecode-ui-settings' ); |
|
| 1750 | - ?> |
|
| 1748 | + settings_fields( 'ayecode-ui-settings' ); |
|
| 1749 | + do_settings_sections( 'ayecode-ui-settings' ); |
|
| 1750 | + ?> |
|
| 1751 | 1751 | |
| 1752 | 1752 | <h2><?php _e( 'Frontend', 'aui' ); ?></h2> |
| 1753 | 1753 | <table class="form-table wpbs-table-settings"> |
@@ -1827,60 +1827,60 @@ discard block |
||
| 1827 | 1827 | </table> |
| 1828 | 1828 | |
| 1829 | 1829 | <?php |
| 1830 | - submit_button(); |
|
| 1831 | - ?> |
|
| 1830 | + submit_button(); |
|
| 1831 | + ?> |
|
| 1832 | 1832 | </form> |
| 1833 | 1833 | |
| 1834 | 1834 | <div id="wpbs-version"><?php echo $this->version; ?></div> |
| 1835 | 1835 | </div> |
| 1836 | 1836 | |
| 1837 | 1837 | <?php |
| 1838 | - } |
|
| 1838 | + } |
|
| 1839 | 1839 | |
| 1840 | - public function customizer_settings($wp_customize){ |
|
| 1841 | - $wp_customize->add_section('aui_settings', array( |
|
| 1842 | - 'title' => __('AyeCode UI','aui'), |
|
| 1843 | - 'priority' => 120, |
|
| 1844 | - )); |
|
| 1845 | - |
|
| 1846 | - // ============================= |
|
| 1847 | - // = Color Picker = |
|
| 1848 | - // ============================= |
|
| 1849 | - $wp_customize->add_setting('aui_options[color_primary]', array( |
|
| 1850 | - 'default' => AUI_PRIMARY_COLOR, |
|
| 1851 | - 'sanitize_callback' => 'sanitize_hex_color', |
|
| 1852 | - 'capability' => 'edit_theme_options', |
|
| 1853 | - 'type' => 'option', |
|
| 1854 | - 'transport' => 'refresh', |
|
| 1855 | - )); |
|
| 1856 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
| 1857 | - 'label' => __('Primary Color','aui'), |
|
| 1858 | - 'section' => 'aui_settings', |
|
| 1859 | - 'settings' => 'aui_options[color_primary]', |
|
| 1860 | - ))); |
|
| 1861 | - |
|
| 1862 | - $wp_customize->add_setting('aui_options[color_secondary]', array( |
|
| 1863 | - 'default' => '#6c757d', |
|
| 1864 | - 'sanitize_callback' => 'sanitize_hex_color', |
|
| 1865 | - 'capability' => 'edit_theme_options', |
|
| 1866 | - 'type' => 'option', |
|
| 1867 | - 'transport' => 'refresh', |
|
| 1868 | - )); |
|
| 1869 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
| 1870 | - 'label' => __('Secondary Color','aui'), |
|
| 1871 | - 'section' => 'aui_settings', |
|
| 1872 | - 'settings' => 'aui_options[color_secondary]', |
|
| 1873 | - ))); |
|
| 1874 | - } |
|
| 1840 | + public function customizer_settings($wp_customize){ |
|
| 1841 | + $wp_customize->add_section('aui_settings', array( |
|
| 1842 | + 'title' => __('AyeCode UI','aui'), |
|
| 1843 | + 'priority' => 120, |
|
| 1844 | + )); |
|
| 1845 | + |
|
| 1846 | + // ============================= |
|
| 1847 | + // = Color Picker = |
|
| 1848 | + // ============================= |
|
| 1849 | + $wp_customize->add_setting('aui_options[color_primary]', array( |
|
| 1850 | + 'default' => AUI_PRIMARY_COLOR, |
|
| 1851 | + 'sanitize_callback' => 'sanitize_hex_color', |
|
| 1852 | + 'capability' => 'edit_theme_options', |
|
| 1853 | + 'type' => 'option', |
|
| 1854 | + 'transport' => 'refresh', |
|
| 1855 | + )); |
|
| 1856 | + $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
| 1857 | + 'label' => __('Primary Color','aui'), |
|
| 1858 | + 'section' => 'aui_settings', |
|
| 1859 | + 'settings' => 'aui_options[color_primary]', |
|
| 1860 | + ))); |
|
| 1861 | + |
|
| 1862 | + $wp_customize->add_setting('aui_options[color_secondary]', array( |
|
| 1863 | + 'default' => '#6c757d', |
|
| 1864 | + 'sanitize_callback' => 'sanitize_hex_color', |
|
| 1865 | + 'capability' => 'edit_theme_options', |
|
| 1866 | + 'type' => 'option', |
|
| 1867 | + 'transport' => 'refresh', |
|
| 1868 | + )); |
|
| 1869 | + $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
| 1870 | + 'label' => __('Secondary Color','aui'), |
|
| 1871 | + 'section' => 'aui_settings', |
|
| 1872 | + 'settings' => 'aui_options[color_secondary]', |
|
| 1873 | + ))); |
|
| 1874 | + } |
|
| 1875 | 1875 | |
| 1876 | - /** |
|
| 1877 | - * CSS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
| 1878 | - * |
|
| 1879 | - * @return mixed |
|
| 1880 | - */ |
|
| 1881 | - public static function bs3_compat_css() { |
|
| 1882 | - ob_start(); |
|
| 1883 | - ?> |
|
| 1876 | + /** |
|
| 1877 | + * CSS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
| 1878 | + * |
|
| 1879 | + * @return mixed |
|
| 1880 | + */ |
|
| 1881 | + public static function bs3_compat_css() { |
|
| 1882 | + ob_start(); |
|
| 1883 | + ?> |
|
| 1884 | 1884 | <style> |
| 1885 | 1885 | /* Bootstrap 3 compatibility */ |
| 1886 | 1886 | body.modal-open .modal-backdrop.show:not(.in) {opacity:0.5;} |
@@ -1909,47 +1909,47 @@ discard block |
||
| 1909 | 1909 | <?php } ?> |
| 1910 | 1910 | </style> |
| 1911 | 1911 | <?php |
| 1912 | - return str_replace( array( |
|
| 1913 | - '<style>', |
|
| 1914 | - '</style>' |
|
| 1915 | - ), '', self::minify_css( ob_get_clean() ) ); |
|
| 1916 | - } |
|
| 1912 | + return str_replace( array( |
|
| 1913 | + '<style>', |
|
| 1914 | + '</style>' |
|
| 1915 | + ), '', self::minify_css( ob_get_clean() ) ); |
|
| 1916 | + } |
|
| 1917 | 1917 | |
| 1918 | 1918 | |
| 1919 | - public static function custom_css($compatibility = true) { |
|
| 1920 | - $colors = array(); |
|
| 1921 | - if ( defined( 'BLOCKSTRAP_VERSION' ) ) { |
|
| 1919 | + public static function custom_css($compatibility = true) { |
|
| 1920 | + $colors = array(); |
|
| 1921 | + if ( defined( 'BLOCKSTRAP_VERSION' ) ) { |
|
| 1922 | 1922 | |
| 1923 | - $setting = wp_get_global_settings(); |
|
| 1924 | - if(!empty($setting['color']['palette']['theme'])){ |
|
| 1925 | - foreach($setting['color']['palette']['theme'] as $color){ |
|
| 1926 | - $colors[$color['slug']] = esc_attr($color['color']); |
|
| 1927 | - } |
|
| 1928 | - } |
|
| 1923 | + $setting = wp_get_global_settings(); |
|
| 1924 | + if(!empty($setting['color']['palette']['theme'])){ |
|
| 1925 | + foreach($setting['color']['palette']['theme'] as $color){ |
|
| 1926 | + $colors[$color['slug']] = esc_attr($color['color']); |
|
| 1927 | + } |
|
| 1928 | + } |
|
| 1929 | 1929 | |
| 1930 | - if(!empty($setting['color']['palette']['custom'])){ |
|
| 1931 | - foreach($setting['color']['palette']['custom'] as $color){ |
|
| 1932 | - $colors[$color['slug']] = esc_attr($color['color']); |
|
| 1933 | - } |
|
| 1934 | - } |
|
| 1935 | - }else{ |
|
| 1936 | - $settings = get_option('aui_options'); |
|
| 1937 | - $colors = array( |
|
| 1938 | - 'primary' => ! empty( $settings['color_primary'] ) ? $settings['color_primary'] : AUI_PRIMARY_COLOR, |
|
| 1939 | - 'secondary' => ! empty( $settings['color_secondary'] ) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR |
|
| 1940 | - ); |
|
| 1941 | - } |
|
| 1930 | + if(!empty($setting['color']['palette']['custom'])){ |
|
| 1931 | + foreach($setting['color']['palette']['custom'] as $color){ |
|
| 1932 | + $colors[$color['slug']] = esc_attr($color['color']); |
|
| 1933 | + } |
|
| 1934 | + } |
|
| 1935 | + }else{ |
|
| 1936 | + $settings = get_option('aui_options'); |
|
| 1937 | + $colors = array( |
|
| 1938 | + 'primary' => ! empty( $settings['color_primary'] ) ? $settings['color_primary'] : AUI_PRIMARY_COLOR, |
|
| 1939 | + 'secondary' => ! empty( $settings['color_secondary'] ) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR |
|
| 1940 | + ); |
|
| 1941 | + } |
|
| 1942 | 1942 | |
| 1943 | - ob_start(); |
|
| 1943 | + ob_start(); |
|
| 1944 | 1944 | |
| 1945 | - ?> |
|
| 1945 | + ?> |
|
| 1946 | 1946 | <style> |
| 1947 | 1947 | <?php |
| 1948 | 1948 | |
| 1949 | - // BS v3 compat |
|
| 1950 | - if( self::is_bs3_compat() ){ |
|
| 1951 | - echo self::bs3_compat_css(); |
|
| 1952 | - } |
|
| 1949 | + // BS v3 compat |
|
| 1950 | + if( self::is_bs3_compat() ){ |
|
| 1951 | + echo self::bs3_compat_css(); |
|
| 1952 | + } |
|
| 1953 | 1953 | |
| 1954 | 1954 | if(!empty($colors)){ |
| 1955 | 1955 | $d_colors = self::get_colors(true); |
@@ -1963,768 +1963,768 @@ discard block |
||
| 1963 | 1963 | echo self::css_overwrite($key,$var,$compat); |
| 1964 | 1964 | } |
| 1965 | 1965 | } |
| 1966 | - // exit; |
|
| 1966 | + // exit; |
|
| 1967 | 1967 | } |
| 1968 | 1968 | |
| 1969 | - // Set admin bar z-index lower when modal is open. |
|
| 1970 | - echo ' body.modal-open #wpadminbar{z-index:999}.embed-responsive-16by9 .fluid-width-video-wrapper{padding:0 !important;position:initial}'; |
|
| 1969 | + // Set admin bar z-index lower when modal is open. |
|
| 1970 | + echo ' body.modal-open #wpadminbar{z-index:999}.embed-responsive-16by9 .fluid-width-video-wrapper{padding:0 !important;position:initial}'; |
|
| 1971 | 1971 | |
| 1972 | - if(is_admin()){ |
|
| 1973 | - echo ' body.modal-open #adminmenuwrap{z-index:999} body.modal-open #wpadminbar{z-index:1025}'; |
|
| 1974 | - } |
|
| 1972 | + if(is_admin()){ |
|
| 1973 | + echo ' body.modal-open #adminmenuwrap{z-index:999} body.modal-open #wpadminbar{z-index:1025}'; |
|
| 1974 | + } |
|
| 1975 | 1975 | ?> |
| 1976 | 1976 | </style> |
| 1977 | 1977 | <?php |
| 1978 | 1978 | |
| 1979 | 1979 | |
| 1980 | - /* |
|
| 1980 | + /* |
|
| 1981 | 1981 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1982 | 1982 | */ |
| 1983 | - return str_replace( array( |
|
| 1984 | - '<style>', |
|
| 1985 | - '</style>' |
|
| 1986 | - ), '', self::minify_css( ob_get_clean() ) ); |
|
| 1987 | - } |
|
| 1983 | + return str_replace( array( |
|
| 1984 | + '<style>', |
|
| 1985 | + '</style>' |
|
| 1986 | + ), '', self::minify_css( ob_get_clean() ) ); |
|
| 1987 | + } |
|
| 1988 | 1988 | |
| 1989 | 1989 | |
| 1990 | 1990 | |
| 1991 | - /** |
|
| 1992 | - * Check if we should add booststrap 3 compatibility changes. |
|
| 1993 | - * |
|
| 1994 | - * @return bool |
|
| 1995 | - */ |
|
| 1996 | - public static function is_bs3_compat(){ |
|
| 1997 | - return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION'); |
|
| 1998 | - } |
|
| 1991 | + /** |
|
| 1992 | + * Check if we should add booststrap 3 compatibility changes. |
|
| 1993 | + * |
|
| 1994 | + * @return bool |
|
| 1995 | + */ |
|
| 1996 | + public static function is_bs3_compat(){ |
|
| 1997 | + return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION'); |
|
| 1998 | + } |
|
| 1999 | 1999 | |
| 2000 | - /** |
|
| 2000 | + /** |
|
| 2001 | 2001 | * Build the CSS to overwrite a bootstrap color variable. |
| 2002 | 2002 | * |
| 2003 | - * @param $type |
|
| 2004 | - * @param $color_code |
|
| 2005 | - * @param $compatibility |
|
| 2006 | - * |
|
| 2007 | - * @return string |
|
| 2008 | - */ |
|
| 2009 | - public static function css_overwrite($type,$color_code,$compatibility){ |
|
| 2003 | + * @param $type |
|
| 2004 | + * @param $color_code |
|
| 2005 | + * @param $compatibility |
|
| 2006 | + * |
|
| 2007 | + * @return string |
|
| 2008 | + */ |
|
| 2009 | + public static function css_overwrite($type,$color_code,$compatibility){ |
|
| 2010 | 2010 | |
| 2011 | 2011 | $is_var = false; |
| 2012 | - if(!$color_code){return '';} |
|
| 2013 | - if(!sanitize_hex_color($color_code)){ |
|
| 2014 | - $color_code = esc_attr($color_code); |
|
| 2015 | - $is_var = true; |
|
| 2012 | + if(!$color_code){return '';} |
|
| 2013 | + if(!sanitize_hex_color($color_code)){ |
|
| 2014 | + $color_code = esc_attr($color_code); |
|
| 2015 | + $is_var = true; |
|
| 2016 | 2016 | // echo '###1'.$color_code;//exit; |
| 2017 | - } |
|
| 2018 | - if(!$color_code){return '';} |
|
| 2017 | + } |
|
| 2018 | + if(!$color_code){return '';} |
|
| 2019 | 2019 | |
| 2020 | 2020 | if($compatibility===true || $compatibility===1){ |
| 2021 | - $compatibility = '.bsui'; |
|
| 2021 | + $compatibility = '.bsui'; |
|
| 2022 | 2022 | }elseif(!$compatibility){ |
| 2023 | - $compatibility = ''; |
|
| 2023 | + $compatibility = ''; |
|
| 2024 | 2024 | }else{ |
| 2025 | - $compatibility = esc_attr($compatibility); |
|
| 2025 | + $compatibility = esc_attr($compatibility); |
|
| 2026 | 2026 | } |
| 2027 | 2027 | |
| 2028 | 2028 | // echo '####'.$color_code;exit; |
| 2029 | 2029 | |
| 2030 | - $type = sanitize_html_class($type); |
|
| 2030 | + $type = sanitize_html_class($type); |
|
| 2031 | + |
|
| 2032 | + /** |
|
| 2033 | + * c = color, b = background color, o = border-color, f = fill |
|
| 2034 | + */ |
|
| 2035 | + $selectors = array( |
|
| 2036 | + ".btn-{$type}" => array( 'b', 'o' ), |
|
| 2037 | + ".btn-{$type}.disabled" => array( 'b', 'o' ), |
|
| 2038 | + ".btn-{$type}:disabled" => array( 'b', 'o' ), |
|
| 2039 | + ".btn-outline-{$type}" => array( 'c', 'o' ), |
|
| 2040 | + ".btn-outline-{$type}:hover" => array( 'b', 'o' ), |
|
| 2041 | + ".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ), |
|
| 2042 | + ".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ), |
|
| 2043 | + ".show>.btn-outline-{$type}.dropdown-toggle" => array( 'b', 'o' ), |
|
| 2044 | + ".badge-{$type}" => array( 'b' ), |
|
| 2045 | + ".alert-{$type}" => array( 'b', 'o' ), |
|
| 2046 | + ".bg-{$type}" => array( 'b', 'f' ), |
|
| 2047 | + ".btn-link.btn-{$type}" => array( 'c' ), |
|
| 2048 | + ); |
|
| 2031 | 2049 | |
| 2032 | - /** |
|
| 2033 | - * c = color, b = background color, o = border-color, f = fill |
|
| 2034 | - */ |
|
| 2035 | - $selectors = array( |
|
| 2036 | - ".btn-{$type}" => array( 'b', 'o' ), |
|
| 2037 | - ".btn-{$type}.disabled" => array( 'b', 'o' ), |
|
| 2038 | - ".btn-{$type}:disabled" => array( 'b', 'o' ), |
|
| 2039 | - ".btn-outline-{$type}" => array( 'c', 'o' ), |
|
| 2040 | - ".btn-outline-{$type}:hover" => array( 'b', 'o' ), |
|
| 2041 | - ".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ), |
|
| 2042 | - ".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ), |
|
| 2043 | - ".show>.btn-outline-{$type}.dropdown-toggle" => array( 'b', 'o' ), |
|
| 2044 | - ".badge-{$type}" => array( 'b' ), |
|
| 2045 | - ".alert-{$type}" => array( 'b', 'o' ), |
|
| 2046 | - ".bg-{$type}" => array( 'b', 'f' ), |
|
| 2047 | - ".btn-link.btn-{$type}" => array( 'c' ), |
|
| 2048 | - ); |
|
| 2049 | - |
|
| 2050 | - if ( $type == 'primary' ) { |
|
| 2051 | - $selectors = $selectors + array( |
|
| 2052 | - 'a' => array( 'c' ), |
|
| 2053 | - '.btn-link' => array( 'c' ), |
|
| 2054 | - '.dropdown-item.active' => array( 'b' ), |
|
| 2055 | - '.custom-control-input:checked~.custom-control-label::before' => array( |
|
| 2056 | - 'b', |
|
| 2057 | - 'o' |
|
| 2058 | - ), |
|
| 2059 | - '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array( |
|
| 2060 | - 'b', |
|
| 2061 | - 'o' |
|
| 2062 | - ), |
|
| 2063 | - '.nav-pills .nav-link.active' => array( 'b' ), |
|
| 2064 | - '.nav-pills .show>.nav-link' => array( 'b' ), |
|
| 2065 | - '.page-link' => array( 'c' ), |
|
| 2066 | - '.page-item.active .page-link' => array( |
|
| 2067 | - 'b', |
|
| 2068 | - 'o' |
|
| 2069 | - ), |
|
| 2070 | - '.progress-bar' => array( 'b' ), |
|
| 2071 | - '.list-group-item.active' => array( |
|
| 2072 | - 'b', |
|
| 2073 | - 'o' |
|
| 2074 | - ), |
|
| 2075 | - '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ), |
|
| 2050 | + if ( $type == 'primary' ) { |
|
| 2051 | + $selectors = $selectors + array( |
|
| 2052 | + 'a' => array( 'c' ), |
|
| 2053 | + '.btn-link' => array( 'c' ), |
|
| 2054 | + '.dropdown-item.active' => array( 'b' ), |
|
| 2055 | + '.custom-control-input:checked~.custom-control-label::before' => array( |
|
| 2056 | + 'b', |
|
| 2057 | + 'o' |
|
| 2058 | + ), |
|
| 2059 | + '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array( |
|
| 2060 | + 'b', |
|
| 2061 | + 'o' |
|
| 2062 | + ), |
|
| 2063 | + '.nav-pills .nav-link.active' => array( 'b' ), |
|
| 2064 | + '.nav-pills .show>.nav-link' => array( 'b' ), |
|
| 2065 | + '.page-link' => array( 'c' ), |
|
| 2066 | + '.page-item.active .page-link' => array( |
|
| 2067 | + 'b', |
|
| 2068 | + 'o' |
|
| 2069 | + ), |
|
| 2070 | + '.progress-bar' => array( 'b' ), |
|
| 2071 | + '.list-group-item.active' => array( |
|
| 2072 | + 'b', |
|
| 2073 | + 'o' |
|
| 2074 | + ), |
|
| 2075 | + '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ), |
|
| 2076 | 2076 | // '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules... |
| 2077 | 2077 | // '.custom-range::-moz-range-thumb' => array('b'), |
| 2078 | 2078 | // '.custom-range::-ms-thumb' => array('b'), |
| 2079 | - ); |
|
| 2080 | - } |
|
| 2081 | - |
|
| 2082 | - $important_selectors = array( |
|
| 2083 | - ".bg-{$type}" => array('b','f'), |
|
| 2084 | - ".border-{$type}" => array('o'), |
|
| 2085 | - ".text-{$type}" => array('c'), |
|
| 2086 | - ); |
|
| 2087 | - |
|
| 2088 | - $color = array(); |
|
| 2089 | - $color_i = array(); |
|
| 2090 | - $background = array(); |
|
| 2091 | - $background_i = array(); |
|
| 2092 | - $border = array(); |
|
| 2093 | - $border_i = array(); |
|
| 2094 | - $fill = array(); |
|
| 2095 | - $fill_i = array(); |
|
| 2096 | - |
|
| 2097 | - $output = ''; |
|
| 2098 | - |
|
| 2099 | - // build rules into each type |
|
| 2100 | - foreach($selectors as $selector => $types){ |
|
| 2101 | - $selector = $compatibility ? $compatibility . " ".$selector : $selector; |
|
| 2102 | - $types = array_combine($types,$types); |
|
| 2103 | - if(isset($types['c'])){$color[] = $selector;} |
|
| 2104 | - if(isset($types['b'])){$background[] = $selector;} |
|
| 2105 | - if(isset($types['o'])){$border[] = $selector;} |
|
| 2106 | - if(isset($types['f'])){$fill[] = $selector;} |
|
| 2107 | - } |
|
| 2108 | - |
|
| 2109 | - // build rules into each type |
|
| 2110 | - foreach($important_selectors as $selector => $types){ |
|
| 2111 | - $selector = $compatibility ? $compatibility . " ".$selector : $selector; |
|
| 2112 | - $types = array_combine($types,$types); |
|
| 2113 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
| 2114 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
| 2115 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
| 2116 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 2117 | - } |
|
| 2118 | - |
|
| 2119 | - // add any color rules |
|
| 2120 | - if(!empty($color)){ |
|
| 2121 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 2122 | - } |
|
| 2123 | - if(!empty($color_i)){ |
|
| 2124 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 2125 | - } |
|
| 2126 | - |
|
| 2127 | - // add any background color rules |
|
| 2128 | - if(!empty($background)){ |
|
| 2129 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 2130 | - } |
|
| 2131 | - if(!empty($background_i)){ |
|
| 2132 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 2133 | - } |
|
| 2134 | - |
|
| 2135 | - // add any border color rules |
|
| 2136 | - if(!empty($border)){ |
|
| 2137 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 2138 | - } |
|
| 2139 | - if(!empty($border_i)){ |
|
| 2140 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 2141 | - } |
|
| 2142 | - |
|
| 2143 | - // add any fill color rules |
|
| 2144 | - if(!empty($fill)){ |
|
| 2145 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 2146 | - } |
|
| 2147 | - if(!empty($fill_i)){ |
|
| 2148 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 2149 | - } |
|
| 2150 | - |
|
| 2151 | - |
|
| 2152 | - $prefix = $compatibility ? $compatibility . " " : ""; |
|
| 2079 | + ); |
|
| 2080 | + } |
|
| 2081 | + |
|
| 2082 | + $important_selectors = array( |
|
| 2083 | + ".bg-{$type}" => array('b','f'), |
|
| 2084 | + ".border-{$type}" => array('o'), |
|
| 2085 | + ".text-{$type}" => array('c'), |
|
| 2086 | + ); |
|
| 2087 | + |
|
| 2088 | + $color = array(); |
|
| 2089 | + $color_i = array(); |
|
| 2090 | + $background = array(); |
|
| 2091 | + $background_i = array(); |
|
| 2092 | + $border = array(); |
|
| 2093 | + $border_i = array(); |
|
| 2094 | + $fill = array(); |
|
| 2095 | + $fill_i = array(); |
|
| 2096 | + |
|
| 2097 | + $output = ''; |
|
| 2098 | + |
|
| 2099 | + // build rules into each type |
|
| 2100 | + foreach($selectors as $selector => $types){ |
|
| 2101 | + $selector = $compatibility ? $compatibility . " ".$selector : $selector; |
|
| 2102 | + $types = array_combine($types,$types); |
|
| 2103 | + if(isset($types['c'])){$color[] = $selector;} |
|
| 2104 | + if(isset($types['b'])){$background[] = $selector;} |
|
| 2105 | + if(isset($types['o'])){$border[] = $selector;} |
|
| 2106 | + if(isset($types['f'])){$fill[] = $selector;} |
|
| 2107 | + } |
|
| 2108 | + |
|
| 2109 | + // build rules into each type |
|
| 2110 | + foreach($important_selectors as $selector => $types){ |
|
| 2111 | + $selector = $compatibility ? $compatibility . " ".$selector : $selector; |
|
| 2112 | + $types = array_combine($types,$types); |
|
| 2113 | + if(isset($types['c'])){$color_i[] = $selector;} |
|
| 2114 | + if(isset($types['b'])){$background_i[] = $selector;} |
|
| 2115 | + if(isset($types['o'])){$border_i[] = $selector;} |
|
| 2116 | + if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 2117 | + } |
|
| 2118 | + |
|
| 2119 | + // add any color rules |
|
| 2120 | + if(!empty($color)){ |
|
| 2121 | + $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 2122 | + } |
|
| 2123 | + if(!empty($color_i)){ |
|
| 2124 | + $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 2125 | + } |
|
| 2126 | + |
|
| 2127 | + // add any background color rules |
|
| 2128 | + if(!empty($background)){ |
|
| 2129 | + $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 2130 | + } |
|
| 2131 | + if(!empty($background_i)){ |
|
| 2132 | + $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 2133 | + } |
|
| 2134 | + |
|
| 2135 | + // add any border color rules |
|
| 2136 | + if(!empty($border)){ |
|
| 2137 | + $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 2138 | + } |
|
| 2139 | + if(!empty($border_i)){ |
|
| 2140 | + $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 2141 | + } |
|
| 2142 | + |
|
| 2143 | + // add any fill color rules |
|
| 2144 | + if(!empty($fill)){ |
|
| 2145 | + $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 2146 | + } |
|
| 2147 | + if(!empty($fill_i)){ |
|
| 2148 | + $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 2149 | + } |
|
| 2150 | + |
|
| 2151 | + |
|
| 2152 | + $prefix = $compatibility ? $compatibility . " " : ""; |
|
| 2153 | 2153 | |
| 2154 | 2154 | $transition = $is_var ? 'transition: color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out,filter 0.15s ease-in-out;' : ''; |
| 2155 | - // darken |
|
| 2156 | - $darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 2157 | - $darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 2158 | - $darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 2155 | + // darken |
|
| 2156 | + $darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 2157 | + $darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 2158 | + $darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 2159 | 2159 | |
| 2160 | - // lighten |
|
| 2161 | - $lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 2160 | + // lighten |
|
| 2161 | + $lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 2162 | 2162 | |
| 2163 | - // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 2164 | - $op_25 = $color_code."40"; // 25% opacity |
|
| 2163 | + // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 2164 | + $op_25 = $color_code."40"; // 25% opacity |
|
| 2165 | 2165 | |
| 2166 | 2166 | |
| 2167 | - // button states |
|
| 2168 | - $output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : ''; |
|
| 2169 | - $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 2167 | + // button states |
|
| 2168 | + $output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : ''; |
|
| 2169 | + $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 2170 | 2170 | // $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: #000; border-color: #000;} "; |
| 2171 | - $output .= $prefix ." .btn-outline-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-{$type}.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2172 | - $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active, $prefix .btn-{$type}:not(:disabled):not(.disabled).active, .show>$prefix .btn-{$type}.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
| 2173 | - $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-{$type}.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2171 | + $output .= $prefix ." .btn-outline-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-{$type}.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2172 | + $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active, $prefix .btn-{$type}:not(:disabled):not(.disabled).active, .show>$prefix .btn-{$type}.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
| 2173 | + $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-{$type}.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2174 | 2174 | |
| 2175 | - if ( $type == 'primary' ) { |
|
| 2176 | - // dropdown's |
|
| 2177 | - $output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
| 2175 | + if ( $type == 'primary' ) { |
|
| 2176 | + // dropdown's |
|
| 2177 | + $output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
| 2178 | 2178 | |
| 2179 | - // input states |
|
| 2180 | - $output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2179 | + // input states |
|
| 2180 | + $output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2181 | 2181 | |
| 2182 | - // page link |
|
| 2183 | - $output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2184 | - } |
|
| 2182 | + // page link |
|
| 2183 | + $output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2184 | + } |
|
| 2185 | 2185 | |
| 2186 | - return $output; |
|
| 2187 | - } |
|
| 2186 | + return $output; |
|
| 2187 | + } |
|
| 2188 | 2188 | |
| 2189 | - /** |
|
| 2189 | + /** |
|
| 2190 | 2190 | * |
| 2191 | 2191 | * @deprecated 0.1.76 Use css_overwrite() |
| 2192 | 2192 | * |
| 2193 | - * @param $color_code |
|
| 2194 | - * @param $compatibility |
|
| 2195 | - * @param $use_variable |
|
| 2196 | - * |
|
| 2197 | - * @return string |
|
| 2198 | - */ |
|
| 2199 | - public static function css_primary($color_code,$compatibility, $use_variable = false){ |
|
| 2193 | + * @param $color_code |
|
| 2194 | + * @param $compatibility |
|
| 2195 | + * @param $use_variable |
|
| 2196 | + * |
|
| 2197 | + * @return string |
|
| 2198 | + */ |
|
| 2199 | + public static function css_primary($color_code,$compatibility, $use_variable = false){ |
|
| 2200 | 2200 | |
| 2201 | 2201 | if(!$use_variable){ |
| 2202 | - $color_code = sanitize_hex_color($color_code); |
|
| 2203 | - if(!$color_code){return '';} |
|
| 2204 | - } |
|
| 2202 | + $color_code = sanitize_hex_color($color_code); |
|
| 2203 | + if(!$color_code){return '';} |
|
| 2204 | + } |
|
| 2205 | 2205 | |
| 2206 | - /** |
|
| 2207 | - * c = color, b = background color, o = border-color, f = fill |
|
| 2208 | - */ |
|
| 2209 | - $selectors = array( |
|
| 2210 | - 'a' => array('c'), |
|
| 2211 | - '.btn-primary' => array('b','o'), |
|
| 2212 | - '.btn-primary.disabled' => array('b','o'), |
|
| 2213 | - '.btn-primary:disabled' => array('b','o'), |
|
| 2214 | - '.btn-outline-primary' => array('c','o'), |
|
| 2215 | - '.btn-outline-primary:hover' => array('b','o'), |
|
| 2216 | - '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
| 2217 | - '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
| 2218 | - '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
|
| 2219 | - '.btn-link' => array('c'), |
|
| 2220 | - '.dropdown-item.active' => array('b'), |
|
| 2221 | - '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
|
| 2222 | - '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
|
| 2206 | + /** |
|
| 2207 | + * c = color, b = background color, o = border-color, f = fill |
|
| 2208 | + */ |
|
| 2209 | + $selectors = array( |
|
| 2210 | + 'a' => array('c'), |
|
| 2211 | + '.btn-primary' => array('b','o'), |
|
| 2212 | + '.btn-primary.disabled' => array('b','o'), |
|
| 2213 | + '.btn-primary:disabled' => array('b','o'), |
|
| 2214 | + '.btn-outline-primary' => array('c','o'), |
|
| 2215 | + '.btn-outline-primary:hover' => array('b','o'), |
|
| 2216 | + '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
| 2217 | + '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
| 2218 | + '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
|
| 2219 | + '.btn-link' => array('c'), |
|
| 2220 | + '.dropdown-item.active' => array('b'), |
|
| 2221 | + '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
|
| 2222 | + '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
|
| 2223 | 2223 | // '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules... |
| 2224 | 2224 | // '.custom-range::-moz-range-thumb' => array('b'), |
| 2225 | 2225 | // '.custom-range::-ms-thumb' => array('b'), |
| 2226 | - '.nav-pills .nav-link.active' => array('b'), |
|
| 2227 | - '.nav-pills .show>.nav-link' => array('b'), |
|
| 2228 | - '.page-link' => array('c'), |
|
| 2229 | - '.page-item.active .page-link' => array('b','o'), |
|
| 2230 | - '.badge-primary' => array('b'), |
|
| 2231 | - '.alert-primary' => array('b','o'), |
|
| 2232 | - '.progress-bar' => array('b'), |
|
| 2233 | - '.list-group-item.active' => array('b','o'), |
|
| 2234 | - '.bg-primary' => array('b','f'), |
|
| 2235 | - '.btn-link.btn-primary' => array('c'), |
|
| 2236 | - '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
|
| 2237 | - ); |
|
| 2238 | - |
|
| 2239 | - $important_selectors = array( |
|
| 2240 | - '.bg-primary' => array('b','f'), |
|
| 2241 | - '.border-primary' => array('o'), |
|
| 2242 | - '.text-primary' => array('c'), |
|
| 2243 | - ); |
|
| 2244 | - |
|
| 2245 | - $color = array(); |
|
| 2246 | - $color_i = array(); |
|
| 2247 | - $background = array(); |
|
| 2248 | - $background_i = array(); |
|
| 2249 | - $border = array(); |
|
| 2250 | - $border_i = array(); |
|
| 2251 | - $fill = array(); |
|
| 2252 | - $fill_i = array(); |
|
| 2253 | - |
|
| 2254 | - $output = ''; |
|
| 2255 | - |
|
| 2256 | - // build rules into each type |
|
| 2257 | - foreach($selectors as $selector => $types){ |
|
| 2258 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 2259 | - $types = array_combine($types,$types); |
|
| 2260 | - if(isset($types['c'])){$color[] = $selector;} |
|
| 2261 | - if(isset($types['b'])){$background[] = $selector;} |
|
| 2262 | - if(isset($types['o'])){$border[] = $selector;} |
|
| 2263 | - if(isset($types['f'])){$fill[] = $selector;} |
|
| 2264 | - } |
|
| 2265 | - |
|
| 2266 | - // build rules into each type |
|
| 2267 | - foreach($important_selectors as $selector => $types){ |
|
| 2268 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 2269 | - $types = array_combine($types,$types); |
|
| 2270 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
| 2271 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
| 2272 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
| 2273 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 2274 | - } |
|
| 2275 | - |
|
| 2276 | - // add any color rules |
|
| 2277 | - if(!empty($color)){ |
|
| 2278 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 2279 | - } |
|
| 2280 | - if(!empty($color_i)){ |
|
| 2281 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 2282 | - } |
|
| 2283 | - |
|
| 2284 | - // add any background color rules |
|
| 2285 | - if(!empty($background)){ |
|
| 2286 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 2287 | - } |
|
| 2288 | - if(!empty($background_i)){ |
|
| 2289 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 2290 | - } |
|
| 2291 | - |
|
| 2292 | - // add any border color rules |
|
| 2293 | - if(!empty($border)){ |
|
| 2294 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 2295 | - } |
|
| 2296 | - if(!empty($border_i)){ |
|
| 2297 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 2298 | - } |
|
| 2299 | - |
|
| 2300 | - // add any fill color rules |
|
| 2301 | - if(!empty($fill)){ |
|
| 2302 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 2303 | - } |
|
| 2304 | - if(!empty($fill_i)){ |
|
| 2305 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 2306 | - } |
|
| 2307 | - |
|
| 2308 | - |
|
| 2309 | - $prefix = $compatibility ? ".bsui " : ""; |
|
| 2310 | - |
|
| 2311 | - // darken |
|
| 2312 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 2313 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 2314 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 2315 | - |
|
| 2316 | - // lighten |
|
| 2317 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 2318 | - |
|
| 2319 | - // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 2320 | - $op_25 = $color_code."40"; // 25% opacity |
|
| 2321 | - |
|
| 2322 | - |
|
| 2323 | - // button states |
|
| 2324 | - $output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 2325 | - $output .= $prefix ." .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2326 | - $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
| 2327 | - $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2328 | - |
|
| 2329 | - |
|
| 2330 | - // dropdown's |
|
| 2331 | - $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
| 2332 | - |
|
| 2333 | - |
|
| 2334 | - // input states |
|
| 2335 | - $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2336 | - |
|
| 2337 | - // page link |
|
| 2338 | - $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2339 | - |
|
| 2340 | - return $output; |
|
| 2341 | - } |
|
| 2226 | + '.nav-pills .nav-link.active' => array('b'), |
|
| 2227 | + '.nav-pills .show>.nav-link' => array('b'), |
|
| 2228 | + '.page-link' => array('c'), |
|
| 2229 | + '.page-item.active .page-link' => array('b','o'), |
|
| 2230 | + '.badge-primary' => array('b'), |
|
| 2231 | + '.alert-primary' => array('b','o'), |
|
| 2232 | + '.progress-bar' => array('b'), |
|
| 2233 | + '.list-group-item.active' => array('b','o'), |
|
| 2234 | + '.bg-primary' => array('b','f'), |
|
| 2235 | + '.btn-link.btn-primary' => array('c'), |
|
| 2236 | + '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
|
| 2237 | + ); |
|
| 2342 | 2238 | |
| 2343 | - /** |
|
| 2239 | + $important_selectors = array( |
|
| 2240 | + '.bg-primary' => array('b','f'), |
|
| 2241 | + '.border-primary' => array('o'), |
|
| 2242 | + '.text-primary' => array('c'), |
|
| 2243 | + ); |
|
| 2244 | + |
|
| 2245 | + $color = array(); |
|
| 2246 | + $color_i = array(); |
|
| 2247 | + $background = array(); |
|
| 2248 | + $background_i = array(); |
|
| 2249 | + $border = array(); |
|
| 2250 | + $border_i = array(); |
|
| 2251 | + $fill = array(); |
|
| 2252 | + $fill_i = array(); |
|
| 2253 | + |
|
| 2254 | + $output = ''; |
|
| 2255 | + |
|
| 2256 | + // build rules into each type |
|
| 2257 | + foreach($selectors as $selector => $types){ |
|
| 2258 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 2259 | + $types = array_combine($types,$types); |
|
| 2260 | + if(isset($types['c'])){$color[] = $selector;} |
|
| 2261 | + if(isset($types['b'])){$background[] = $selector;} |
|
| 2262 | + if(isset($types['o'])){$border[] = $selector;} |
|
| 2263 | + if(isset($types['f'])){$fill[] = $selector;} |
|
| 2264 | + } |
|
| 2265 | + |
|
| 2266 | + // build rules into each type |
|
| 2267 | + foreach($important_selectors as $selector => $types){ |
|
| 2268 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 2269 | + $types = array_combine($types,$types); |
|
| 2270 | + if(isset($types['c'])){$color_i[] = $selector;} |
|
| 2271 | + if(isset($types['b'])){$background_i[] = $selector;} |
|
| 2272 | + if(isset($types['o'])){$border_i[] = $selector;} |
|
| 2273 | + if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 2274 | + } |
|
| 2275 | + |
|
| 2276 | + // add any color rules |
|
| 2277 | + if(!empty($color)){ |
|
| 2278 | + $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 2279 | + } |
|
| 2280 | + if(!empty($color_i)){ |
|
| 2281 | + $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 2282 | + } |
|
| 2283 | + |
|
| 2284 | + // add any background color rules |
|
| 2285 | + if(!empty($background)){ |
|
| 2286 | + $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 2287 | + } |
|
| 2288 | + if(!empty($background_i)){ |
|
| 2289 | + $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 2290 | + } |
|
| 2291 | + |
|
| 2292 | + // add any border color rules |
|
| 2293 | + if(!empty($border)){ |
|
| 2294 | + $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 2295 | + } |
|
| 2296 | + if(!empty($border_i)){ |
|
| 2297 | + $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 2298 | + } |
|
| 2299 | + |
|
| 2300 | + // add any fill color rules |
|
| 2301 | + if(!empty($fill)){ |
|
| 2302 | + $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 2303 | + } |
|
| 2304 | + if(!empty($fill_i)){ |
|
| 2305 | + $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 2306 | + } |
|
| 2307 | + |
|
| 2308 | + |
|
| 2309 | + $prefix = $compatibility ? ".bsui " : ""; |
|
| 2310 | + |
|
| 2311 | + // darken |
|
| 2312 | + $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 2313 | + $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 2314 | + $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 2315 | + |
|
| 2316 | + // lighten |
|
| 2317 | + $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 2318 | + |
|
| 2319 | + // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 2320 | + $op_25 = $color_code."40"; // 25% opacity |
|
| 2321 | + |
|
| 2322 | + |
|
| 2323 | + // button states |
|
| 2324 | + $output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 2325 | + $output .= $prefix ." .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2326 | + $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
| 2327 | + $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2328 | + |
|
| 2329 | + |
|
| 2330 | + // dropdown's |
|
| 2331 | + $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
| 2332 | + |
|
| 2333 | + |
|
| 2334 | + // input states |
|
| 2335 | + $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2336 | + |
|
| 2337 | + // page link |
|
| 2338 | + $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2339 | + |
|
| 2340 | + return $output; |
|
| 2341 | + } |
|
| 2342 | + |
|
| 2343 | + /** |
|
| 2344 | 2344 | * |
| 2345 | 2345 | * @deprecated 0.1.76 Use css_overwrite() |
| 2346 | 2346 | * |
| 2347 | - * @param $color_code |
|
| 2348 | - * @param $compatibility |
|
| 2349 | - * |
|
| 2350 | - * @return string |
|
| 2351 | - */ |
|
| 2352 | - public static function css_secondary($color_code,$compatibility){; |
|
| 2353 | - $color_code = sanitize_hex_color($color_code); |
|
| 2354 | - if(!$color_code){return '';} |
|
| 2355 | - /** |
|
| 2356 | - * c = color, b = background color, o = border-color, f = fill |
|
| 2357 | - */ |
|
| 2358 | - $selectors = array( |
|
| 2359 | - '.btn-secondary' => array('b','o'), |
|
| 2360 | - '.btn-secondary.disabled' => array('b','o'), |
|
| 2361 | - '.btn-secondary:disabled' => array('b','o'), |
|
| 2362 | - '.btn-outline-secondary' => array('c','o'), |
|
| 2363 | - '.btn-outline-secondary:hover' => array('b','o'), |
|
| 2364 | - '.btn-outline-secondary.disabled' => array('c'), |
|
| 2365 | - '.btn-outline-secondary:disabled' => array('c'), |
|
| 2366 | - '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
| 2367 | - '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
| 2368 | - '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
|
| 2369 | - '.badge-secondary' => array('b'), |
|
| 2370 | - '.alert-secondary' => array('b','o'), |
|
| 2371 | - '.btn-link.btn-secondary' => array('c'), |
|
| 2372 | - ); |
|
| 2373 | - |
|
| 2374 | - $important_selectors = array( |
|
| 2375 | - '.bg-secondary' => array('b','f'), |
|
| 2376 | - '.border-secondary' => array('o'), |
|
| 2377 | - '.text-secondary' => array('c'), |
|
| 2378 | - ); |
|
| 2379 | - |
|
| 2380 | - $color = array(); |
|
| 2381 | - $color_i = array(); |
|
| 2382 | - $background = array(); |
|
| 2383 | - $background_i = array(); |
|
| 2384 | - $border = array(); |
|
| 2385 | - $border_i = array(); |
|
| 2386 | - $fill = array(); |
|
| 2387 | - $fill_i = array(); |
|
| 2388 | - |
|
| 2389 | - $output = ''; |
|
| 2390 | - |
|
| 2391 | - // build rules into each type |
|
| 2392 | - foreach($selectors as $selector => $types){ |
|
| 2393 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 2394 | - $types = array_combine($types,$types); |
|
| 2395 | - if(isset($types['c'])){$color[] = $selector;} |
|
| 2396 | - if(isset($types['b'])){$background[] = $selector;} |
|
| 2397 | - if(isset($types['o'])){$border[] = $selector;} |
|
| 2398 | - if(isset($types['f'])){$fill[] = $selector;} |
|
| 2399 | - } |
|
| 2400 | - |
|
| 2401 | - // build rules into each type |
|
| 2402 | - foreach($important_selectors as $selector => $types){ |
|
| 2403 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 2404 | - $types = array_combine($types,$types); |
|
| 2405 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
| 2406 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
| 2407 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
| 2408 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 2409 | - } |
|
| 2410 | - |
|
| 2411 | - // add any color rules |
|
| 2412 | - if(!empty($color)){ |
|
| 2413 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 2414 | - } |
|
| 2415 | - if(!empty($color_i)){ |
|
| 2416 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 2417 | - } |
|
| 2418 | - |
|
| 2419 | - // add any background color rules |
|
| 2420 | - if(!empty($background)){ |
|
| 2421 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 2422 | - } |
|
| 2423 | - if(!empty($background_i)){ |
|
| 2424 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 2425 | - } |
|
| 2426 | - |
|
| 2427 | - // add any border color rules |
|
| 2428 | - if(!empty($border)){ |
|
| 2429 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 2430 | - } |
|
| 2431 | - if(!empty($border_i)){ |
|
| 2432 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 2433 | - } |
|
| 2434 | - |
|
| 2435 | - // add any fill color rules |
|
| 2436 | - if(!empty($fill)){ |
|
| 2437 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 2438 | - } |
|
| 2439 | - if(!empty($fill_i)){ |
|
| 2440 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 2441 | - } |
|
| 2442 | - |
|
| 2443 | - |
|
| 2444 | - $prefix = $compatibility ? ".bsui " : ""; |
|
| 2445 | - |
|
| 2446 | - // darken |
|
| 2447 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 2448 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 2449 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 2450 | - |
|
| 2451 | - // lighten |
|
| 2452 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 2453 | - |
|
| 2454 | - // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 2455 | - $op_25 = $color_code."40"; // 25% opacity |
|
| 2456 | - |
|
| 2457 | - |
|
| 2458 | - // button states |
|
| 2459 | - $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 2460 | - $output .= $prefix ." .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2461 | - $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
| 2462 | - $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2463 | - |
|
| 2464 | - |
|
| 2465 | - return $output; |
|
| 2466 | - } |
|
| 2347 | + * @param $color_code |
|
| 2348 | + * @param $compatibility |
|
| 2349 | + * |
|
| 2350 | + * @return string |
|
| 2351 | + */ |
|
| 2352 | + public static function css_secondary($color_code,$compatibility){; |
|
| 2353 | + $color_code = sanitize_hex_color($color_code); |
|
| 2354 | + if(!$color_code){return '';} |
|
| 2355 | + /** |
|
| 2356 | + * c = color, b = background color, o = border-color, f = fill |
|
| 2357 | + */ |
|
| 2358 | + $selectors = array( |
|
| 2359 | + '.btn-secondary' => array('b','o'), |
|
| 2360 | + '.btn-secondary.disabled' => array('b','o'), |
|
| 2361 | + '.btn-secondary:disabled' => array('b','o'), |
|
| 2362 | + '.btn-outline-secondary' => array('c','o'), |
|
| 2363 | + '.btn-outline-secondary:hover' => array('b','o'), |
|
| 2364 | + '.btn-outline-secondary.disabled' => array('c'), |
|
| 2365 | + '.btn-outline-secondary:disabled' => array('c'), |
|
| 2366 | + '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
| 2367 | + '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
| 2368 | + '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
|
| 2369 | + '.badge-secondary' => array('b'), |
|
| 2370 | + '.alert-secondary' => array('b','o'), |
|
| 2371 | + '.btn-link.btn-secondary' => array('c'), |
|
| 2372 | + ); |
|
| 2467 | 2373 | |
| 2468 | - /** |
|
| 2469 | - * Increases or decreases the brightness of a color by a percentage of the current brightness. |
|
| 2470 | - * |
|
| 2471 | - * @param string $hexCode Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF` |
|
| 2472 | - * @param float $adjustPercent A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker. |
|
| 2473 | - * |
|
| 2474 | - * @return string |
|
| 2475 | - */ |
|
| 2476 | - public static function css_hex_lighten_darken($hexCode, $adjustPercent) { |
|
| 2477 | - $hexCode = ltrim($hexCode, '#'); |
|
| 2374 | + $important_selectors = array( |
|
| 2375 | + '.bg-secondary' => array('b','f'), |
|
| 2376 | + '.border-secondary' => array('o'), |
|
| 2377 | + '.text-secondary' => array('c'), |
|
| 2378 | + ); |
|
| 2478 | 2379 | |
| 2479 | - if (strlen($hexCode) == 3) { |
|
| 2480 | - $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2]; |
|
| 2481 | - } |
|
| 2380 | + $color = array(); |
|
| 2381 | + $color_i = array(); |
|
| 2382 | + $background = array(); |
|
| 2383 | + $background_i = array(); |
|
| 2384 | + $border = array(); |
|
| 2385 | + $border_i = array(); |
|
| 2386 | + $fill = array(); |
|
| 2387 | + $fill_i = array(); |
|
| 2388 | + |
|
| 2389 | + $output = ''; |
|
| 2390 | + |
|
| 2391 | + // build rules into each type |
|
| 2392 | + foreach($selectors as $selector => $types){ |
|
| 2393 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 2394 | + $types = array_combine($types,$types); |
|
| 2395 | + if(isset($types['c'])){$color[] = $selector;} |
|
| 2396 | + if(isset($types['b'])){$background[] = $selector;} |
|
| 2397 | + if(isset($types['o'])){$border[] = $selector;} |
|
| 2398 | + if(isset($types['f'])){$fill[] = $selector;} |
|
| 2399 | + } |
|
| 2482 | 2400 | |
| 2483 | - $hexCode = array_map('hexdec', str_split($hexCode, 2)); |
|
| 2401 | + // build rules into each type |
|
| 2402 | + foreach($important_selectors as $selector => $types){ |
|
| 2403 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 2404 | + $types = array_combine($types,$types); |
|
| 2405 | + if(isset($types['c'])){$color_i[] = $selector;} |
|
| 2406 | + if(isset($types['b'])){$background_i[] = $selector;} |
|
| 2407 | + if(isset($types['o'])){$border_i[] = $selector;} |
|
| 2408 | + if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 2409 | + } |
|
| 2484 | 2410 | |
| 2485 | - foreach ($hexCode as & $color) { |
|
| 2486 | - $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color; |
|
| 2487 | - $adjustAmount = ceil($adjustableLimit * $adjustPercent); |
|
| 2411 | + // add any color rules |
|
| 2412 | + if(!empty($color)){ |
|
| 2413 | + $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 2414 | + } |
|
| 2415 | + if(!empty($color_i)){ |
|
| 2416 | + $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 2417 | + } |
|
| 2488 | 2418 | |
| 2489 | - $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT); |
|
| 2490 | - } |
|
| 2419 | + // add any background color rules |
|
| 2420 | + if(!empty($background)){ |
|
| 2421 | + $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 2422 | + } |
|
| 2423 | + if(!empty($background_i)){ |
|
| 2424 | + $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 2425 | + } |
|
| 2491 | 2426 | |
| 2492 | - return '#' . implode($hexCode); |
|
| 2493 | - } |
|
| 2427 | + // add any border color rules |
|
| 2428 | + if(!empty($border)){ |
|
| 2429 | + $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 2430 | + } |
|
| 2431 | + if(!empty($border_i)){ |
|
| 2432 | + $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 2433 | + } |
|
| 2494 | 2434 | |
| 2495 | - /** |
|
| 2496 | - * Check if we should display examples. |
|
| 2497 | - */ |
|
| 2498 | - public function maybe_show_examples(){ |
|
| 2499 | - if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
| 2500 | - echo "<head>"; |
|
| 2501 | - wp_head(); |
|
| 2502 | - echo "</head>"; |
|
| 2503 | - echo "<body>"; |
|
| 2504 | - echo $this->get_examples(); |
|
| 2505 | - echo "</body>"; |
|
| 2506 | - exit; |
|
| 2507 | - } |
|
| 2508 | - } |
|
| 2435 | + // add any fill color rules |
|
| 2436 | + if(!empty($fill)){ |
|
| 2437 | + $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 2438 | + } |
|
| 2439 | + if(!empty($fill_i)){ |
|
| 2440 | + $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 2441 | + } |
|
| 2509 | 2442 | |
| 2510 | - /** |
|
| 2511 | - * Get developer examples. |
|
| 2512 | - * |
|
| 2513 | - * @return string |
|
| 2514 | - */ |
|
| 2515 | - public function get_examples(){ |
|
| 2516 | - $output = ''; |
|
| 2517 | - |
|
| 2518 | - |
|
| 2519 | - // open form |
|
| 2520 | - $output .= "<form class='p-5 m-5 border rounded'>"; |
|
| 2521 | - |
|
| 2522 | - // input example |
|
| 2523 | - $output .= aui()->input(array( |
|
| 2524 | - 'type' => 'text', |
|
| 2525 | - 'id' => 'text-example', |
|
| 2526 | - 'name' => 'text-example', |
|
| 2527 | - 'placeholder' => 'text placeholder', |
|
| 2528 | - 'title' => 'Text input example', |
|
| 2529 | - 'value' => '', |
|
| 2530 | - 'required' => false, |
|
| 2531 | - 'help_text' => 'help text', |
|
| 2532 | - 'label' => 'Text input example label' |
|
| 2533 | - )); |
|
| 2534 | - |
|
| 2535 | - // input example |
|
| 2536 | - $output .= aui()->input(array( |
|
| 2537 | - 'type' => 'url', |
|
| 2538 | - 'id' => 'text-example2', |
|
| 2539 | - 'name' => 'text-example', |
|
| 2540 | - 'placeholder' => 'url placeholder', |
|
| 2541 | - 'title' => 'Text input example', |
|
| 2542 | - 'value' => '', |
|
| 2543 | - 'required' => false, |
|
| 2544 | - 'help_text' => 'help text', |
|
| 2545 | - 'label' => 'Text input example label' |
|
| 2546 | - )); |
|
| 2547 | - |
|
| 2548 | - // checkbox example |
|
| 2549 | - $output .= aui()->input(array( |
|
| 2550 | - 'type' => 'checkbox', |
|
| 2551 | - 'id' => 'checkbox-example', |
|
| 2552 | - 'name' => 'checkbox-example', |
|
| 2553 | - 'placeholder' => 'checkbox-example', |
|
| 2554 | - 'title' => 'Checkbox example', |
|
| 2555 | - 'value' => '1', |
|
| 2556 | - 'checked' => true, |
|
| 2557 | - 'required' => false, |
|
| 2558 | - 'help_text' => 'help text', |
|
| 2559 | - 'label' => 'Checkbox checked' |
|
| 2560 | - )); |
|
| 2561 | - |
|
| 2562 | - // checkbox example |
|
| 2563 | - $output .= aui()->input(array( |
|
| 2564 | - 'type' => 'checkbox', |
|
| 2565 | - 'id' => 'checkbox-example2', |
|
| 2566 | - 'name' => 'checkbox-example2', |
|
| 2567 | - 'placeholder' => 'checkbox-example', |
|
| 2568 | - 'title' => 'Checkbox example', |
|
| 2569 | - 'value' => '1', |
|
| 2570 | - 'checked' => false, |
|
| 2571 | - 'required' => false, |
|
| 2572 | - 'help_text' => 'help text', |
|
| 2573 | - 'label' => 'Checkbox un-checked' |
|
| 2574 | - )); |
|
| 2575 | - |
|
| 2576 | - // switch example |
|
| 2577 | - $output .= aui()->input(array( |
|
| 2578 | - 'type' => 'checkbox', |
|
| 2579 | - 'id' => 'switch-example', |
|
| 2580 | - 'name' => 'switch-example', |
|
| 2581 | - 'placeholder' => 'checkbox-example', |
|
| 2582 | - 'title' => 'Switch example', |
|
| 2583 | - 'value' => '1', |
|
| 2584 | - 'checked' => true, |
|
| 2585 | - 'switch' => true, |
|
| 2586 | - 'required' => false, |
|
| 2587 | - 'help_text' => 'help text', |
|
| 2588 | - 'label' => 'Switch on' |
|
| 2589 | - )); |
|
| 2590 | - |
|
| 2591 | - // switch example |
|
| 2592 | - $output .= aui()->input(array( |
|
| 2593 | - 'type' => 'checkbox', |
|
| 2594 | - 'id' => 'switch-example2', |
|
| 2595 | - 'name' => 'switch-example2', |
|
| 2596 | - 'placeholder' => 'checkbox-example', |
|
| 2597 | - 'title' => 'Switch example', |
|
| 2598 | - 'value' => '1', |
|
| 2599 | - 'checked' => false, |
|
| 2600 | - 'switch' => true, |
|
| 2601 | - 'required' => false, |
|
| 2602 | - 'help_text' => 'help text', |
|
| 2603 | - 'label' => 'Switch off' |
|
| 2604 | - )); |
|
| 2605 | - |
|
| 2606 | - // close form |
|
| 2607 | - $output .= "</form>"; |
|
| 2608 | - |
|
| 2609 | - return $output; |
|
| 2610 | - } |
|
| 2611 | 2443 | |
| 2612 | - /** |
|
| 2613 | - * Calendar params. |
|
| 2614 | - * |
|
| 2615 | - * @since 0.1.44 |
|
| 2616 | - * |
|
| 2617 | - * @return array Calendar params. |
|
| 2618 | - */ |
|
| 2619 | - public static function calendar_params() { |
|
| 2620 | - $params = array( |
|
| 2621 | - 'month_long_1' => __( 'January', 'aui' ), |
|
| 2622 | - 'month_long_2' => __( 'February', 'aui' ), |
|
| 2623 | - 'month_long_3' => __( 'March', 'aui' ), |
|
| 2624 | - 'month_long_4' => __( 'April', 'aui' ), |
|
| 2625 | - 'month_long_5' => __( 'May', 'aui' ), |
|
| 2626 | - 'month_long_6' => __( 'June', 'aui' ), |
|
| 2627 | - 'month_long_7' => __( 'July', 'aui' ), |
|
| 2628 | - 'month_long_8' => __( 'August', 'aui' ), |
|
| 2629 | - 'month_long_9' => __( 'September', 'aui' ), |
|
| 2630 | - 'month_long_10' => __( 'October', 'aui' ), |
|
| 2631 | - 'month_long_11' => __( 'November', 'aui' ), |
|
| 2632 | - 'month_long_12' => __( 'December', 'aui' ), |
|
| 2633 | - 'month_s_1' => _x( 'Jan', 'January abbreviation', 'aui' ), |
|
| 2634 | - 'month_s_2' => _x( 'Feb', 'February abbreviation', 'aui' ), |
|
| 2635 | - 'month_s_3' => _x( 'Mar', 'March abbreviation', 'aui' ), |
|
| 2636 | - 'month_s_4' => _x( 'Apr', 'April abbreviation', 'aui' ), |
|
| 2637 | - 'month_s_5' => _x( 'May', 'May abbreviation', 'aui' ), |
|
| 2638 | - 'month_s_6' => _x( 'Jun', 'June abbreviation', 'aui' ), |
|
| 2639 | - 'month_s_7' => _x( 'Jul', 'July abbreviation', 'aui' ), |
|
| 2640 | - 'month_s_8' => _x( 'Aug', 'August abbreviation', 'aui' ), |
|
| 2641 | - 'month_s_9' => _x( 'Sep', 'September abbreviation', 'aui' ), |
|
| 2642 | - 'month_s_10' => _x( 'Oct', 'October abbreviation', 'aui' ), |
|
| 2643 | - 'month_s_11' => _x( 'Nov', 'November abbreviation', 'aui' ), |
|
| 2644 | - 'month_s_12' => _x( 'Dec', 'December abbreviation', 'aui' ), |
|
| 2645 | - 'day_s1_1' => _x( 'S', 'Sunday initial', 'aui' ), |
|
| 2646 | - 'day_s1_2' => _x( 'M', 'Monday initial', 'aui' ), |
|
| 2647 | - 'day_s1_3' => _x( 'T', 'Tuesday initial', 'aui' ), |
|
| 2648 | - 'day_s1_4' => _x( 'W', 'Wednesday initial', 'aui' ), |
|
| 2649 | - 'day_s1_5' => _x( 'T', 'Friday initial', 'aui' ), |
|
| 2650 | - 'day_s1_6' => _x( 'F', 'Thursday initial', 'aui' ), |
|
| 2651 | - 'day_s1_7' => _x( 'S', 'Saturday initial', 'aui' ), |
|
| 2652 | - 'day_s2_1' => __( 'Su', 'aui' ), |
|
| 2653 | - 'day_s2_2' => __( 'Mo', 'aui' ), |
|
| 2654 | - 'day_s2_3' => __( 'Tu', 'aui' ), |
|
| 2655 | - 'day_s2_4' => __( 'We', 'aui' ), |
|
| 2656 | - 'day_s2_5' => __( 'Th', 'aui' ), |
|
| 2657 | - 'day_s2_6' => __( 'Fr', 'aui' ), |
|
| 2658 | - 'day_s2_7' => __( 'Sa', 'aui' ), |
|
| 2659 | - 'day_s3_1' => __( 'Sun', 'aui' ), |
|
| 2660 | - 'day_s3_2' => __( 'Mon', 'aui' ), |
|
| 2661 | - 'day_s3_3' => __( 'Tue', 'aui' ), |
|
| 2662 | - 'day_s3_4' => __( 'Wed', 'aui' ), |
|
| 2663 | - 'day_s3_5' => __( 'Thu', 'aui' ), |
|
| 2664 | - 'day_s3_6' => __( 'Fri', 'aui' ), |
|
| 2665 | - 'day_s3_7' => __( 'Sat', 'aui' ), |
|
| 2666 | - 'day_s5_1' => __( 'Sunday', 'aui' ), |
|
| 2667 | - 'day_s5_2' => __( 'Monday', 'aui' ), |
|
| 2668 | - 'day_s5_3' => __( 'Tuesday', 'aui' ), |
|
| 2669 | - 'day_s5_4' => __( 'Wednesday', 'aui' ), |
|
| 2670 | - 'day_s5_5' => __( 'Thursday', 'aui' ), |
|
| 2671 | - 'day_s5_6' => __( 'Friday', 'aui' ), |
|
| 2672 | - 'day_s5_7' => __( 'Saturday', 'aui' ), |
|
| 2673 | - 'am_lower' => __( 'am', 'aui' ), |
|
| 2674 | - 'pm_lower' => __( 'pm', 'aui' ), |
|
| 2675 | - 'am_upper' => __( 'AM', 'aui' ), |
|
| 2676 | - 'pm_upper' => __( 'PM', 'aui' ), |
|
| 2677 | - 'firstDayOfWeek' => (int) get_option( 'start_of_week' ), |
|
| 2678 | - 'time_24hr' => false, |
|
| 2679 | - 'year' => __( 'Year', 'aui' ), |
|
| 2680 | - 'hour' => __( 'Hour', 'aui' ), |
|
| 2681 | - 'minute' => __( 'Minute', 'aui' ), |
|
| 2682 | - 'weekAbbreviation' => __( 'Wk', 'aui' ), |
|
| 2683 | - 'rangeSeparator' => __( ' to ', 'aui' ), |
|
| 2684 | - 'scrollTitle' => __( 'Scroll to increment', 'aui' ), |
|
| 2685 | - 'toggleTitle' => __( 'Click to toggle', 'aui' ) |
|
| 2686 | - ); |
|
| 2687 | - |
|
| 2688 | - return apply_filters( 'ayecode_ui_calendar_params', $params ); |
|
| 2689 | - } |
|
| 2444 | + $prefix = $compatibility ? ".bsui " : ""; |
|
| 2690 | 2445 | |
| 2691 | - /** |
|
| 2692 | - * Flatpickr calendar localize. |
|
| 2693 | - * |
|
| 2694 | - * @since 0.1.44 |
|
| 2695 | - * |
|
| 2696 | - * @return string Calendar locale. |
|
| 2697 | - */ |
|
| 2698 | - public static function flatpickr_locale() { |
|
| 2699 | - $params = self::calendar_params(); |
|
| 2700 | - |
|
| 2701 | - if ( is_string( $params ) ) { |
|
| 2702 | - $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' ); |
|
| 2703 | - } else { |
|
| 2704 | - foreach ( (array) $params as $key => $value ) { |
|
| 2705 | - if ( ! is_scalar( $value ) ) { |
|
| 2706 | - continue; |
|
| 2707 | - } |
|
| 2446 | + // darken |
|
| 2447 | + $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 2448 | + $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 2449 | + $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 2708 | 2450 | |
| 2709 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2710 | - } |
|
| 2711 | - } |
|
| 2451 | + // lighten |
|
| 2452 | + $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 2453 | + |
|
| 2454 | + // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
| 2455 | + $op_25 = $color_code."40"; // 25% opacity |
|
| 2456 | + |
|
| 2457 | + |
|
| 2458 | + // button states |
|
| 2459 | + $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 2460 | + $output .= $prefix ." .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2461 | + $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
| 2462 | + $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2463 | + |
|
| 2464 | + |
|
| 2465 | + return $output; |
|
| 2466 | + } |
|
| 2467 | + |
|
| 2468 | + /** |
|
| 2469 | + * Increases or decreases the brightness of a color by a percentage of the current brightness. |
|
| 2470 | + * |
|
| 2471 | + * @param string $hexCode Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF` |
|
| 2472 | + * @param float $adjustPercent A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker. |
|
| 2473 | + * |
|
| 2474 | + * @return string |
|
| 2475 | + */ |
|
| 2476 | + public static function css_hex_lighten_darken($hexCode, $adjustPercent) { |
|
| 2477 | + $hexCode = ltrim($hexCode, '#'); |
|
| 2478 | + |
|
| 2479 | + if (strlen($hexCode) == 3) { |
|
| 2480 | + $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2]; |
|
| 2481 | + } |
|
| 2482 | + |
|
| 2483 | + $hexCode = array_map('hexdec', str_split($hexCode, 2)); |
|
| 2484 | + |
|
| 2485 | + foreach ($hexCode as & $color) { |
|
| 2486 | + $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color; |
|
| 2487 | + $adjustAmount = ceil($adjustableLimit * $adjustPercent); |
|
| 2488 | + |
|
| 2489 | + $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT); |
|
| 2490 | + } |
|
| 2491 | + |
|
| 2492 | + return '#' . implode($hexCode); |
|
| 2493 | + } |
|
| 2494 | + |
|
| 2495 | + /** |
|
| 2496 | + * Check if we should display examples. |
|
| 2497 | + */ |
|
| 2498 | + public function maybe_show_examples(){ |
|
| 2499 | + if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
| 2500 | + echo "<head>"; |
|
| 2501 | + wp_head(); |
|
| 2502 | + echo "</head>"; |
|
| 2503 | + echo "<body>"; |
|
| 2504 | + echo $this->get_examples(); |
|
| 2505 | + echo "</body>"; |
|
| 2506 | + exit; |
|
| 2507 | + } |
|
| 2508 | + } |
|
| 2509 | + |
|
| 2510 | + /** |
|
| 2511 | + * Get developer examples. |
|
| 2512 | + * |
|
| 2513 | + * @return string |
|
| 2514 | + */ |
|
| 2515 | + public function get_examples(){ |
|
| 2516 | + $output = ''; |
|
| 2517 | + |
|
| 2518 | + |
|
| 2519 | + // open form |
|
| 2520 | + $output .= "<form class='p-5 m-5 border rounded'>"; |
|
| 2521 | + |
|
| 2522 | + // input example |
|
| 2523 | + $output .= aui()->input(array( |
|
| 2524 | + 'type' => 'text', |
|
| 2525 | + 'id' => 'text-example', |
|
| 2526 | + 'name' => 'text-example', |
|
| 2527 | + 'placeholder' => 'text placeholder', |
|
| 2528 | + 'title' => 'Text input example', |
|
| 2529 | + 'value' => '', |
|
| 2530 | + 'required' => false, |
|
| 2531 | + 'help_text' => 'help text', |
|
| 2532 | + 'label' => 'Text input example label' |
|
| 2533 | + )); |
|
| 2534 | + |
|
| 2535 | + // input example |
|
| 2536 | + $output .= aui()->input(array( |
|
| 2537 | + 'type' => 'url', |
|
| 2538 | + 'id' => 'text-example2', |
|
| 2539 | + 'name' => 'text-example', |
|
| 2540 | + 'placeholder' => 'url placeholder', |
|
| 2541 | + 'title' => 'Text input example', |
|
| 2542 | + 'value' => '', |
|
| 2543 | + 'required' => false, |
|
| 2544 | + 'help_text' => 'help text', |
|
| 2545 | + 'label' => 'Text input example label' |
|
| 2546 | + )); |
|
| 2547 | + |
|
| 2548 | + // checkbox example |
|
| 2549 | + $output .= aui()->input(array( |
|
| 2550 | + 'type' => 'checkbox', |
|
| 2551 | + 'id' => 'checkbox-example', |
|
| 2552 | + 'name' => 'checkbox-example', |
|
| 2553 | + 'placeholder' => 'checkbox-example', |
|
| 2554 | + 'title' => 'Checkbox example', |
|
| 2555 | + 'value' => '1', |
|
| 2556 | + 'checked' => true, |
|
| 2557 | + 'required' => false, |
|
| 2558 | + 'help_text' => 'help text', |
|
| 2559 | + 'label' => 'Checkbox checked' |
|
| 2560 | + )); |
|
| 2561 | + |
|
| 2562 | + // checkbox example |
|
| 2563 | + $output .= aui()->input(array( |
|
| 2564 | + 'type' => 'checkbox', |
|
| 2565 | + 'id' => 'checkbox-example2', |
|
| 2566 | + 'name' => 'checkbox-example2', |
|
| 2567 | + 'placeholder' => 'checkbox-example', |
|
| 2568 | + 'title' => 'Checkbox example', |
|
| 2569 | + 'value' => '1', |
|
| 2570 | + 'checked' => false, |
|
| 2571 | + 'required' => false, |
|
| 2572 | + 'help_text' => 'help text', |
|
| 2573 | + 'label' => 'Checkbox un-checked' |
|
| 2574 | + )); |
|
| 2575 | + |
|
| 2576 | + // switch example |
|
| 2577 | + $output .= aui()->input(array( |
|
| 2578 | + 'type' => 'checkbox', |
|
| 2579 | + 'id' => 'switch-example', |
|
| 2580 | + 'name' => 'switch-example', |
|
| 2581 | + 'placeholder' => 'checkbox-example', |
|
| 2582 | + 'title' => 'Switch example', |
|
| 2583 | + 'value' => '1', |
|
| 2584 | + 'checked' => true, |
|
| 2585 | + 'switch' => true, |
|
| 2586 | + 'required' => false, |
|
| 2587 | + 'help_text' => 'help text', |
|
| 2588 | + 'label' => 'Switch on' |
|
| 2589 | + )); |
|
| 2590 | + |
|
| 2591 | + // switch example |
|
| 2592 | + $output .= aui()->input(array( |
|
| 2593 | + 'type' => 'checkbox', |
|
| 2594 | + 'id' => 'switch-example2', |
|
| 2595 | + 'name' => 'switch-example2', |
|
| 2596 | + 'placeholder' => 'checkbox-example', |
|
| 2597 | + 'title' => 'Switch example', |
|
| 2598 | + 'value' => '1', |
|
| 2599 | + 'checked' => false, |
|
| 2600 | + 'switch' => true, |
|
| 2601 | + 'required' => false, |
|
| 2602 | + 'help_text' => 'help text', |
|
| 2603 | + 'label' => 'Switch off' |
|
| 2604 | + )); |
|
| 2605 | + |
|
| 2606 | + // close form |
|
| 2607 | + $output .= "</form>"; |
|
| 2608 | + |
|
| 2609 | + return $output; |
|
| 2610 | + } |
|
| 2611 | + |
|
| 2612 | + /** |
|
| 2613 | + * Calendar params. |
|
| 2614 | + * |
|
| 2615 | + * @since 0.1.44 |
|
| 2616 | + * |
|
| 2617 | + * @return array Calendar params. |
|
| 2618 | + */ |
|
| 2619 | + public static function calendar_params() { |
|
| 2620 | + $params = array( |
|
| 2621 | + 'month_long_1' => __( 'January', 'aui' ), |
|
| 2622 | + 'month_long_2' => __( 'February', 'aui' ), |
|
| 2623 | + 'month_long_3' => __( 'March', 'aui' ), |
|
| 2624 | + 'month_long_4' => __( 'April', 'aui' ), |
|
| 2625 | + 'month_long_5' => __( 'May', 'aui' ), |
|
| 2626 | + 'month_long_6' => __( 'June', 'aui' ), |
|
| 2627 | + 'month_long_7' => __( 'July', 'aui' ), |
|
| 2628 | + 'month_long_8' => __( 'August', 'aui' ), |
|
| 2629 | + 'month_long_9' => __( 'September', 'aui' ), |
|
| 2630 | + 'month_long_10' => __( 'October', 'aui' ), |
|
| 2631 | + 'month_long_11' => __( 'November', 'aui' ), |
|
| 2632 | + 'month_long_12' => __( 'December', 'aui' ), |
|
| 2633 | + 'month_s_1' => _x( 'Jan', 'January abbreviation', 'aui' ), |
|
| 2634 | + 'month_s_2' => _x( 'Feb', 'February abbreviation', 'aui' ), |
|
| 2635 | + 'month_s_3' => _x( 'Mar', 'March abbreviation', 'aui' ), |
|
| 2636 | + 'month_s_4' => _x( 'Apr', 'April abbreviation', 'aui' ), |
|
| 2637 | + 'month_s_5' => _x( 'May', 'May abbreviation', 'aui' ), |
|
| 2638 | + 'month_s_6' => _x( 'Jun', 'June abbreviation', 'aui' ), |
|
| 2639 | + 'month_s_7' => _x( 'Jul', 'July abbreviation', 'aui' ), |
|
| 2640 | + 'month_s_8' => _x( 'Aug', 'August abbreviation', 'aui' ), |
|
| 2641 | + 'month_s_9' => _x( 'Sep', 'September abbreviation', 'aui' ), |
|
| 2642 | + 'month_s_10' => _x( 'Oct', 'October abbreviation', 'aui' ), |
|
| 2643 | + 'month_s_11' => _x( 'Nov', 'November abbreviation', 'aui' ), |
|
| 2644 | + 'month_s_12' => _x( 'Dec', 'December abbreviation', 'aui' ), |
|
| 2645 | + 'day_s1_1' => _x( 'S', 'Sunday initial', 'aui' ), |
|
| 2646 | + 'day_s1_2' => _x( 'M', 'Monday initial', 'aui' ), |
|
| 2647 | + 'day_s1_3' => _x( 'T', 'Tuesday initial', 'aui' ), |
|
| 2648 | + 'day_s1_4' => _x( 'W', 'Wednesday initial', 'aui' ), |
|
| 2649 | + 'day_s1_5' => _x( 'T', 'Friday initial', 'aui' ), |
|
| 2650 | + 'day_s1_6' => _x( 'F', 'Thursday initial', 'aui' ), |
|
| 2651 | + 'day_s1_7' => _x( 'S', 'Saturday initial', 'aui' ), |
|
| 2652 | + 'day_s2_1' => __( 'Su', 'aui' ), |
|
| 2653 | + 'day_s2_2' => __( 'Mo', 'aui' ), |
|
| 2654 | + 'day_s2_3' => __( 'Tu', 'aui' ), |
|
| 2655 | + 'day_s2_4' => __( 'We', 'aui' ), |
|
| 2656 | + 'day_s2_5' => __( 'Th', 'aui' ), |
|
| 2657 | + 'day_s2_6' => __( 'Fr', 'aui' ), |
|
| 2658 | + 'day_s2_7' => __( 'Sa', 'aui' ), |
|
| 2659 | + 'day_s3_1' => __( 'Sun', 'aui' ), |
|
| 2660 | + 'day_s3_2' => __( 'Mon', 'aui' ), |
|
| 2661 | + 'day_s3_3' => __( 'Tue', 'aui' ), |
|
| 2662 | + 'day_s3_4' => __( 'Wed', 'aui' ), |
|
| 2663 | + 'day_s3_5' => __( 'Thu', 'aui' ), |
|
| 2664 | + 'day_s3_6' => __( 'Fri', 'aui' ), |
|
| 2665 | + 'day_s3_7' => __( 'Sat', 'aui' ), |
|
| 2666 | + 'day_s5_1' => __( 'Sunday', 'aui' ), |
|
| 2667 | + 'day_s5_2' => __( 'Monday', 'aui' ), |
|
| 2668 | + 'day_s5_3' => __( 'Tuesday', 'aui' ), |
|
| 2669 | + 'day_s5_4' => __( 'Wednesday', 'aui' ), |
|
| 2670 | + 'day_s5_5' => __( 'Thursday', 'aui' ), |
|
| 2671 | + 'day_s5_6' => __( 'Friday', 'aui' ), |
|
| 2672 | + 'day_s5_7' => __( 'Saturday', 'aui' ), |
|
| 2673 | + 'am_lower' => __( 'am', 'aui' ), |
|
| 2674 | + 'pm_lower' => __( 'pm', 'aui' ), |
|
| 2675 | + 'am_upper' => __( 'AM', 'aui' ), |
|
| 2676 | + 'pm_upper' => __( 'PM', 'aui' ), |
|
| 2677 | + 'firstDayOfWeek' => (int) get_option( 'start_of_week' ), |
|
| 2678 | + 'time_24hr' => false, |
|
| 2679 | + 'year' => __( 'Year', 'aui' ), |
|
| 2680 | + 'hour' => __( 'Hour', 'aui' ), |
|
| 2681 | + 'minute' => __( 'Minute', 'aui' ), |
|
| 2682 | + 'weekAbbreviation' => __( 'Wk', 'aui' ), |
|
| 2683 | + 'rangeSeparator' => __( ' to ', 'aui' ), |
|
| 2684 | + 'scrollTitle' => __( 'Scroll to increment', 'aui' ), |
|
| 2685 | + 'toggleTitle' => __( 'Click to toggle', 'aui' ) |
|
| 2686 | + ); |
|
| 2687 | + |
|
| 2688 | + return apply_filters( 'ayecode_ui_calendar_params', $params ); |
|
| 2689 | + } |
|
| 2690 | + |
|
| 2691 | + /** |
|
| 2692 | + * Flatpickr calendar localize. |
|
| 2693 | + * |
|
| 2694 | + * @since 0.1.44 |
|
| 2695 | + * |
|
| 2696 | + * @return string Calendar locale. |
|
| 2697 | + */ |
|
| 2698 | + public static function flatpickr_locale() { |
|
| 2699 | + $params = self::calendar_params(); |
|
| 2700 | + |
|
| 2701 | + if ( is_string( $params ) ) { |
|
| 2702 | + $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' ); |
|
| 2703 | + } else { |
|
| 2704 | + foreach ( (array) $params as $key => $value ) { |
|
| 2705 | + if ( ! is_scalar( $value ) ) { |
|
| 2706 | + continue; |
|
| 2707 | + } |
|
| 2708 | + |
|
| 2709 | + $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2710 | + } |
|
| 2711 | + } |
|
| 2712 | 2712 | |
| 2713 | - $day_s3 = array(); |
|
| 2714 | - $day_s5 = array(); |
|
| 2713 | + $day_s3 = array(); |
|
| 2714 | + $day_s5 = array(); |
|
| 2715 | 2715 | |
| 2716 | - for ( $i = 1; $i <= 7; $i ++ ) { |
|
| 2717 | - $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
| 2718 | - $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
| 2719 | - } |
|
| 2716 | + for ( $i = 1; $i <= 7; $i ++ ) { |
|
| 2717 | + $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
| 2718 | + $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
| 2719 | + } |
|
| 2720 | 2720 | |
| 2721 | - $month_s = array(); |
|
| 2722 | - $month_long = array(); |
|
| 2721 | + $month_s = array(); |
|
| 2722 | + $month_long = array(); |
|
| 2723 | 2723 | |
| 2724 | - for ( $i = 1; $i <= 12; $i ++ ) { |
|
| 2725 | - $month_s[] = addslashes( $params[ 'month_s_' . $i ] ); |
|
| 2726 | - $month_long[] = addslashes( $params[ 'month_long_' . $i ] ); |
|
| 2727 | - } |
|
| 2724 | + for ( $i = 1; $i <= 12; $i ++ ) { |
|
| 2725 | + $month_s[] = addslashes( $params[ 'month_s_' . $i ] ); |
|
| 2726 | + $month_long[] = addslashes( $params[ 'month_long_' . $i ] ); |
|
| 2727 | + } |
|
| 2728 | 2728 | |
| 2729 | 2729 | ob_start(); |
| 2730 | 2730 | if ( 0 ) { ?><script><?php } ?> |
@@ -2766,189 +2766,189 @@ discard block |
||
| 2766 | 2766 | } |
| 2767 | 2767 | <?php if ( 0 ) { ?></script><?php } ?> |
| 2768 | 2768 | <?php |
| 2769 | - $locale = ob_get_clean(); |
|
| 2769 | + $locale = ob_get_clean(); |
|
| 2770 | 2770 | |
| 2771 | - return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) ); |
|
| 2772 | - } |
|
| 2771 | + return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) ); |
|
| 2772 | + } |
|
| 2773 | 2773 | |
| 2774 | - /** |
|
| 2775 | - * Select2 JS params. |
|
| 2776 | - * |
|
| 2777 | - * @since 0.1.44 |
|
| 2778 | - * |
|
| 2779 | - * @return array Select2 JS params. |
|
| 2780 | - */ |
|
| 2781 | - public static function select2_params() { |
|
| 2782 | - $params = array( |
|
| 2783 | - 'i18n_select_state_text' => esc_attr__( 'Select an option…', 'aui' ), |
|
| 2784 | - 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'aui' ), |
|
| 2785 | - 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'aui' ), |
|
| 2786 | - 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'aui' ), |
|
| 2787 | - 'i18n_input_too_short_n' => _x( 'Please enter %item% or more characters', 'enhanced select', 'aui' ), |
|
| 2788 | - 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'aui' ), |
|
| 2789 | - 'i18n_input_too_long_n' => _x( 'Please delete %item% characters', 'enhanced select', 'aui' ), |
|
| 2790 | - 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'aui' ), |
|
| 2791 | - 'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'aui' ), |
|
| 2792 | - 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'aui' ), |
|
| 2793 | - 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'aui' ) |
|
| 2794 | - ); |
|
| 2795 | - |
|
| 2796 | - return apply_filters( 'ayecode_ui_select2_params', $params ); |
|
| 2797 | - } |
|
| 2774 | + /** |
|
| 2775 | + * Select2 JS params. |
|
| 2776 | + * |
|
| 2777 | + * @since 0.1.44 |
|
| 2778 | + * |
|
| 2779 | + * @return array Select2 JS params. |
|
| 2780 | + */ |
|
| 2781 | + public static function select2_params() { |
|
| 2782 | + $params = array( |
|
| 2783 | + 'i18n_select_state_text' => esc_attr__( 'Select an option…', 'aui' ), |
|
| 2784 | + 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'aui' ), |
|
| 2785 | + 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'aui' ), |
|
| 2786 | + 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'aui' ), |
|
| 2787 | + 'i18n_input_too_short_n' => _x( 'Please enter %item% or more characters', 'enhanced select', 'aui' ), |
|
| 2788 | + 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'aui' ), |
|
| 2789 | + 'i18n_input_too_long_n' => _x( 'Please delete %item% characters', 'enhanced select', 'aui' ), |
|
| 2790 | + 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'aui' ), |
|
| 2791 | + 'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'aui' ), |
|
| 2792 | + 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'aui' ), |
|
| 2793 | + 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'aui' ) |
|
| 2794 | + ); |
|
| 2798 | 2795 | |
| 2799 | - /** |
|
| 2800 | - * Select2 JS localize. |
|
| 2801 | - * |
|
| 2802 | - * @since 0.1.44 |
|
| 2803 | - * |
|
| 2804 | - * @return string Select2 JS locale. |
|
| 2805 | - */ |
|
| 2806 | - public static function select2_locale() { |
|
| 2807 | - $params = self::select2_params(); |
|
| 2808 | - |
|
| 2809 | - foreach ( (array) $params as $key => $value ) { |
|
| 2810 | - if ( ! is_scalar( $value ) ) { |
|
| 2811 | - continue; |
|
| 2812 | - } |
|
| 2796 | + return apply_filters( 'ayecode_ui_select2_params', $params ); |
|
| 2797 | + } |
|
| 2813 | 2798 | |
| 2814 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2815 | - } |
|
| 2799 | + /** |
|
| 2800 | + * Select2 JS localize. |
|
| 2801 | + * |
|
| 2802 | + * @since 0.1.44 |
|
| 2803 | + * |
|
| 2804 | + * @return string Select2 JS locale. |
|
| 2805 | + */ |
|
| 2806 | + public static function select2_locale() { |
|
| 2807 | + $params = self::select2_params(); |
|
| 2808 | + |
|
| 2809 | + foreach ( (array) $params as $key => $value ) { |
|
| 2810 | + if ( ! is_scalar( $value ) ) { |
|
| 2811 | + continue; |
|
| 2812 | + } |
|
| 2816 | 2813 | |
| 2817 | - $locale = json_encode( $params ); |
|
| 2814 | + $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2815 | + } |
|
| 2818 | 2816 | |
| 2819 | - return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) ); |
|
| 2820 | - } |
|
| 2817 | + $locale = json_encode( $params ); |
|
| 2821 | 2818 | |
| 2822 | - /** |
|
| 2823 | - * Time ago JS localize. |
|
| 2824 | - * |
|
| 2825 | - * @since 0.1.47 |
|
| 2826 | - * |
|
| 2827 | - * @return string Time ago JS locale. |
|
| 2828 | - */ |
|
| 2829 | - public static function timeago_locale() { |
|
| 2830 | - $params = array( |
|
| 2831 | - 'prefix_ago' => '', |
|
| 2832 | - 'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'aui' ), |
|
| 2833 | - 'prefix_after' => _x( 'after', 'time ago', 'aui' ) . ' ', |
|
| 2834 | - 'suffix_after' => '', |
|
| 2835 | - 'seconds' => _x( 'less than a minute', 'time ago', 'aui' ), |
|
| 2836 | - 'minute' => _x( 'about a minute', 'time ago', 'aui' ), |
|
| 2837 | - 'minutes' => _x( '%d minutes', 'time ago', 'aui' ), |
|
| 2838 | - 'hour' => _x( 'about an hour', 'time ago', 'aui' ), |
|
| 2839 | - 'hours' => _x( 'about %d hours', 'time ago', 'aui' ), |
|
| 2840 | - 'day' => _x( 'a day', 'time ago', 'aui' ), |
|
| 2841 | - 'days' => _x( '%d days', 'time ago', 'aui' ), |
|
| 2842 | - 'month' => _x( 'about a month', 'time ago', 'aui' ), |
|
| 2843 | - 'months' => _x( '%d months', 'time ago', 'aui' ), |
|
| 2844 | - 'year' => _x( 'about a year', 'time ago', 'aui' ), |
|
| 2845 | - 'years' => _x( '%d years', 'time ago', 'aui' ), |
|
| 2846 | - ); |
|
| 2847 | - |
|
| 2848 | - $params = apply_filters( 'ayecode_ui_timeago_params', $params ); |
|
| 2849 | - |
|
| 2850 | - foreach ( (array) $params as $key => $value ) { |
|
| 2851 | - if ( ! is_scalar( $value ) ) { |
|
| 2852 | - continue; |
|
| 2853 | - } |
|
| 2819 | + return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) ); |
|
| 2820 | + } |
|
| 2854 | 2821 | |
| 2855 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2856 | - } |
|
| 2822 | + /** |
|
| 2823 | + * Time ago JS localize. |
|
| 2824 | + * |
|
| 2825 | + * @since 0.1.47 |
|
| 2826 | + * |
|
| 2827 | + * @return string Time ago JS locale. |
|
| 2828 | + */ |
|
| 2829 | + public static function timeago_locale() { |
|
| 2830 | + $params = array( |
|
| 2831 | + 'prefix_ago' => '', |
|
| 2832 | + 'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'aui' ), |
|
| 2833 | + 'prefix_after' => _x( 'after', 'time ago', 'aui' ) . ' ', |
|
| 2834 | + 'suffix_after' => '', |
|
| 2835 | + 'seconds' => _x( 'less than a minute', 'time ago', 'aui' ), |
|
| 2836 | + 'minute' => _x( 'about a minute', 'time ago', 'aui' ), |
|
| 2837 | + 'minutes' => _x( '%d minutes', 'time ago', 'aui' ), |
|
| 2838 | + 'hour' => _x( 'about an hour', 'time ago', 'aui' ), |
|
| 2839 | + 'hours' => _x( 'about %d hours', 'time ago', 'aui' ), |
|
| 2840 | + 'day' => _x( 'a day', 'time ago', 'aui' ), |
|
| 2841 | + 'days' => _x( '%d days', 'time ago', 'aui' ), |
|
| 2842 | + 'month' => _x( 'about a month', 'time ago', 'aui' ), |
|
| 2843 | + 'months' => _x( '%d months', 'time ago', 'aui' ), |
|
| 2844 | + 'year' => _x( 'about a year', 'time ago', 'aui' ), |
|
| 2845 | + 'years' => _x( '%d years', 'time ago', 'aui' ), |
|
| 2846 | + ); |
|
| 2857 | 2847 | |
| 2858 | - $locale = json_encode( $params ); |
|
| 2848 | + $params = apply_filters( 'ayecode_ui_timeago_params', $params ); |
|
| 2859 | 2849 | |
| 2860 | - return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) ); |
|
| 2861 | - } |
|
| 2850 | + foreach ( (array) $params as $key => $value ) { |
|
| 2851 | + if ( ! is_scalar( $value ) ) { |
|
| 2852 | + continue; |
|
| 2853 | + } |
|
| 2862 | 2854 | |
| 2863 | - /** |
|
| 2864 | - * JavaScript Minifier |
|
| 2865 | - * |
|
| 2866 | - * @param $input |
|
| 2867 | - * |
|
| 2868 | - * @return mixed |
|
| 2869 | - */ |
|
| 2870 | - public static function minify_js($input) { |
|
| 2871 | - if(trim($input) === "") return $input; |
|
| 2872 | - return preg_replace( |
|
| 2873 | - array( |
|
| 2874 | - // Remove comment(s) |
|
| 2875 | - '#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#', |
|
| 2876 | - // Remove white-space(s) outside the string and regex |
|
| 2877 | - '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s', |
|
| 2878 | - // Remove the last semicolon |
|
| 2879 | - '#;+\}#', |
|
| 2880 | - // Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}` |
|
| 2881 | - '#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i', |
|
| 2882 | - // --ibid. From `foo['bar']` to `foo.bar` |
|
| 2883 | - '#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i' |
|
| 2884 | - ), |
|
| 2885 | - array( |
|
| 2886 | - '$1', |
|
| 2887 | - '$1$2', |
|
| 2888 | - '}', |
|
| 2889 | - '$1$3', |
|
| 2890 | - '$1.$3' |
|
| 2891 | - ), |
|
| 2892 | - $input); |
|
| 2893 | - } |
|
| 2855 | + $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2856 | + } |
|
| 2894 | 2857 | |
| 2895 | - /** |
|
| 2896 | - * Minify CSS |
|
| 2897 | - * |
|
| 2898 | - * @param $input |
|
| 2899 | - * |
|
| 2900 | - * @return mixed |
|
| 2901 | - */ |
|
| 2902 | - public static function minify_css($input) { |
|
| 2903 | - if(trim($input) === "") return $input; |
|
| 2904 | - return preg_replace( |
|
| 2905 | - array( |
|
| 2906 | - // Remove comment(s) |
|
| 2907 | - '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s', |
|
| 2908 | - // Remove unused white-space(s) |
|
| 2909 | - '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si', |
|
| 2910 | - // Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0` |
|
| 2911 | - '#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si', |
|
| 2912 | - // Replace `:0 0 0 0` with `:0` |
|
| 2913 | - '#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i', |
|
| 2914 | - // Replace `background-position:0` with `background-position:0 0` |
|
| 2915 | - '#(background-position):0(?=[;\}])#si', |
|
| 2916 | - // Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space |
|
| 2917 | - '#(?<=[\s:,\-])0+\.(\d+)#s', |
|
| 2918 | - // Minify string value |
|
| 2919 | - '#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si', |
|
| 2920 | - '#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si', |
|
| 2921 | - // Minify HEX color code |
|
| 2922 | - '#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i', |
|
| 2923 | - // Replace `(border|outline):none` with `(border|outline):0` |
|
| 2924 | - '#(?<=[\{;])(border|outline):none(?=[;\}\!])#', |
|
| 2925 | - // Remove empty selector(s) |
|
| 2926 | - '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s' |
|
| 2927 | - ), |
|
| 2928 | - array( |
|
| 2929 | - '$1', |
|
| 2930 | - '$1$2$3$4$5$6$7', |
|
| 2931 | - '$1', |
|
| 2932 | - ':0', |
|
| 2933 | - '$1:0 0', |
|
| 2934 | - '.$1', |
|
| 2935 | - '$1$3', |
|
| 2936 | - '$1$2$4$5', |
|
| 2937 | - '$1$2$3', |
|
| 2938 | - '$1:0', |
|
| 2939 | - '$1$2' |
|
| 2940 | - ), |
|
| 2941 | - $input); |
|
| 2942 | - } |
|
| 2858 | + $locale = json_encode( $params ); |
|
| 2859 | + |
|
| 2860 | + return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) ); |
|
| 2861 | + } |
|
| 2943 | 2862 | |
| 2944 | - /** |
|
| 2945 | - * Get the conditional fields JavaScript. |
|
| 2946 | - * |
|
| 2947 | - * @return mixed |
|
| 2948 | - */ |
|
| 2949 | - public function conditional_fields_js() { |
|
| 2950 | - ob_start(); |
|
| 2951 | - ?> |
|
| 2863 | + /** |
|
| 2864 | + * JavaScript Minifier |
|
| 2865 | + * |
|
| 2866 | + * @param $input |
|
| 2867 | + * |
|
| 2868 | + * @return mixed |
|
| 2869 | + */ |
|
| 2870 | + public static function minify_js($input) { |
|
| 2871 | + if(trim($input) === "") return $input; |
|
| 2872 | + return preg_replace( |
|
| 2873 | + array( |
|
| 2874 | + // Remove comment(s) |
|
| 2875 | + '#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#', |
|
| 2876 | + // Remove white-space(s) outside the string and regex |
|
| 2877 | + '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s', |
|
| 2878 | + // Remove the last semicolon |
|
| 2879 | + '#;+\}#', |
|
| 2880 | + // Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}` |
|
| 2881 | + '#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i', |
|
| 2882 | + // --ibid. From `foo['bar']` to `foo.bar` |
|
| 2883 | + '#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i' |
|
| 2884 | + ), |
|
| 2885 | + array( |
|
| 2886 | + '$1', |
|
| 2887 | + '$1$2', |
|
| 2888 | + '}', |
|
| 2889 | + '$1$3', |
|
| 2890 | + '$1.$3' |
|
| 2891 | + ), |
|
| 2892 | + $input); |
|
| 2893 | + } |
|
| 2894 | + |
|
| 2895 | + /** |
|
| 2896 | + * Minify CSS |
|
| 2897 | + * |
|
| 2898 | + * @param $input |
|
| 2899 | + * |
|
| 2900 | + * @return mixed |
|
| 2901 | + */ |
|
| 2902 | + public static function minify_css($input) { |
|
| 2903 | + if(trim($input) === "") return $input; |
|
| 2904 | + return preg_replace( |
|
| 2905 | + array( |
|
| 2906 | + // Remove comment(s) |
|
| 2907 | + '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s', |
|
| 2908 | + // Remove unused white-space(s) |
|
| 2909 | + '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si', |
|
| 2910 | + // Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0` |
|
| 2911 | + '#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si', |
|
| 2912 | + // Replace `:0 0 0 0` with `:0` |
|
| 2913 | + '#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i', |
|
| 2914 | + // Replace `background-position:0` with `background-position:0 0` |
|
| 2915 | + '#(background-position):0(?=[;\}])#si', |
|
| 2916 | + // Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space |
|
| 2917 | + '#(?<=[\s:,\-])0+\.(\d+)#s', |
|
| 2918 | + // Minify string value |
|
| 2919 | + '#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si', |
|
| 2920 | + '#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si', |
|
| 2921 | + // Minify HEX color code |
|
| 2922 | + '#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i', |
|
| 2923 | + // Replace `(border|outline):none` with `(border|outline):0` |
|
| 2924 | + '#(?<=[\{;])(border|outline):none(?=[;\}\!])#', |
|
| 2925 | + // Remove empty selector(s) |
|
| 2926 | + '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s' |
|
| 2927 | + ), |
|
| 2928 | + array( |
|
| 2929 | + '$1', |
|
| 2930 | + '$1$2$3$4$5$6$7', |
|
| 2931 | + '$1', |
|
| 2932 | + ':0', |
|
| 2933 | + '$1:0 0', |
|
| 2934 | + '.$1', |
|
| 2935 | + '$1$3', |
|
| 2936 | + '$1$2$4$5', |
|
| 2937 | + '$1$2$3', |
|
| 2938 | + '$1:0', |
|
| 2939 | + '$1$2' |
|
| 2940 | + ), |
|
| 2941 | + $input); |
|
| 2942 | + } |
|
| 2943 | + |
|
| 2944 | + /** |
|
| 2945 | + * Get the conditional fields JavaScript. |
|
| 2946 | + * |
|
| 2947 | + * @return mixed |
|
| 2948 | + */ |
|
| 2949 | + public function conditional_fields_js() { |
|
| 2950 | + ob_start(); |
|
| 2951 | + ?> |
|
| 2952 | 2952 | <script> |
| 2953 | 2953 | /** |
| 2954 | 2954 | * Conditional Fields |
@@ -3451,14 +3451,14 @@ discard block |
||
| 3451 | 3451 | <?php do_action( 'aui_conditional_fields_js', $this ); ?> |
| 3452 | 3452 | </script> |
| 3453 | 3453 | <?php |
| 3454 | - $output = ob_get_clean(); |
|
| 3454 | + $output = ob_get_clean(); |
|
| 3455 | 3455 | |
| 3456 | - return str_replace( array( '<script>', '</script>' ), '', self::minify_js( $output ) ); |
|
| 3457 | - } |
|
| 3458 | - } |
|
| 3456 | + return str_replace( array( '<script>', '</script>' ), '', self::minify_js( $output ) ); |
|
| 3457 | + } |
|
| 3458 | + } |
|
| 3459 | 3459 | |
| 3460 | - /** |
|
| 3461 | - * Run the class if found. |
|
| 3462 | - */ |
|
| 3463 | - AyeCode_UI_Settings::instance(); |
|
| 3460 | + /** |
|
| 3461 | + * Run the class if found. |
|
| 3462 | + */ |
|
| 3463 | + AyeCode_UI_Settings::instance(); |
|
| 3464 | 3464 | } |
| 3465 | 3465 | \ No newline at end of file |
@@ -12,14 +12,14 @@ discard block |
||
| 12 | 12 | /** |
| 13 | 13 | * Bail if we are not in WP. |
| 14 | 14 | */ |
| 15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 15 | +if (!defined('ABSPATH')) { |
|
| 16 | 16 | exit; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * Only add if the class does not already exist. |
| 21 | 21 | */ |
| 22 | -if ( ! class_exists( 'AyeCode_UI_Settings' ) ) { |
|
| 22 | +if (!class_exists('AyeCode_UI_Settings')) { |
|
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | 25 | * A Class to be able to change settings for Font Awesome. |
@@ -99,27 +99,27 @@ discard block |
||
| 99 | 99 | * @return AyeCode_UI_Settings - Main instance. |
| 100 | 100 | */ |
| 101 | 101 | public static function instance() { |
| 102 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) { |
|
| 102 | + if (!isset(self::$instance) && !(self::$instance instanceof AyeCode_UI_Settings)) { |
|
| 103 | 103 | |
| 104 | 104 | self::$instance = new AyeCode_UI_Settings; |
| 105 | 105 | |
| 106 | - add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
| 106 | + add_action('init', array(self::$instance, 'init')); // set settings |
|
| 107 | 107 | |
| 108 | - if ( is_admin() ) { |
|
| 109 | - add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
|
| 110 | - add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
|
| 108 | + if (is_admin()) { |
|
| 109 | + add_action('admin_menu', array(self::$instance, 'menu_item')); |
|
| 110 | + add_action('admin_init', array(self::$instance, 'register_settings')); |
|
| 111 | 111 | |
| 112 | 112 | // Maybe show example page |
| 113 | - add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) ); |
|
| 113 | + add_action('template_redirect', array(self::$instance, 'maybe_show_examples')); |
|
| 114 | 114 | |
| 115 | - if ( defined( 'BLOCKSTRAP_VERSION' ) ) { |
|
| 116 | - add_filter( 'sd_aui_colors', array( self::$instance,'sd_aui_colors' ), 10, 3 ); |
|
| 115 | + if (defined('BLOCKSTRAP_VERSION')) { |
|
| 116 | + add_filter('sd_aui_colors', array(self::$instance, 'sd_aui_colors'), 10, 3); |
|
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - add_action( 'customize_register', array( self::$instance, 'customizer_settings' )); |
|
| 120 | + add_action('customize_register', array(self::$instance, 'customizer_settings')); |
|
| 121 | 121 | |
| 122 | - do_action( 'ayecode_ui_settings_loaded' ); |
|
| 122 | + do_action('ayecode_ui_settings_loaded'); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | return self::$instance; |
@@ -134,13 +134,13 @@ discard block |
||
| 134 | 134 | * |
| 135 | 135 | * @return mixed |
| 136 | 136 | */ |
| 137 | - public function sd_aui_colors( $theme_colors, $include_outlines, $include_branding ){ |
|
| 137 | + public function sd_aui_colors($theme_colors, $include_outlines, $include_branding) { |
|
| 138 | 138 | |
| 139 | 139 | |
| 140 | 140 | $setting = wp_get_global_settings(); |
| 141 | 141 | |
| 142 | - if(!empty($setting['color']['palette']['custom'])){ |
|
| 143 | - foreach($setting['color']['palette']['custom'] as $color){ |
|
| 142 | + if (!empty($setting['color']['palette']['custom'])) { |
|
| 143 | + foreach ($setting['color']['palette']['custom'] as $color) { |
|
| 144 | 144 | $theme_colors[$color['slug']] = esc_attr($color['name']); |
| 145 | 145 | } |
| 146 | 146 | } |
@@ -151,81 +151,81 @@ discard block |
||
| 151 | 151 | /** |
| 152 | 152 | * Setup some constants. |
| 153 | 153 | */ |
| 154 | - public function constants(){ |
|
| 155 | - define( 'AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be" ); |
|
| 156 | - define( 'AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d' ); |
|
| 157 | - define( 'AUI_INFO_COLOR_ORIGINAL', '#17a2b8' ); |
|
| 158 | - define( 'AUI_WARNING_COLOR_ORIGINAL', '#ffc107' ); |
|
| 159 | - define( 'AUI_DANGER_COLOR_ORIGINAL', '#dc3545' ); |
|
| 160 | - define( 'AUI_SUCCESS_COLOR_ORIGINAL', '#44c553' ); |
|
| 161 | - define( 'AUI_LIGHT_COLOR_ORIGINAL', '#f8f9fa' ); |
|
| 162 | - define( 'AUI_DARK_COLOR_ORIGINAL', '#343a40' ); |
|
| 163 | - define( 'AUI_WHITE_COLOR_ORIGINAL', '#fff' ); |
|
| 164 | - define( 'AUI_PURPLE_COLOR_ORIGINAL', '#ad6edd' ); |
|
| 165 | - define( 'AUI_SALMON_COLOR_ORIGINAL', '#ff977a' ); |
|
| 166 | - define( 'AUI_CYAN_COLOR_ORIGINAL', '#35bdff' ); |
|
| 167 | - define( 'AUI_GRAY_COLOR_ORIGINAL', '#ced4da' ); |
|
| 168 | - define( 'AUI_INDIGO_COLOR_ORIGINAL', '#502c6c' ); |
|
| 169 | - define( 'AUI_ORANGE_COLOR_ORIGINAL', '#orange' ); |
|
| 170 | - define( 'AUI_BLACK_COLOR_ORIGINAL', '#000' ); |
|
| 154 | + public function constants() { |
|
| 155 | + define('AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be"); |
|
| 156 | + define('AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d'); |
|
| 157 | + define('AUI_INFO_COLOR_ORIGINAL', '#17a2b8'); |
|
| 158 | + define('AUI_WARNING_COLOR_ORIGINAL', '#ffc107'); |
|
| 159 | + define('AUI_DANGER_COLOR_ORIGINAL', '#dc3545'); |
|
| 160 | + define('AUI_SUCCESS_COLOR_ORIGINAL', '#44c553'); |
|
| 161 | + define('AUI_LIGHT_COLOR_ORIGINAL', '#f8f9fa'); |
|
| 162 | + define('AUI_DARK_COLOR_ORIGINAL', '#343a40'); |
|
| 163 | + define('AUI_WHITE_COLOR_ORIGINAL', '#fff'); |
|
| 164 | + define('AUI_PURPLE_COLOR_ORIGINAL', '#ad6edd'); |
|
| 165 | + define('AUI_SALMON_COLOR_ORIGINAL', '#ff977a'); |
|
| 166 | + define('AUI_CYAN_COLOR_ORIGINAL', '#35bdff'); |
|
| 167 | + define('AUI_GRAY_COLOR_ORIGINAL', '#ced4da'); |
|
| 168 | + define('AUI_INDIGO_COLOR_ORIGINAL', '#502c6c'); |
|
| 169 | + define('AUI_ORANGE_COLOR_ORIGINAL', '#orange'); |
|
| 170 | + define('AUI_BLACK_COLOR_ORIGINAL', '#000'); |
|
| 171 | 171 | |
| 172 | - if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) { |
|
| 173 | - define( 'AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL ); |
|
| 172 | + if (!defined('AUI_PRIMARY_COLOR')) { |
|
| 173 | + define('AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL); |
|
| 174 | 174 | } |
| 175 | - if ( ! defined( 'AUI_SECONDARY_COLOR' ) ) { |
|
| 176 | - define( 'AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL ); |
|
| 175 | + if (!defined('AUI_SECONDARY_COLOR')) { |
|
| 176 | + define('AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL); |
|
| 177 | 177 | } |
| 178 | - if ( ! defined( 'AUI_INFO_COLOR' ) ) { |
|
| 179 | - define( 'AUI_INFO_COLOR', AUI_INFO_COLOR_ORIGINAL ); |
|
| 178 | + if (!defined('AUI_INFO_COLOR')) { |
|
| 179 | + define('AUI_INFO_COLOR', AUI_INFO_COLOR_ORIGINAL); |
|
| 180 | 180 | } |
| 181 | - if ( ! defined( 'AUI_WARNING_COLOR' ) ) { |
|
| 182 | - define( 'AUI_WARNING_COLOR', AUI_WARNING_COLOR_ORIGINAL ); |
|
| 181 | + if (!defined('AUI_WARNING_COLOR')) { |
|
| 182 | + define('AUI_WARNING_COLOR', AUI_WARNING_COLOR_ORIGINAL); |
|
| 183 | 183 | } |
| 184 | - if ( ! defined( 'AUI_DANGER_COLOR' ) ) { |
|
| 185 | - define( 'AUI_DANGER_COLOR', AUI_DANGER_COLOR_ORIGINAL ); |
|
| 184 | + if (!defined('AUI_DANGER_COLOR')) { |
|
| 185 | + define('AUI_DANGER_COLOR', AUI_DANGER_COLOR_ORIGINAL); |
|
| 186 | 186 | } |
| 187 | - if ( ! defined( 'AUI_SUCCESS_COLOR' ) ) { |
|
| 188 | - define( 'AUI_SUCCESS_COLOR', AUI_SUCCESS_COLOR_ORIGINAL ); |
|
| 187 | + if (!defined('AUI_SUCCESS_COLOR')) { |
|
| 188 | + define('AUI_SUCCESS_COLOR', AUI_SUCCESS_COLOR_ORIGINAL); |
|
| 189 | 189 | } |
| 190 | - if ( ! defined( 'AUI_LIGHT_COLOR' ) ) { |
|
| 191 | - define( 'AUI_LIGHT_COLOR', AUI_LIGHT_COLOR_ORIGINAL ); |
|
| 190 | + if (!defined('AUI_LIGHT_COLOR')) { |
|
| 191 | + define('AUI_LIGHT_COLOR', AUI_LIGHT_COLOR_ORIGINAL); |
|
| 192 | 192 | } |
| 193 | - if ( ! defined( 'AUI_DARK_COLOR' ) ) { |
|
| 194 | - define( 'AUI_DARK_COLOR', AUI_DARK_COLOR_ORIGINAL ); |
|
| 193 | + if (!defined('AUI_DARK_COLOR')) { |
|
| 194 | + define('AUI_DARK_COLOR', AUI_DARK_COLOR_ORIGINAL); |
|
| 195 | 195 | } |
| 196 | - if ( ! defined( 'AUI_WHITE_COLOR' ) ) { |
|
| 197 | - define( 'AUI_WHITE_COLOR', AUI_WHITE_COLOR_ORIGINAL ); |
|
| 196 | + if (!defined('AUI_WHITE_COLOR')) { |
|
| 197 | + define('AUI_WHITE_COLOR', AUI_WHITE_COLOR_ORIGINAL); |
|
| 198 | 198 | } |
| 199 | - if ( ! defined( 'AUI_PURPLE_COLOR' ) ) { |
|
| 200 | - define( 'AUI_PURPLE_COLOR', AUI_PURPLE_COLOR_ORIGINAL ); |
|
| 199 | + if (!defined('AUI_PURPLE_COLOR')) { |
|
| 200 | + define('AUI_PURPLE_COLOR', AUI_PURPLE_COLOR_ORIGINAL); |
|
| 201 | 201 | } |
| 202 | - if ( ! defined( 'AUI_SALMON_COLOR' ) ) { |
|
| 203 | - define( 'AUI_SALMON_COLOR', AUI_SALMON_COLOR_ORIGINAL ); |
|
| 202 | + if (!defined('AUI_SALMON_COLOR')) { |
|
| 203 | + define('AUI_SALMON_COLOR', AUI_SALMON_COLOR_ORIGINAL); |
|
| 204 | 204 | } |
| 205 | - if ( ! defined( 'AUI_CYAN_COLOR' ) ) { |
|
| 206 | - define( 'AUI_CYAN_COLOR', AUI_CYAN_COLOR_ORIGINAL ); |
|
| 205 | + if (!defined('AUI_CYAN_COLOR')) { |
|
| 206 | + define('AUI_CYAN_COLOR', AUI_CYAN_COLOR_ORIGINAL); |
|
| 207 | 207 | } |
| 208 | - if ( ! defined( 'AUI_GRAY_COLOR' ) ) { |
|
| 209 | - define( 'AUI_GRAY_COLOR', AUI_GRAY_COLOR_ORIGINAL ); |
|
| 208 | + if (!defined('AUI_GRAY_COLOR')) { |
|
| 209 | + define('AUI_GRAY_COLOR', AUI_GRAY_COLOR_ORIGINAL); |
|
| 210 | 210 | } |
| 211 | - if ( ! defined( 'AUI_INDIGO_COLOR' ) ) { |
|
| 212 | - define( 'AUI_INDIGO_COLOR', AUI_INDIGO_COLOR_ORIGINAL ); |
|
| 211 | + if (!defined('AUI_INDIGO_COLOR')) { |
|
| 212 | + define('AUI_INDIGO_COLOR', AUI_INDIGO_COLOR_ORIGINAL); |
|
| 213 | 213 | } |
| 214 | - if ( ! defined( 'AUI_ORANGE_COLOR' ) ) { |
|
| 215 | - define( 'AUI_ORANGE_COLOR', AUI_ORANGE_COLOR_ORIGINAL ); |
|
| 214 | + if (!defined('AUI_ORANGE_COLOR')) { |
|
| 215 | + define('AUI_ORANGE_COLOR', AUI_ORANGE_COLOR_ORIGINAL); |
|
| 216 | 216 | } |
| 217 | - if ( ! defined( 'AUI_BLACK_COLOR' ) ) { |
|
| 218 | - define( 'AUI_BLACK_COLOR', AUI_BLACK_COLOR_ORIGINAL ); |
|
| 217 | + if (!defined('AUI_BLACK_COLOR')) { |
|
| 218 | + define('AUI_BLACK_COLOR', AUI_BLACK_COLOR_ORIGINAL); |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - public static function get_colors( $original = false){ |
|
| 223 | + public static function get_colors($original = false) { |
|
| 224 | 224 | |
| 225 | - if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) { |
|
| 225 | + if (!defined('AUI_PRIMARY_COLOR')) { |
|
| 226 | 226 | return array(); |
| 227 | 227 | } |
| 228 | - if ( $original ) { |
|
| 228 | + if ($original) { |
|
| 229 | 229 | return array( |
| 230 | 230 | 'primary' => AUI_PRIMARY_COLOR_ORIGINAL, |
| 231 | 231 | 'secondary' => AUI_SECONDARY_COLOR_ORIGINAL, |
@@ -272,12 +272,12 @@ discard block |
||
| 272 | 272 | public function init() { |
| 273 | 273 | |
| 274 | 274 | // Maybe fix settings |
| 275 | - if ( ! empty( $_REQUEST['aui-fix-admin'] ) && !empty($_REQUEST['nonce']) && wp_verify_nonce( $_REQUEST['nonce'], "aui-fix-admin" ) ) { |
|
| 276 | - $db_settings = get_option( 'ayecode-ui-settings' ); |
|
| 277 | - if ( ! empty( $db_settings ) ) { |
|
| 275 | + if (!empty($_REQUEST['aui-fix-admin']) && !empty($_REQUEST['nonce']) && wp_verify_nonce($_REQUEST['nonce'], "aui-fix-admin")) { |
|
| 276 | + $db_settings = get_option('ayecode-ui-settings'); |
|
| 277 | + if (!empty($db_settings)) { |
|
| 278 | 278 | $db_settings['css_backend'] = 'compatibility'; |
| 279 | 279 | $db_settings['js_backend'] = 'core-popper'; |
| 280 | - update_option( 'ayecode-ui-settings', $db_settings ); |
|
| 280 | + update_option('ayecode-ui-settings', $db_settings); |
|
| 281 | 281 | wp_safe_redirect(admin_url("options-general.php?page=ayecode-ui-settings&updated=true")); |
| 282 | 282 | } |
| 283 | 283 | } |
@@ -291,31 +291,31 @@ discard block |
||
| 291 | 291 | * |
| 292 | 292 | * We load super early in case there is a theme version that might change the colors |
| 293 | 293 | */ |
| 294 | - if ( $this->settings['css'] ) { |
|
| 294 | + if ($this->settings['css']) { |
|
| 295 | 295 | $priority = $this->is_bs3_compat() ? 100 : 1; |
| 296 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), $priority ); |
|
| 296 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_style'), $priority); |
|
| 297 | 297 | } |
| 298 | - if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) { |
|
| 299 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
| 298 | + if ($this->settings['css_backend'] && $this->load_admin_scripts()) { |
|
| 299 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_style'), 1); |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | // maybe load JS |
| 303 | - if ( $this->settings['js'] ) { |
|
| 303 | + if ($this->settings['js']) { |
|
| 304 | 304 | $priority = $this->is_bs3_compat() ? 100 : 1; |
| 305 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority ); |
|
| 305 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), $priority); |
|
| 306 | 306 | } |
| 307 | - if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) { |
|
| 308 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); |
|
| 307 | + if ($this->settings['js_backend'] && $this->load_admin_scripts()) { |
|
| 308 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'), 1); |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | // Maybe set the HTML font size |
| 312 | - if ( $this->settings['html_font_size'] ) { |
|
| 313 | - add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 ); |
|
| 312 | + if ($this->settings['html_font_size']) { |
|
| 313 | + add_action('wp_footer', array($this, 'html_font_size'), 10); |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | // Maybe show backend style error |
| 317 | - if( $this->settings['css_backend'] != 'compatibility' || $this->settings['js_backend'] != 'core-popper' ){ |
|
| 318 | - add_action( 'admin_notices', array( $this, 'show_admin_style_notice' ) ); |
|
| 317 | + if ($this->settings['css_backend'] != 'compatibility' || $this->settings['js_backend'] != 'core-popper') { |
|
| 318 | + add_action('admin_notices', array($this, 'show_admin_style_notice')); |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | } |
@@ -323,11 +323,11 @@ discard block |
||
| 323 | 323 | /** |
| 324 | 324 | * Show admin notice if backend scripts not loaded. |
| 325 | 325 | */ |
| 326 | - public function show_admin_style_notice(){ |
|
| 327 | - $fix_url = admin_url("options-general.php?page=ayecode-ui-settings&aui-fix-admin=true&nonce=".wp_create_nonce('aui-fix-admin')); |
|
| 328 | - $button = '<a href="'.esc_url($fix_url).'" class="button-primary">Fix Now</a>'; |
|
| 329 | - $message = __( '<b>Style Issue:</b> AyeCode UI is disable or set wrong.')." " .$button; |
|
| 330 | - echo '<div class="notice notice-error aui-settings-error-notice"><p>'.$message.'</p></div>'; |
|
| 326 | + public function show_admin_style_notice() { |
|
| 327 | + $fix_url = admin_url("options-general.php?page=ayecode-ui-settings&aui-fix-admin=true&nonce=" . wp_create_nonce('aui-fix-admin')); |
|
| 328 | + $button = '<a href="' . esc_url($fix_url) . '" class="button-primary">Fix Now</a>'; |
|
| 329 | + $message = __('<b>Style Issue:</b> AyeCode UI is disable or set wrong.') . " " . $button; |
|
| 330 | + echo '<div class="notice notice-error aui-settings-error-notice"><p>' . $message . '</p></div>'; |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | /** |
@@ -335,14 +335,14 @@ discard block |
||
| 335 | 335 | * |
| 336 | 336 | * @return bool |
| 337 | 337 | */ |
| 338 | - public function load_admin_scripts(){ |
|
| 338 | + public function load_admin_scripts() { |
|
| 339 | 339 | $result = true; |
| 340 | 340 | |
| 341 | 341 | // check if specifically disabled |
| 342 | - if(!empty($this->settings['disable_admin'])){ |
|
| 343 | - $url_parts = explode("\n",$this->settings['disable_admin']); |
|
| 344 | - foreach($url_parts as $part){ |
|
| 345 | - if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){ |
|
| 342 | + if (!empty($this->settings['disable_admin'])) { |
|
| 343 | + $url_parts = explode("\n", $this->settings['disable_admin']); |
|
| 344 | + foreach ($url_parts as $part) { |
|
| 345 | + if (strpos($_SERVER['REQUEST_URI'], trim($part)) !== false) { |
|
| 346 | 346 | return false; // return early, no point checking further |
| 347 | 347 | } |
| 348 | 348 | } |
@@ -354,9 +354,9 @@ discard block |
||
| 354 | 354 | /** |
| 355 | 355 | * Add a html font size to the footer. |
| 356 | 356 | */ |
| 357 | - public function html_font_size(){ |
|
| 357 | + public function html_font_size() { |
|
| 358 | 358 | $this->settings = $this->get_settings(); |
| 359 | - echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>"; |
|
| 359 | + echo "<style>html{font-size:" . absint($this->settings['html_font_size']) . "px;}</style>"; |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | /** |
@@ -364,11 +364,11 @@ discard block |
||
| 364 | 364 | * |
| 365 | 365 | * @return bool |
| 366 | 366 | */ |
| 367 | - public function is_aui_screen(){ |
|
| 367 | + public function is_aui_screen() { |
|
| 368 | 368 | // echo '###';exit; |
| 369 | 369 | $load = false; |
| 370 | 370 | // check if we should load or not |
| 371 | - if ( is_admin() ) { |
|
| 371 | + if (is_admin()) { |
|
| 372 | 372 | // Only enable on set pages |
| 373 | 373 | $aui_screens = array( |
| 374 | 374 | 'page', |
@@ -379,24 +379,24 @@ discard block |
||
| 379 | 379 | 'ayecode-ui-settings', |
| 380 | 380 | 'site-editor' |
| 381 | 381 | ); |
| 382 | - $screen_ids = apply_filters( 'aui_screen_ids', $aui_screens ); |
|
| 382 | + $screen_ids = apply_filters('aui_screen_ids', $aui_screens); |
|
| 383 | 383 | |
| 384 | 384 | $screen = get_current_screen(); |
| 385 | 385 | |
| 386 | 386 | // echo '###'.$screen->id; |
| 387 | 387 | |
| 388 | 388 | // check if we are on a AUI screen |
| 389 | - if ( $screen && in_array( $screen->id, $screen_ids ) ) { |
|
| 389 | + if ($screen && in_array($screen->id, $screen_ids)) { |
|
| 390 | 390 | $load = true; |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | //load for widget previews in WP 5.8 |
| 394 | - if( !empty($_REQUEST['legacy-widget-preview'])){ |
|
| 394 | + if (!empty($_REQUEST['legacy-widget-preview'])) { |
|
| 395 | 395 | $load = true; |
| 396 | 396 | } |
| 397 | 397 | } |
| 398 | 398 | |
| 399 | - return apply_filters( 'aui_load_on_admin' , $load ); |
|
| 399 | + return apply_filters('aui_load_on_admin', $load); |
|
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | /** |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | * @return bool |
| 406 | 406 | */ |
| 407 | 407 | public static function is_block_theme() { |
| 408 | - if ( function_exists( 'wp_is_block_theme' && wp_is_block_theme() ) ) { |
|
| 408 | + if (function_exists('wp_is_block_theme' && wp_is_block_theme())) { |
|
| 409 | 409 | return true; |
| 410 | 410 | } |
| 411 | 411 | |
@@ -418,24 +418,24 @@ discard block |
||
| 418 | 418 | public function enqueue_style() { |
| 419 | 419 | |
| 420 | 420 | |
| 421 | - if( is_admin() && !$this->is_aui_screen()){ |
|
| 421 | + if (is_admin() && !$this->is_aui_screen()) { |
|
| 422 | 422 | // don't add wp-admin scripts if not requested to |
| 423 | - }else{ |
|
| 423 | + } else { |
|
| 424 | 424 | $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
| 425 | 425 | |
| 426 | 426 | $rtl = is_rtl() ? '-rtl' : ''; |
| 427 | 427 | |
| 428 | - if($this->settings[$css_setting]){ |
|
| 429 | - $compatibility = $this->settings[$css_setting]=='core' ? false : true; |
|
| 430 | - $url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets/css/ayecode-ui-compatibility'.$rtl.'.css'; |
|
| 431 | - wp_register_style( 'ayecode-ui', $url, array(), $this->version ); |
|
| 432 | - wp_enqueue_style( 'ayecode-ui' ); |
|
| 428 | + if ($this->settings[$css_setting]) { |
|
| 429 | + $compatibility = $this->settings[$css_setting] == 'core' ? false : true; |
|
| 430 | + $url = $this->settings[$css_setting] == 'core' ? $this->url . 'assets/css/ayecode-ui' . $rtl . '.css' : $this->url . 'assets/css/ayecode-ui-compatibility' . $rtl . '.css'; |
|
| 431 | + wp_register_style('ayecode-ui', $url, array(), $this->version); |
|
| 432 | + wp_enqueue_style('ayecode-ui'); |
|
| 433 | 433 | |
| 434 | 434 | // flatpickr |
| 435 | - wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->version ); |
|
| 435 | + wp_register_style('flatpickr', $this->url . 'assets/css/flatpickr.min.css', array(), $this->version); |
|
| 436 | 436 | |
| 437 | 437 | // fix some wp-admin issues |
| 438 | - if(is_admin()){ |
|
| 438 | + if (is_admin()) { |
|
| 439 | 439 | $custom_css = " |
| 440 | 440 | body{ |
| 441 | 441 | background-color: #f1f1f1; |
@@ -488,11 +488,11 @@ discard block |
||
| 488 | 488 | padding: 0; |
| 489 | 489 | } |
| 490 | 490 | "; |
| 491 | - wp_add_inline_style( 'ayecode-ui', $custom_css ); |
|
| 491 | + wp_add_inline_style('ayecode-ui', $custom_css); |
|
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | // custom changes |
| 495 | - wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); |
|
| 495 | + wp_add_inline_style('ayecode-ui', self::custom_css($compatibility)); |
|
| 496 | 496 | |
| 497 | 497 | } |
| 498 | 498 | } |
@@ -755,7 +755,7 @@ discard block |
||
| 755 | 755 | function aui_init_flatpickr(){ |
| 756 | 756 | if ( typeof jQuery.fn.flatpickr === "function" && !$aui_doing_init_flatpickr) { |
| 757 | 757 | $aui_doing_init_flatpickr = true; |
| 758 | - <?php if ( ! empty( $flatpickr_locale ) ) { ?>try{flatpickr.localize(<?php echo $flatpickr_locale; ?>);}catch(err){console.log(err.message);}<?php } ?> |
|
| 758 | + <?php if (!empty($flatpickr_locale)) { ?>try{flatpickr.localize(<?php echo $flatpickr_locale; ?>);}catch(err){console.log(err.message);}<?php } ?> |
|
| 759 | 759 | jQuery('input[data-aui-init="flatpickr"]:not(.flatpickr-input)').flatpickr(); |
| 760 | 760 | } |
| 761 | 761 | $aui_doing_init_flatpickr = false; |
@@ -1448,7 +1448,7 @@ discard block |
||
| 1448 | 1448 | |
| 1449 | 1449 | <?php |
| 1450 | 1450 | // FSE tweaks. |
| 1451 | - if(!empty($_REQUEST['postType']) && $_REQUEST['postType']=='wp_template'){ ?> |
|
| 1451 | + if (!empty($_REQUEST['postType']) && $_REQUEST['postType'] == 'wp_template') { ?> |
|
| 1452 | 1452 | function aui_fse_set_data_scroll() { |
| 1453 | 1453 | let Iframe = document.getElementsByClassName("edit-site-visual-editor__editor-canvas"); |
| 1454 | 1454 | let iframe_doc = Iframe[0].contentWindow ? Iframe[0].contentWindow.document : Iframe[0].contentDocument; |
@@ -1486,10 +1486,10 @@ discard block |
||
| 1486 | 1486 | /* |
| 1487 | 1487 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1488 | 1488 | */ |
| 1489 | - return str_replace( array( |
|
| 1489 | + return str_replace(array( |
|
| 1490 | 1490 | '<script>', |
| 1491 | 1491 | '</script>' |
| 1492 | - ), '', self::minify_js($output) ); |
|
| 1492 | + ), '', self::minify_js($output)); |
|
| 1493 | 1493 | } |
| 1494 | 1494 | |
| 1495 | 1495 | |
@@ -1503,13 +1503,13 @@ discard block |
||
| 1503 | 1503 | ob_start(); |
| 1504 | 1504 | ?> |
| 1505 | 1505 | <script> |
| 1506 | - <?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?> |
|
| 1506 | + <?php if (defined('FUSION_BUILDER_VERSION')) { ?> |
|
| 1507 | 1507 | /* With Avada builder */ |
| 1508 | 1508 | |
| 1509 | 1509 | <?php } ?> |
| 1510 | 1510 | </script> |
| 1511 | 1511 | <?php |
| 1512 | - return str_replace( array( |
|
| 1512 | + return str_replace(array( |
|
| 1513 | 1513 | '<script>', |
| 1514 | 1514 | '</script>' |
| 1515 | 1515 | ), '', ob_get_clean()); |
@@ -1520,7 +1520,7 @@ discard block |
||
| 1520 | 1520 | * |
| 1521 | 1521 | * If this remains small then its best to use this than to add another JS file. |
| 1522 | 1522 | */ |
| 1523 | - public function inline_script_file_browser(){ |
|
| 1523 | + public function inline_script_file_browser() { |
|
| 1524 | 1524 | ob_start(); |
| 1525 | 1525 | ?> |
| 1526 | 1526 | <script> |
@@ -1535,10 +1535,10 @@ discard block |
||
| 1535 | 1535 | /* |
| 1536 | 1536 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1537 | 1537 | */ |
| 1538 | - return str_replace( array( |
|
| 1538 | + return str_replace(array( |
|
| 1539 | 1539 | '<script>', |
| 1540 | 1540 | '</script>' |
| 1541 | - ), '', $output ); |
|
| 1541 | + ), '', $output); |
|
| 1542 | 1542 | } |
| 1543 | 1543 | |
| 1544 | 1544 | /** |
@@ -1546,53 +1546,53 @@ discard block |
||
| 1546 | 1546 | */ |
| 1547 | 1547 | public function enqueue_scripts() { |
| 1548 | 1548 | |
| 1549 | - if( is_admin() && !$this->is_aui_screen()){ |
|
| 1549 | + if (is_admin() && !$this->is_aui_screen()) { |
|
| 1550 | 1550 | // don't add wp-admin scripts if not requested to |
| 1551 | - }else { |
|
| 1551 | + } else { |
|
| 1552 | 1552 | |
| 1553 | 1553 | $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
| 1554 | 1554 | |
| 1555 | 1555 | // select2 |
| 1556 | - wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version ); |
|
| 1556 | + wp_register_script('select2', $this->url . 'assets/js/select2.min.js', array('jquery'), $this->select2_version); |
|
| 1557 | 1557 | |
| 1558 | 1558 | // flatpickr |
| 1559 | - wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->version ); |
|
| 1559 | + wp_register_script('flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->version); |
|
| 1560 | 1560 | |
| 1561 | 1561 | // flatpickr |
| 1562 | - wp_register_script( 'iconpicker', $this->url . 'assets/js/fa-iconpicker.min.js', array(), $this->version ); |
|
| 1562 | + wp_register_script('iconpicker', $this->url . 'assets/js/fa-iconpicker.min.js', array(), $this->version); |
|
| 1563 | 1563 | |
| 1564 | 1564 | // Bootstrap file browser |
| 1565 | - wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version ); |
|
| 1566 | - wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() ); |
|
| 1565 | + wp_register_script('aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array('jquery'), $this->select2_version); |
|
| 1566 | + wp_add_inline_script('aui-custom-file-input', $this->inline_script_file_browser()); |
|
| 1567 | 1567 | |
| 1568 | 1568 | $load_inline = false; |
| 1569 | 1569 | |
| 1570 | - if ( $this->settings[ $js_setting ] == 'core-popper' ) { |
|
| 1570 | + if ($this->settings[$js_setting] == 'core-popper') { |
|
| 1571 | 1571 | // Bootstrap bundle |
| 1572 | 1572 | $url = $this->url . 'assets/js/bootstrap.bundle.min.js'; |
| 1573 | - wp_register_script( 'bootstrap-js-bundle', $url, array( |
|
| 1573 | + wp_register_script('bootstrap-js-bundle', $url, array( |
|
| 1574 | 1574 | 'select2', |
| 1575 | 1575 | 'jquery' |
| 1576 | - ), $this->version, $this->is_bs3_compat() ); |
|
| 1576 | + ), $this->version, $this->is_bs3_compat()); |
|
| 1577 | 1577 | // if in admin then add to footer for compatibility. |
| 1578 | - is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' ); |
|
| 1578 | + is_admin() ? wp_enqueue_script('bootstrap-js-bundle', '', null, null, true) : wp_enqueue_script('bootstrap-js-bundle'); |
|
| 1579 | 1579 | $script = $this->inline_script(); |
| 1580 | - wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
|
| 1581 | - } elseif ( $this->settings[ $js_setting ] == 'popper' ) { |
|
| 1580 | + wp_add_inline_script('bootstrap-js-bundle', $script); |
|
| 1581 | + } elseif ($this->settings[$js_setting] == 'popper') { |
|
| 1582 | 1582 | $url = $this->url . 'assets/js/popper.min.js'; |
| 1583 | - wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->version ); |
|
| 1584 | - wp_enqueue_script( 'bootstrap-js-popper' ); |
|
| 1583 | + wp_register_script('bootstrap-js-popper', $url, array('select2', 'jquery'), $this->version); |
|
| 1584 | + wp_enqueue_script('bootstrap-js-popper'); |
|
| 1585 | 1585 | $load_inline = true; |
| 1586 | 1586 | } else { |
| 1587 | 1587 | $load_inline = true; |
| 1588 | 1588 | } |
| 1589 | 1589 | |
| 1590 | 1590 | // Load needed inline scripts by faking the loading of a script if the main script is not being loaded |
| 1591 | - if ( $load_inline ) { |
|
| 1592 | - wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) ); |
|
| 1593 | - wp_enqueue_script( 'bootstrap-dummy' ); |
|
| 1591 | + if ($load_inline) { |
|
| 1592 | + wp_register_script('bootstrap-dummy', '', array('select2', 'jquery')); |
|
| 1593 | + wp_enqueue_script('bootstrap-dummy'); |
|
| 1594 | 1594 | $script = $this->inline_script(); |
| 1595 | - wp_add_inline_script( 'bootstrap-dummy', $script ); |
|
| 1595 | + wp_add_inline_script('bootstrap-dummy', $script); |
|
| 1596 | 1596 | } |
| 1597 | 1597 | } |
| 1598 | 1598 | |
@@ -1601,17 +1601,17 @@ discard block |
||
| 1601 | 1601 | /** |
| 1602 | 1602 | * Enqueue flatpickr if called. |
| 1603 | 1603 | */ |
| 1604 | - public function enqueue_flatpickr(){ |
|
| 1605 | - wp_enqueue_style( 'flatpickr' ); |
|
| 1606 | - wp_enqueue_script( 'flatpickr' ); |
|
| 1604 | + public function enqueue_flatpickr() { |
|
| 1605 | + wp_enqueue_style('flatpickr'); |
|
| 1606 | + wp_enqueue_script('flatpickr'); |
|
| 1607 | 1607 | } |
| 1608 | 1608 | |
| 1609 | 1609 | /** |
| 1610 | 1610 | * Enqueue iconpicker if called. |
| 1611 | 1611 | */ |
| 1612 | - public function enqueue_iconpicker(){ |
|
| 1613 | - wp_enqueue_style( 'iconpicker' ); |
|
| 1614 | - wp_enqueue_script( 'iconpicker' ); |
|
| 1612 | + public function enqueue_iconpicker() { |
|
| 1613 | + wp_enqueue_style('iconpicker'); |
|
| 1614 | + wp_enqueue_script('iconpicker'); |
|
| 1615 | 1615 | } |
| 1616 | 1616 | |
| 1617 | 1617 | /** |
@@ -1620,19 +1620,19 @@ discard block |
||
| 1620 | 1620 | * @return string |
| 1621 | 1621 | */ |
| 1622 | 1622 | public function get_url() { |
| 1623 | - $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) ); |
|
| 1624 | - $content_url = untrailingslashit( WP_CONTENT_URL ); |
|
| 1623 | + $content_dir = wp_normalize_path(untrailingslashit(WP_CONTENT_DIR)); |
|
| 1624 | + $content_url = untrailingslashit(WP_CONTENT_URL); |
|
| 1625 | 1625 | |
| 1626 | 1626 | // Replace http:// to https://. |
| 1627 | - if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) { |
|
| 1628 | - $content_url = str_replace( 'http://', 'https://', $content_url ); |
|
| 1627 | + if (strpos($content_url, 'http://') === 0 && strpos(plugins_url(), 'https://') === 0) { |
|
| 1628 | + $content_url = str_replace('http://', 'https://', $content_url); |
|
| 1629 | 1629 | } |
| 1630 | 1630 | |
| 1631 | 1631 | // Check if we are inside a plugin |
| 1632 | - $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 1633 | - $url = str_replace( $content_dir, $content_url, $file_dir ); |
|
| 1632 | + $file_dir = str_replace("/includes", "", wp_normalize_path(dirname(__FILE__))); |
|
| 1633 | + $url = str_replace($content_dir, $content_url, $file_dir); |
|
| 1634 | 1634 | |
| 1635 | - return trailingslashit( $url ); |
|
| 1635 | + return trailingslashit($url); |
|
| 1636 | 1636 | } |
| 1637 | 1637 | |
| 1638 | 1638 | /** |
@@ -1644,15 +1644,15 @@ discard block |
||
| 1644 | 1644 | |
| 1645 | 1645 | $url = ''; |
| 1646 | 1646 | // check if we are inside a plugin |
| 1647 | - $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 1647 | + $file_dir = str_replace("/includes", "", wp_normalize_path(dirname(__FILE__))); |
|
| 1648 | 1648 | |
| 1649 | 1649 | // add check in-case user has changed wp-content dir name. |
| 1650 | 1650 | $wp_content_folder_name = basename(WP_CONTENT_DIR); |
| 1651 | - $dir_parts = explode("/$wp_content_folder_name/",$file_dir); |
|
| 1652 | - $url_parts = explode("/$wp_content_folder_name/",plugins_url()); |
|
| 1651 | + $dir_parts = explode("/$wp_content_folder_name/", $file_dir); |
|
| 1652 | + $url_parts = explode("/$wp_content_folder_name/", plugins_url()); |
|
| 1653 | 1653 | |
| 1654 | - if(!empty($url_parts[0]) && !empty($dir_parts[1])){ |
|
| 1655 | - $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); |
|
| 1654 | + if (!empty($url_parts[0]) && !empty($dir_parts[1])) { |
|
| 1655 | + $url = trailingslashit($url_parts[0] . "/$wp_content_folder_name/" . $dir_parts[1]); |
|
| 1656 | 1656 | } |
| 1657 | 1657 | |
| 1658 | 1658 | return $url; |
@@ -1662,7 +1662,7 @@ discard block |
||
| 1662 | 1662 | * Register the database settings with WordPress. |
| 1663 | 1663 | */ |
| 1664 | 1664 | public function register_settings() { |
| 1665 | - register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); |
|
| 1665 | + register_setting('ayecode-ui-settings', 'ayecode-ui-settings'); |
|
| 1666 | 1666 | } |
| 1667 | 1667 | |
| 1668 | 1668 | /** |
@@ -1671,10 +1671,10 @@ discard block |
||
| 1671 | 1671 | */ |
| 1672 | 1672 | public function menu_item() { |
| 1673 | 1673 | $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
| 1674 | - call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
| 1674 | + call_user_func($menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
| 1675 | 1675 | $this, |
| 1676 | 1676 | 'settings_page' |
| 1677 | - ) ); |
|
| 1677 | + )); |
|
| 1678 | 1678 | } |
| 1679 | 1679 | |
| 1680 | 1680 | /** |
@@ -1682,7 +1682,7 @@ discard block |
||
| 1682 | 1682 | * |
| 1683 | 1683 | * @return array |
| 1684 | 1684 | */ |
| 1685 | - public function theme_js_settings(){ |
|
| 1685 | + public function theme_js_settings() { |
|
| 1686 | 1686 | return array( |
| 1687 | 1687 | 'ayetheme' => 'popper', |
| 1688 | 1688 | 'listimia' => 'required', |
@@ -1698,17 +1698,17 @@ discard block |
||
| 1698 | 1698 | */ |
| 1699 | 1699 | public function get_settings() { |
| 1700 | 1700 | |
| 1701 | - $db_settings = get_option( 'ayecode-ui-settings' ); |
|
| 1701 | + $db_settings = get_option('ayecode-ui-settings'); |
|
| 1702 | 1702 | $js_default = 'core-popper'; |
| 1703 | 1703 | $js_default_backend = $js_default; |
| 1704 | 1704 | |
| 1705 | 1705 | // maybe set defaults (if no settings set) |
| 1706 | - if(empty($db_settings)){ |
|
| 1707 | - $active_theme = strtolower( get_template() ); // active parent theme. |
|
| 1706 | + if (empty($db_settings)) { |
|
| 1707 | + $active_theme = strtolower(get_template()); // active parent theme. |
|
| 1708 | 1708 | $theme_js_settings = self::theme_js_settings(); |
| 1709 | - if(isset($theme_js_settings[$active_theme])){ |
|
| 1709 | + if (isset($theme_js_settings[$active_theme])) { |
|
| 1710 | 1710 | $js_default = $theme_js_settings[$active_theme]; |
| 1711 | - $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default; |
|
| 1711 | + $js_default_backend = isset($theme_js_settings[$active_theme . "_backend"]) ? $theme_js_settings[$active_theme . "_backend"] : $js_default; |
|
| 1712 | 1712 | } |
| 1713 | 1713 | } |
| 1714 | 1714 | |
@@ -1721,14 +1721,14 @@ discard block |
||
| 1721 | 1721 | 'disable_admin' => '', // URL snippets to disable loading on admin |
| 1722 | 1722 | ); |
| 1723 | 1723 | |
| 1724 | - $settings = wp_parse_args( $db_settings, $defaults ); |
|
| 1724 | + $settings = wp_parse_args($db_settings, $defaults); |
|
| 1725 | 1725 | |
| 1726 | 1726 | /** |
| 1727 | 1727 | * Filter the Bootstrap settings. |
| 1728 | 1728 | * |
| 1729 | 1729 | * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
| 1730 | 1730 | */ |
| 1731 | - return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); |
|
| 1731 | + return $this->settings = apply_filters('ayecode-ui-settings', $settings, $db_settings, $defaults); |
|
| 1732 | 1732 | } |
| 1733 | 1733 | |
| 1734 | 1734 | |
@@ -1736,90 +1736,90 @@ discard block |
||
| 1736 | 1736 | * The settings page html output. |
| 1737 | 1737 | */ |
| 1738 | 1738 | public function settings_page() { |
| 1739 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 1740 | - wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) ); |
|
| 1739 | + if (!current_user_can('manage_options')) { |
|
| 1740 | + wp_die(__('You do not have sufficient permissions to access this page.', 'aui')); |
|
| 1741 | 1741 | } |
| 1742 | 1742 | ?> |
| 1743 | 1743 | <div class="wrap"> |
| 1744 | 1744 | <h1><?php echo $this->name; ?></h1> |
| 1745 | - <p><?php _e("Here you can adjust settings if you are having compatibility issues.",'aui');?></p> |
|
| 1745 | + <p><?php _e("Here you can adjust settings if you are having compatibility issues.", 'aui'); ?></p> |
|
| 1746 | 1746 | <form method="post" action="options.php"> |
| 1747 | 1747 | <?php |
| 1748 | - settings_fields( 'ayecode-ui-settings' ); |
|
| 1749 | - do_settings_sections( 'ayecode-ui-settings' ); |
|
| 1748 | + settings_fields('ayecode-ui-settings'); |
|
| 1749 | + do_settings_sections('ayecode-ui-settings'); |
|
| 1750 | 1750 | ?> |
| 1751 | 1751 | |
| 1752 | - <h2><?php _e( 'Frontend', 'aui' ); ?></h2> |
|
| 1752 | + <h2><?php _e('Frontend', 'aui'); ?></h2> |
|
| 1753 | 1753 | <table class="form-table wpbs-table-settings"> |
| 1754 | 1754 | <tr valign="top"> |
| 1755 | 1755 | <th scope="row"><label |
| 1756 | - for="wpbs-css"><?php _e( 'Load CSS', 'aui' ); ?></label></th> |
|
| 1756 | + for="wpbs-css"><?php _e('Load CSS', 'aui'); ?></label></th> |
|
| 1757 | 1757 | <td> |
| 1758 | 1758 | <select name="ayecode-ui-settings[css]" id="wpbs-css"> |
| 1759 | - <option value="compatibility" <?php selected( $this->settings['css'], 'compatibility' ); ?>><?php _e( 'Compatibility Mode (default)', 'aui' ); ?></option> |
|
| 1760 | - <option value="core" <?php selected( $this->settings['css'], 'core' ); ?>><?php _e( 'Full Mode', 'aui' ); ?></option> |
|
| 1761 | - <option value="" <?php selected( $this->settings['css'], '' ); ?>><?php _e( 'Disabled', 'aui' ); ?></option> |
|
| 1759 | + <option value="compatibility" <?php selected($this->settings['css'], 'compatibility'); ?>><?php _e('Compatibility Mode (default)', 'aui'); ?></option> |
|
| 1760 | + <option value="core" <?php selected($this->settings['css'], 'core'); ?>><?php _e('Full Mode', 'aui'); ?></option> |
|
| 1761 | + <option value="" <?php selected($this->settings['css'], ''); ?>><?php _e('Disabled', 'aui'); ?></option> |
|
| 1762 | 1762 | </select> |
| 1763 | 1763 | </td> |
| 1764 | 1764 | </tr> |
| 1765 | 1765 | |
| 1766 | 1766 | <tr valign="top"> |
| 1767 | 1767 | <th scope="row"><label |
| 1768 | - for="wpbs-js"><?php _e( 'Load JS', 'aui' ); ?></label></th> |
|
| 1768 | + for="wpbs-js"><?php _e('Load JS', 'aui'); ?></label></th> |
|
| 1769 | 1769 | <td> |
| 1770 | 1770 | <select name="ayecode-ui-settings[js]" id="wpbs-js"> |
| 1771 | - <option value="core-popper" <?php selected( $this->settings['js'], 'core-popper' ); ?>><?php _e( 'Core + Popper (default)', 'aui' ); ?></option> |
|
| 1772 | - <option value="popper" <?php selected( $this->settings['js'], 'popper' ); ?>><?php _e( 'Popper', 'aui' ); ?></option> |
|
| 1773 | - <option value="required" <?php selected( $this->settings['js'], 'required' ); ?>><?php _e( 'Required functions only', 'aui' ); ?></option> |
|
| 1774 | - <option value="" <?php selected( $this->settings['js'], '' ); ?>><?php _e( 'Disabled (not recommended)', 'aui' ); ?></option> |
|
| 1771 | + <option value="core-popper" <?php selected($this->settings['js'], 'core-popper'); ?>><?php _e('Core + Popper (default)', 'aui'); ?></option> |
|
| 1772 | + <option value="popper" <?php selected($this->settings['js'], 'popper'); ?>><?php _e('Popper', 'aui'); ?></option> |
|
| 1773 | + <option value="required" <?php selected($this->settings['js'], 'required'); ?>><?php _e('Required functions only', 'aui'); ?></option> |
|
| 1774 | + <option value="" <?php selected($this->settings['js'], ''); ?>><?php _e('Disabled (not recommended)', 'aui'); ?></option> |
|
| 1775 | 1775 | </select> |
| 1776 | 1776 | </td> |
| 1777 | 1777 | </tr> |
| 1778 | 1778 | |
| 1779 | 1779 | <tr valign="top"> |
| 1780 | 1780 | <th scope="row"><label |
| 1781 | - for="wpbs-font_size"><?php _e( 'HTML Font Size (px)', 'aui' ); ?></label></th> |
|
| 1781 | + for="wpbs-font_size"><?php _e('HTML Font Size (px)', 'aui'); ?></label></th> |
|
| 1782 | 1782 | <td> |
| 1783 | - <input type="number" name="ayecode-ui-settings[html_font_size]" id="wpbs-font_size" value="<?php echo absint( $this->settings['html_font_size']); ?>" placeholder="16" /> |
|
| 1784 | - <p class="description" ><?php _e("Our font sizing is rem (responsive based) here you can set the html font size in-case your theme is setting it too low.",'aui');?></p> |
|
| 1783 | + <input type="number" name="ayecode-ui-settings[html_font_size]" id="wpbs-font_size" value="<?php echo absint($this->settings['html_font_size']); ?>" placeholder="16" /> |
|
| 1784 | + <p class="description" ><?php _e("Our font sizing is rem (responsive based) here you can set the html font size in-case your theme is setting it too low.", 'aui'); ?></p> |
|
| 1785 | 1785 | </td> |
| 1786 | 1786 | </tr> |
| 1787 | 1787 | |
| 1788 | 1788 | </table> |
| 1789 | 1789 | |
| 1790 | - <h2><?php _e( 'Backend', 'aui' ); ?> (wp-admin)</h2> |
|
| 1790 | + <h2><?php _e('Backend', 'aui'); ?> (wp-admin)</h2> |
|
| 1791 | 1791 | <table class="form-table wpbs-table-settings"> |
| 1792 | 1792 | <tr valign="top"> |
| 1793 | 1793 | <th scope="row"><label |
| 1794 | - for="wpbs-css-admin"><?php _e( 'Load CSS', 'aui' ); ?></label></th> |
|
| 1794 | + for="wpbs-css-admin"><?php _e('Load CSS', 'aui'); ?></label></th> |
|
| 1795 | 1795 | <td> |
| 1796 | 1796 | <select name="ayecode-ui-settings[css_backend]" id="wpbs-css-admin"> |
| 1797 | - <option value="compatibility" <?php selected( $this->settings['css_backend'], 'compatibility' ); ?>><?php _e( 'Compatibility Mode (default)', 'aui' ); ?></option> |
|
| 1798 | - <option value="core" <?php selected( $this->settings['css_backend'], 'core' ); ?>><?php _e( 'Full Mode (will cause style issues)', 'aui' ); ?></option> |
|
| 1799 | - <option value="" <?php selected( $this->settings['css_backend'], '' ); ?>><?php _e( 'Disabled', 'aui' ); ?></option> |
|
| 1797 | + <option value="compatibility" <?php selected($this->settings['css_backend'], 'compatibility'); ?>><?php _e('Compatibility Mode (default)', 'aui'); ?></option> |
|
| 1798 | + <option value="core" <?php selected($this->settings['css_backend'], 'core'); ?>><?php _e('Full Mode (will cause style issues)', 'aui'); ?></option> |
|
| 1799 | + <option value="" <?php selected($this->settings['css_backend'], ''); ?>><?php _e('Disabled', 'aui'); ?></option> |
|
| 1800 | 1800 | </select> |
| 1801 | 1801 | </td> |
| 1802 | 1802 | </tr> |
| 1803 | 1803 | |
| 1804 | 1804 | <tr valign="top"> |
| 1805 | 1805 | <th scope="row"><label |
| 1806 | - for="wpbs-js-admin"><?php _e( 'Load JS', 'aui' ); ?></label></th> |
|
| 1806 | + for="wpbs-js-admin"><?php _e('Load JS', 'aui'); ?></label></th> |
|
| 1807 | 1807 | <td> |
| 1808 | 1808 | <select name="ayecode-ui-settings[js_backend]" id="wpbs-js-admin"> |
| 1809 | - <option value="core-popper" <?php selected( $this->settings['js_backend'], 'core-popper' ); ?>><?php _e( 'Core + Popper (default)', 'aui' ); ?></option> |
|
| 1810 | - <option value="popper" <?php selected( $this->settings['js_backend'], 'popper' ); ?>><?php _e( 'Popper', 'aui' ); ?></option> |
|
| 1811 | - <option value="required" <?php selected( $this->settings['js_backend'], 'required' ); ?>><?php _e( 'Required functions only', 'aui' ); ?></option> |
|
| 1812 | - <option value="" <?php selected( $this->settings['js_backend'], '' ); ?>><?php _e( 'Disabled (not recommended)', 'aui' ); ?></option> |
|
| 1809 | + <option value="core-popper" <?php selected($this->settings['js_backend'], 'core-popper'); ?>><?php _e('Core + Popper (default)', 'aui'); ?></option> |
|
| 1810 | + <option value="popper" <?php selected($this->settings['js_backend'], 'popper'); ?>><?php _e('Popper', 'aui'); ?></option> |
|
| 1811 | + <option value="required" <?php selected($this->settings['js_backend'], 'required'); ?>><?php _e('Required functions only', 'aui'); ?></option> |
|
| 1812 | + <option value="" <?php selected($this->settings['js_backend'], ''); ?>><?php _e('Disabled (not recommended)', 'aui'); ?></option> |
|
| 1813 | 1813 | </select> |
| 1814 | 1814 | </td> |
| 1815 | 1815 | </tr> |
| 1816 | 1816 | |
| 1817 | 1817 | <tr valign="top"> |
| 1818 | 1818 | <th scope="row"><label |
| 1819 | - for="wpbs-disable-admin"><?php _e( 'Disable load on URL', 'aui' ); ?></label></th> |
|
| 1819 | + for="wpbs-disable-admin"><?php _e('Disable load on URL', 'aui'); ?></label></th> |
|
| 1820 | 1820 | <td> |
| 1821 | - <p><?php _e( 'If you have backend conflict you can enter a partial URL argument that will disable the loading of AUI on those pages. Add each argument on a new line.', 'aui' ); ?></p> |
|
| 1822 | - <textarea name="ayecode-ui-settings[disable_admin]" rows="10" cols="50" id="wpbs-disable-admin" class="large-text code" spellcheck="false" placeholder="myplugin.php action=go"><?php echo $this->settings['disable_admin'];?></textarea> |
|
| 1821 | + <p><?php _e('If you have backend conflict you can enter a partial URL argument that will disable the loading of AUI on those pages. Add each argument on a new line.', 'aui'); ?></p> |
|
| 1822 | + <textarea name="ayecode-ui-settings[disable_admin]" rows="10" cols="50" id="wpbs-disable-admin" class="large-text code" spellcheck="false" placeholder="myplugin.php action=go"><?php echo $this->settings['disable_admin']; ?></textarea> |
|
| 1823 | 1823 | |
| 1824 | 1824 | </td> |
| 1825 | 1825 | </tr> |
@@ -1837,9 +1837,9 @@ discard block |
||
| 1837 | 1837 | <?php |
| 1838 | 1838 | } |
| 1839 | 1839 | |
| 1840 | - public function customizer_settings($wp_customize){ |
|
| 1840 | + public function customizer_settings($wp_customize) { |
|
| 1841 | 1841 | $wp_customize->add_section('aui_settings', array( |
| 1842 | - 'title' => __('AyeCode UI','aui'), |
|
| 1842 | + 'title' => __('AyeCode UI', 'aui'), |
|
| 1843 | 1843 | 'priority' => 120, |
| 1844 | 1844 | )); |
| 1845 | 1845 | |
@@ -1853,8 +1853,8 @@ discard block |
||
| 1853 | 1853 | 'type' => 'option', |
| 1854 | 1854 | 'transport' => 'refresh', |
| 1855 | 1855 | )); |
| 1856 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
| 1857 | - 'label' => __('Primary Color','aui'), |
|
| 1856 | + $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
| 1857 | + 'label' => __('Primary Color', 'aui'), |
|
| 1858 | 1858 | 'section' => 'aui_settings', |
| 1859 | 1859 | 'settings' => 'aui_options[color_primary]', |
| 1860 | 1860 | ))); |
@@ -1866,8 +1866,8 @@ discard block |
||
| 1866 | 1866 | 'type' => 'option', |
| 1867 | 1867 | 'transport' => 'refresh', |
| 1868 | 1868 | )); |
| 1869 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
| 1870 | - 'label' => __('Secondary Color','aui'), |
|
| 1869 | + $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
| 1870 | + 'label' => __('Secondary Color', 'aui'), |
|
| 1871 | 1871 | 'section' => 'aui_settings', |
| 1872 | 1872 | 'settings' => 'aui_options[color_secondary]', |
| 1873 | 1873 | ))); |
@@ -1893,12 +1893,12 @@ discard block |
||
| 1893 | 1893 | .collapse.show:not(.in){display: inherit;} |
| 1894 | 1894 | .fade.show{opacity: 1;} |
| 1895 | 1895 | |
| 1896 | - <?php if( defined( 'SVQ_THEME_VERSION' ) ){ ?> |
|
| 1896 | + <?php if (defined('SVQ_THEME_VERSION')) { ?> |
|
| 1897 | 1897 | /* KLEO theme specific */ |
| 1898 | 1898 | .kleo-main-header .navbar-collapse.collapse.show:not(.in){display: block !important;} |
| 1899 | 1899 | <?php } ?> |
| 1900 | 1900 | |
| 1901 | - <?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?> |
|
| 1901 | + <?php if (defined('FUSION_BUILDER_VERSION')) { ?> |
|
| 1902 | 1902 | /* With Avada builder */ |
| 1903 | 1903 | body.modal-open .modal.in {opacity:1;z-index: 99999} |
| 1904 | 1904 | body.modal-open .modal.bsui.in .modal-content {box-shadow: none;} |
@@ -1909,34 +1909,34 @@ discard block |
||
| 1909 | 1909 | <?php } ?> |
| 1910 | 1910 | </style> |
| 1911 | 1911 | <?php |
| 1912 | - return str_replace( array( |
|
| 1912 | + return str_replace(array( |
|
| 1913 | 1913 | '<style>', |
| 1914 | 1914 | '</style>' |
| 1915 | - ), '', self::minify_css( ob_get_clean() ) ); |
|
| 1915 | + ), '', self::minify_css(ob_get_clean())); |
|
| 1916 | 1916 | } |
| 1917 | 1917 | |
| 1918 | 1918 | |
| 1919 | 1919 | public static function custom_css($compatibility = true) { |
| 1920 | 1920 | $colors = array(); |
| 1921 | - if ( defined( 'BLOCKSTRAP_VERSION' ) ) { |
|
| 1921 | + if (defined('BLOCKSTRAP_VERSION')) { |
|
| 1922 | 1922 | |
| 1923 | 1923 | $setting = wp_get_global_settings(); |
| 1924 | - if(!empty($setting['color']['palette']['theme'])){ |
|
| 1925 | - foreach($setting['color']['palette']['theme'] as $color){ |
|
| 1924 | + if (!empty($setting['color']['palette']['theme'])) { |
|
| 1925 | + foreach ($setting['color']['palette']['theme'] as $color) { |
|
| 1926 | 1926 | $colors[$color['slug']] = esc_attr($color['color']); |
| 1927 | 1927 | } |
| 1928 | 1928 | } |
| 1929 | 1929 | |
| 1930 | - if(!empty($setting['color']['palette']['custom'])){ |
|
| 1931 | - foreach($setting['color']['palette']['custom'] as $color){ |
|
| 1930 | + if (!empty($setting['color']['palette']['custom'])) { |
|
| 1931 | + foreach ($setting['color']['palette']['custom'] as $color) { |
|
| 1932 | 1932 | $colors[$color['slug']] = esc_attr($color['color']); |
| 1933 | 1933 | } |
| 1934 | 1934 | } |
| 1935 | - }else{ |
|
| 1935 | + } else { |
|
| 1936 | 1936 | $settings = get_option('aui_options'); |
| 1937 | 1937 | $colors = array( |
| 1938 | - 'primary' => ! empty( $settings['color_primary'] ) ? $settings['color_primary'] : AUI_PRIMARY_COLOR, |
|
| 1939 | - 'secondary' => ! empty( $settings['color_secondary'] ) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR |
|
| 1938 | + 'primary' => !empty($settings['color_primary']) ? $settings['color_primary'] : AUI_PRIMARY_COLOR, |
|
| 1939 | + 'secondary' => !empty($settings['color_secondary']) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR |
|
| 1940 | 1940 | ); |
| 1941 | 1941 | } |
| 1942 | 1942 | |
@@ -1947,20 +1947,20 @@ discard block |
||
| 1947 | 1947 | <?php |
| 1948 | 1948 | |
| 1949 | 1949 | // BS v3 compat |
| 1950 | - if( self::is_bs3_compat() ){ |
|
| 1950 | + if (self::is_bs3_compat()) { |
|
| 1951 | 1951 | echo self::bs3_compat_css(); |
| 1952 | 1952 | } |
| 1953 | 1953 | |
| 1954 | - if(!empty($colors)){ |
|
| 1954 | + if (!empty($colors)) { |
|
| 1955 | 1955 | $d_colors = self::get_colors(true); |
| 1956 | 1956 | //print_r($d_colors );exit; |
| 1957 | 1957 | // print_r($colors );exit; |
| 1958 | - $is_fse = !empty($_REQUEST['postType']) && $_REQUEST['postType']=='wp_template'; |
|
| 1959 | - foreach($colors as $key => $color ){ |
|
| 1960 | - if((empty( $d_colors[$key]) || $d_colors[$key] != $color) || $is_fse ) { |
|
| 1958 | + $is_fse = !empty($_REQUEST['postType']) && $_REQUEST['postType'] == 'wp_template'; |
|
| 1959 | + foreach ($colors as $key => $color) { |
|
| 1960 | + if ((empty($d_colors[$key]) || $d_colors[$key] != $color) || $is_fse) { |
|
| 1961 | 1961 | $var = $is_fse ? "var(--wp--preset--color--$key)" : $color; |
| 1962 | 1962 | $compat = $is_fse ? '.editor-styles-wrapper' : $compatibility; |
| 1963 | - echo self::css_overwrite($key,$var,$compat); |
|
| 1963 | + echo self::css_overwrite($key, $var, $compat); |
|
| 1964 | 1964 | } |
| 1965 | 1965 | } |
| 1966 | 1966 | // exit; |
@@ -1969,7 +1969,7 @@ discard block |
||
| 1969 | 1969 | // Set admin bar z-index lower when modal is open. |
| 1970 | 1970 | echo ' body.modal-open #wpadminbar{z-index:999}.embed-responsive-16by9 .fluid-width-video-wrapper{padding:0 !important;position:initial}'; |
| 1971 | 1971 | |
| 1972 | - if(is_admin()){ |
|
| 1972 | + if (is_admin()) { |
|
| 1973 | 1973 | echo ' body.modal-open #adminmenuwrap{z-index:999} body.modal-open #wpadminbar{z-index:1025}'; |
| 1974 | 1974 | } |
| 1975 | 1975 | ?> |
@@ -1980,10 +1980,10 @@ discard block |
||
| 1980 | 1980 | /* |
| 1981 | 1981 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1982 | 1982 | */ |
| 1983 | - return str_replace( array( |
|
| 1983 | + return str_replace(array( |
|
| 1984 | 1984 | '<style>', |
| 1985 | 1985 | '</style>' |
| 1986 | - ), '', self::minify_css( ob_get_clean() ) ); |
|
| 1986 | + ), '', self::minify_css(ob_get_clean())); |
|
| 1987 | 1987 | } |
| 1988 | 1988 | |
| 1989 | 1989 | |
@@ -1993,7 +1993,7 @@ discard block |
||
| 1993 | 1993 | * |
| 1994 | 1994 | * @return bool |
| 1995 | 1995 | */ |
| 1996 | - public static function is_bs3_compat(){ |
|
| 1996 | + public static function is_bs3_compat() { |
|
| 1997 | 1997 | return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION'); |
| 1998 | 1998 | } |
| 1999 | 1999 | |
@@ -2006,22 +2006,22 @@ discard block |
||
| 2006 | 2006 | * |
| 2007 | 2007 | * @return string |
| 2008 | 2008 | */ |
| 2009 | - public static function css_overwrite($type,$color_code,$compatibility){ |
|
| 2009 | + public static function css_overwrite($type, $color_code, $compatibility) { |
|
| 2010 | 2010 | |
| 2011 | 2011 | $is_var = false; |
| 2012 | - if(!$color_code){return '';} |
|
| 2013 | - if(!sanitize_hex_color($color_code)){ |
|
| 2012 | + if (!$color_code) {return ''; } |
|
| 2013 | + if (!sanitize_hex_color($color_code)) { |
|
| 2014 | 2014 | $color_code = esc_attr($color_code); |
| 2015 | 2015 | $is_var = true; |
| 2016 | 2016 | // echo '###1'.$color_code;//exit; |
| 2017 | 2017 | } |
| 2018 | - if(!$color_code){return '';} |
|
| 2018 | + if (!$color_code) {return ''; } |
|
| 2019 | 2019 | |
| 2020 | - if($compatibility===true || $compatibility===1){ |
|
| 2020 | + if ($compatibility === true || $compatibility === 1) { |
|
| 2021 | 2021 | $compatibility = '.bsui'; |
| 2022 | - }elseif(!$compatibility){ |
|
| 2022 | + }elseif (!$compatibility) { |
|
| 2023 | 2023 | $compatibility = ''; |
| 2024 | - }else{ |
|
| 2024 | + } else { |
|
| 2025 | 2025 | $compatibility = esc_attr($compatibility); |
| 2026 | 2026 | } |
| 2027 | 2027 | |
@@ -2033,25 +2033,25 @@ discard block |
||
| 2033 | 2033 | * c = color, b = background color, o = border-color, f = fill |
| 2034 | 2034 | */ |
| 2035 | 2035 | $selectors = array( |
| 2036 | - ".btn-{$type}" => array( 'b', 'o' ), |
|
| 2037 | - ".btn-{$type}.disabled" => array( 'b', 'o' ), |
|
| 2038 | - ".btn-{$type}:disabled" => array( 'b', 'o' ), |
|
| 2039 | - ".btn-outline-{$type}" => array( 'c', 'o' ), |
|
| 2040 | - ".btn-outline-{$type}:hover" => array( 'b', 'o' ), |
|
| 2041 | - ".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ), |
|
| 2042 | - ".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ), |
|
| 2043 | - ".show>.btn-outline-{$type}.dropdown-toggle" => array( 'b', 'o' ), |
|
| 2044 | - ".badge-{$type}" => array( 'b' ), |
|
| 2045 | - ".alert-{$type}" => array( 'b', 'o' ), |
|
| 2046 | - ".bg-{$type}" => array( 'b', 'f' ), |
|
| 2047 | - ".btn-link.btn-{$type}" => array( 'c' ), |
|
| 2036 | + ".btn-{$type}" => array('b', 'o'), |
|
| 2037 | + ".btn-{$type}.disabled" => array('b', 'o'), |
|
| 2038 | + ".btn-{$type}:disabled" => array('b', 'o'), |
|
| 2039 | + ".btn-outline-{$type}" => array('c', 'o'), |
|
| 2040 | + ".btn-outline-{$type}:hover" => array('b', 'o'), |
|
| 2041 | + ".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array('b', 'o'), |
|
| 2042 | + ".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array('b', 'o'), |
|
| 2043 | + ".show>.btn-outline-{$type}.dropdown-toggle" => array('b', 'o'), |
|
| 2044 | + ".badge-{$type}" => array('b'), |
|
| 2045 | + ".alert-{$type}" => array('b', 'o'), |
|
| 2046 | + ".bg-{$type}" => array('b', 'f'), |
|
| 2047 | + ".btn-link.btn-{$type}" => array('c'), |
|
| 2048 | 2048 | ); |
| 2049 | 2049 | |
| 2050 | - if ( $type == 'primary' ) { |
|
| 2050 | + if ($type == 'primary') { |
|
| 2051 | 2051 | $selectors = $selectors + array( |
| 2052 | - 'a' => array( 'c' ), |
|
| 2053 | - '.btn-link' => array( 'c' ), |
|
| 2054 | - '.dropdown-item.active' => array( 'b' ), |
|
| 2052 | + 'a' => array('c'), |
|
| 2053 | + '.btn-link' => array('c'), |
|
| 2054 | + '.dropdown-item.active' => array('b'), |
|
| 2055 | 2055 | '.custom-control-input:checked~.custom-control-label::before' => array( |
| 2056 | 2056 | 'b', |
| 2057 | 2057 | 'o' |
@@ -2060,19 +2060,19 @@ discard block |
||
| 2060 | 2060 | 'b', |
| 2061 | 2061 | 'o' |
| 2062 | 2062 | ), |
| 2063 | - '.nav-pills .nav-link.active' => array( 'b' ), |
|
| 2064 | - '.nav-pills .show>.nav-link' => array( 'b' ), |
|
| 2065 | - '.page-link' => array( 'c' ), |
|
| 2063 | + '.nav-pills .nav-link.active' => array('b'), |
|
| 2064 | + '.nav-pills .show>.nav-link' => array('b'), |
|
| 2065 | + '.page-link' => array('c'), |
|
| 2066 | 2066 | '.page-item.active .page-link' => array( |
| 2067 | 2067 | 'b', |
| 2068 | 2068 | 'o' |
| 2069 | 2069 | ), |
| 2070 | - '.progress-bar' => array( 'b' ), |
|
| 2070 | + '.progress-bar' => array('b'), |
|
| 2071 | 2071 | '.list-group-item.active' => array( |
| 2072 | 2072 | 'b', |
| 2073 | 2073 | 'o' |
| 2074 | 2074 | ), |
| 2075 | - '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ), |
|
| 2075 | + '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
|
| 2076 | 2076 | // '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules... |
| 2077 | 2077 | // '.custom-range::-moz-range-thumb' => array('b'), |
| 2078 | 2078 | // '.custom-range::-ms-thumb' => array('b'), |
@@ -2080,7 +2080,7 @@ discard block |
||
| 2080 | 2080 | } |
| 2081 | 2081 | |
| 2082 | 2082 | $important_selectors = array( |
| 2083 | - ".bg-{$type}" => array('b','f'), |
|
| 2083 | + ".bg-{$type}" => array('b', 'f'), |
|
| 2084 | 2084 | ".border-{$type}" => array('o'), |
| 2085 | 2085 | ".text-{$type}" => array('c'), |
| 2086 | 2086 | ); |
@@ -2097,55 +2097,55 @@ discard block |
||
| 2097 | 2097 | $output = ''; |
| 2098 | 2098 | |
| 2099 | 2099 | // build rules into each type |
| 2100 | - foreach($selectors as $selector => $types){ |
|
| 2101 | - $selector = $compatibility ? $compatibility . " ".$selector : $selector; |
|
| 2102 | - $types = array_combine($types,$types); |
|
| 2103 | - if(isset($types['c'])){$color[] = $selector;} |
|
| 2104 | - if(isset($types['b'])){$background[] = $selector;} |
|
| 2105 | - if(isset($types['o'])){$border[] = $selector;} |
|
| 2106 | - if(isset($types['f'])){$fill[] = $selector;} |
|
| 2100 | + foreach ($selectors as $selector => $types) { |
|
| 2101 | + $selector = $compatibility ? $compatibility . " " . $selector : $selector; |
|
| 2102 | + $types = array_combine($types, $types); |
|
| 2103 | + if (isset($types['c'])) {$color[] = $selector; } |
|
| 2104 | + if (isset($types['b'])) {$background[] = $selector; } |
|
| 2105 | + if (isset($types['o'])) {$border[] = $selector; } |
|
| 2106 | + if (isset($types['f'])) {$fill[] = $selector; } |
|
| 2107 | 2107 | } |
| 2108 | 2108 | |
| 2109 | 2109 | // build rules into each type |
| 2110 | - foreach($important_selectors as $selector => $types){ |
|
| 2111 | - $selector = $compatibility ? $compatibility . " ".$selector : $selector; |
|
| 2112 | - $types = array_combine($types,$types); |
|
| 2113 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
| 2114 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
| 2115 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
| 2116 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 2110 | + foreach ($important_selectors as $selector => $types) { |
|
| 2111 | + $selector = $compatibility ? $compatibility . " " . $selector : $selector; |
|
| 2112 | + $types = array_combine($types, $types); |
|
| 2113 | + if (isset($types['c'])) {$color_i[] = $selector; } |
|
| 2114 | + if (isset($types['b'])) {$background_i[] = $selector; } |
|
| 2115 | + if (isset($types['o'])) {$border_i[] = $selector; } |
|
| 2116 | + if (isset($types['f'])) {$fill_i[] = $selector; } |
|
| 2117 | 2117 | } |
| 2118 | 2118 | |
| 2119 | 2119 | // add any color rules |
| 2120 | - if(!empty($color)){ |
|
| 2121 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 2120 | + if (!empty($color)) { |
|
| 2121 | + $output .= implode(",", $color) . "{color: $color_code;} "; |
|
| 2122 | 2122 | } |
| 2123 | - if(!empty($color_i)){ |
|
| 2124 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 2123 | + if (!empty($color_i)) { |
|
| 2124 | + $output .= implode(",", $color_i) . "{color: $color_code !important;} "; |
|
| 2125 | 2125 | } |
| 2126 | 2126 | |
| 2127 | 2127 | // add any background color rules |
| 2128 | - if(!empty($background)){ |
|
| 2129 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 2128 | + if (!empty($background)) { |
|
| 2129 | + $output .= implode(",", $background) . "{background-color: $color_code;} "; |
|
| 2130 | 2130 | } |
| 2131 | - if(!empty($background_i)){ |
|
| 2132 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 2131 | + if (!empty($background_i)) { |
|
| 2132 | + $output .= implode(",", $background_i) . "{background-color: $color_code !important;} "; |
|
| 2133 | 2133 | } |
| 2134 | 2134 | |
| 2135 | 2135 | // add any border color rules |
| 2136 | - if(!empty($border)){ |
|
| 2137 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 2136 | + if (!empty($border)) { |
|
| 2137 | + $output .= implode(",", $border) . "{border-color: $color_code;} "; |
|
| 2138 | 2138 | } |
| 2139 | - if(!empty($border_i)){ |
|
| 2140 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 2139 | + if (!empty($border_i)) { |
|
| 2140 | + $output .= implode(",", $border_i) . "{border-color: $color_code !important;} "; |
|
| 2141 | 2141 | } |
| 2142 | 2142 | |
| 2143 | 2143 | // add any fill color rules |
| 2144 | - if(!empty($fill)){ |
|
| 2145 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 2144 | + if (!empty($fill)) { |
|
| 2145 | + $output .= implode(",", $fill) . "{fill: $color_code;} "; |
|
| 2146 | 2146 | } |
| 2147 | - if(!empty($fill_i)){ |
|
| 2148 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 2147 | + if (!empty($fill_i)) { |
|
| 2148 | + $output .= implode(",", $fill_i) . "{fill: $color_code !important;} "; |
|
| 2149 | 2149 | } |
| 2150 | 2150 | |
| 2151 | 2151 | |
@@ -2153,26 +2153,26 @@ discard block |
||
| 2153 | 2153 | |
| 2154 | 2154 | $transition = $is_var ? 'transition: color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out,filter 0.15s ease-in-out;' : ''; |
| 2155 | 2155 | // darken |
| 2156 | - $darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 2157 | - $darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 2158 | - $darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 2156 | + $darker_075 = $is_var ? $color_code . ';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code, "-0.075"); |
|
| 2157 | + $darker_10 = $is_var ? $color_code . ';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code, "-0.10"); |
|
| 2158 | + $darker_125 = $is_var ? $color_code . ';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code, "-0.125"); |
|
| 2159 | 2159 | |
| 2160 | 2160 | // lighten |
| 2161 | - $lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 2161 | + $lighten_25 = $is_var ? $color_code . ';filter:brightness(1.25)' : self::css_hex_lighten_darken($color_code, "0.25"); |
|
| 2162 | 2162 | |
| 2163 | 2163 | // opacity see https://css-tricks.com/8-digit-hex-codes/ |
| 2164 | - $op_25 = $color_code."40"; // 25% opacity |
|
| 2164 | + $op_25 = $color_code . "40"; // 25% opacity |
|
| 2165 | 2165 | |
| 2166 | 2166 | |
| 2167 | 2167 | // button states |
| 2168 | - $output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : ''; |
|
| 2169 | - $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 2168 | + $output .= $is_var ? $prefix . " .btn-{$type}{{$transition }} " : ''; |
|
| 2169 | + $output .= $prefix . " .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: " . $darker_075 . "; border-color: " . $darker_10 . ";} "; |
|
| 2170 | 2170 | // $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: #000; border-color: #000;} "; |
| 2171 | - $output .= $prefix ." .btn-outline-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-{$type}.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2172 | - $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active, $prefix .btn-{$type}:not(:disabled):not(.disabled).active, .show>$prefix .btn-{$type}.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
| 2173 | - $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-{$type}.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2171 | + $output .= $prefix . " .btn-outline-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-{$type}.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2172 | + $output .= $prefix . " .btn-{$type}:not(:disabled):not(.disabled):active, $prefix .btn-{$type}:not(:disabled):not(.disabled).active, .show>$prefix .btn-{$type}.dropdown-toggle{background-color: " . $darker_10 . "; border-color: " . $darker_125 . ";} "; |
|
| 2173 | + $output .= $prefix . " .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-{$type}.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2174 | 2174 | |
| 2175 | - if ( $type == 'primary' ) { |
|
| 2175 | + if ($type == 'primary') { |
|
| 2176 | 2176 | // dropdown's |
| 2177 | 2177 | $output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
| 2178 | 2178 | |
@@ -2196,11 +2196,11 @@ discard block |
||
| 2196 | 2196 | * |
| 2197 | 2197 | * @return string |
| 2198 | 2198 | */ |
| 2199 | - public static function css_primary($color_code,$compatibility, $use_variable = false){ |
|
| 2199 | + public static function css_primary($color_code, $compatibility, $use_variable = false) { |
|
| 2200 | 2200 | |
| 2201 | - if(!$use_variable){ |
|
| 2201 | + if (!$use_variable) { |
|
| 2202 | 2202 | $color_code = sanitize_hex_color($color_code); |
| 2203 | - if(!$color_code){return '';} |
|
| 2203 | + if (!$color_code) {return ''; } |
|
| 2204 | 2204 | } |
| 2205 | 2205 | |
| 2206 | 2206 | /** |
@@ -2208,36 +2208,36 @@ discard block |
||
| 2208 | 2208 | */ |
| 2209 | 2209 | $selectors = array( |
| 2210 | 2210 | 'a' => array('c'), |
| 2211 | - '.btn-primary' => array('b','o'), |
|
| 2212 | - '.btn-primary.disabled' => array('b','o'), |
|
| 2213 | - '.btn-primary:disabled' => array('b','o'), |
|
| 2214 | - '.btn-outline-primary' => array('c','o'), |
|
| 2215 | - '.btn-outline-primary:hover' => array('b','o'), |
|
| 2216 | - '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
| 2217 | - '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
| 2218 | - '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
|
| 2211 | + '.btn-primary' => array('b', 'o'), |
|
| 2212 | + '.btn-primary.disabled' => array('b', 'o'), |
|
| 2213 | + '.btn-primary:disabled' => array('b', 'o'), |
|
| 2214 | + '.btn-outline-primary' => array('c', 'o'), |
|
| 2215 | + '.btn-outline-primary:hover' => array('b', 'o'), |
|
| 2216 | + '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b', 'o'), |
|
| 2217 | + '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b', 'o'), |
|
| 2218 | + '.show>.btn-outline-primary.dropdown-toggle' => array('b', 'o'), |
|
| 2219 | 2219 | '.btn-link' => array('c'), |
| 2220 | 2220 | '.dropdown-item.active' => array('b'), |
| 2221 | - '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
|
| 2222 | - '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
|
| 2221 | + '.custom-control-input:checked~.custom-control-label::before' => array('b', 'o'), |
|
| 2222 | + '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b', 'o'), |
|
| 2223 | 2223 | // '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules... |
| 2224 | 2224 | // '.custom-range::-moz-range-thumb' => array('b'), |
| 2225 | 2225 | // '.custom-range::-ms-thumb' => array('b'), |
| 2226 | 2226 | '.nav-pills .nav-link.active' => array('b'), |
| 2227 | 2227 | '.nav-pills .show>.nav-link' => array('b'), |
| 2228 | 2228 | '.page-link' => array('c'), |
| 2229 | - '.page-item.active .page-link' => array('b','o'), |
|
| 2229 | + '.page-item.active .page-link' => array('b', 'o'), |
|
| 2230 | 2230 | '.badge-primary' => array('b'), |
| 2231 | - '.alert-primary' => array('b','o'), |
|
| 2231 | + '.alert-primary' => array('b', 'o'), |
|
| 2232 | 2232 | '.progress-bar' => array('b'), |
| 2233 | - '.list-group-item.active' => array('b','o'), |
|
| 2234 | - '.bg-primary' => array('b','f'), |
|
| 2233 | + '.list-group-item.active' => array('b', 'o'), |
|
| 2234 | + '.bg-primary' => array('b', 'f'), |
|
| 2235 | 2235 | '.btn-link.btn-primary' => array('c'), |
| 2236 | 2236 | '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
| 2237 | 2237 | ); |
| 2238 | 2238 | |
| 2239 | 2239 | $important_selectors = array( |
| 2240 | - '.bg-primary' => array('b','f'), |
|
| 2240 | + '.bg-primary' => array('b', 'f'), |
|
| 2241 | 2241 | '.border-primary' => array('o'), |
| 2242 | 2242 | '.text-primary' => array('c'), |
| 2243 | 2243 | ); |
@@ -2254,88 +2254,88 @@ discard block |
||
| 2254 | 2254 | $output = ''; |
| 2255 | 2255 | |
| 2256 | 2256 | // build rules into each type |
| 2257 | - foreach($selectors as $selector => $types){ |
|
| 2258 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 2259 | - $types = array_combine($types,$types); |
|
| 2260 | - if(isset($types['c'])){$color[] = $selector;} |
|
| 2261 | - if(isset($types['b'])){$background[] = $selector;} |
|
| 2262 | - if(isset($types['o'])){$border[] = $selector;} |
|
| 2263 | - if(isset($types['f'])){$fill[] = $selector;} |
|
| 2257 | + foreach ($selectors as $selector => $types) { |
|
| 2258 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
| 2259 | + $types = array_combine($types, $types); |
|
| 2260 | + if (isset($types['c'])) {$color[] = $selector; } |
|
| 2261 | + if (isset($types['b'])) {$background[] = $selector; } |
|
| 2262 | + if (isset($types['o'])) {$border[] = $selector; } |
|
| 2263 | + if (isset($types['f'])) {$fill[] = $selector; } |
|
| 2264 | 2264 | } |
| 2265 | 2265 | |
| 2266 | 2266 | // build rules into each type |
| 2267 | - foreach($important_selectors as $selector => $types){ |
|
| 2268 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 2269 | - $types = array_combine($types,$types); |
|
| 2270 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
| 2271 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
| 2272 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
| 2273 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 2267 | + foreach ($important_selectors as $selector => $types) { |
|
| 2268 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
| 2269 | + $types = array_combine($types, $types); |
|
| 2270 | + if (isset($types['c'])) {$color_i[] = $selector; } |
|
| 2271 | + if (isset($types['b'])) {$background_i[] = $selector; } |
|
| 2272 | + if (isset($types['o'])) {$border_i[] = $selector; } |
|
| 2273 | + if (isset($types['f'])) {$fill_i[] = $selector; } |
|
| 2274 | 2274 | } |
| 2275 | 2275 | |
| 2276 | 2276 | // add any color rules |
| 2277 | - if(!empty($color)){ |
|
| 2278 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 2277 | + if (!empty($color)) { |
|
| 2278 | + $output .= implode(",", $color) . "{color: $color_code;} "; |
|
| 2279 | 2279 | } |
| 2280 | - if(!empty($color_i)){ |
|
| 2281 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 2280 | + if (!empty($color_i)) { |
|
| 2281 | + $output .= implode(",", $color_i) . "{color: $color_code !important;} "; |
|
| 2282 | 2282 | } |
| 2283 | 2283 | |
| 2284 | 2284 | // add any background color rules |
| 2285 | - if(!empty($background)){ |
|
| 2286 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 2285 | + if (!empty($background)) { |
|
| 2286 | + $output .= implode(",", $background) . "{background-color: $color_code;} "; |
|
| 2287 | 2287 | } |
| 2288 | - if(!empty($background_i)){ |
|
| 2289 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 2288 | + if (!empty($background_i)) { |
|
| 2289 | + $output .= implode(",", $background_i) . "{background-color: $color_code !important;} "; |
|
| 2290 | 2290 | } |
| 2291 | 2291 | |
| 2292 | 2292 | // add any border color rules |
| 2293 | - if(!empty($border)){ |
|
| 2294 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 2293 | + if (!empty($border)) { |
|
| 2294 | + $output .= implode(",", $border) . "{border-color: $color_code;} "; |
|
| 2295 | 2295 | } |
| 2296 | - if(!empty($border_i)){ |
|
| 2297 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 2296 | + if (!empty($border_i)) { |
|
| 2297 | + $output .= implode(",", $border_i) . "{border-color: $color_code !important;} "; |
|
| 2298 | 2298 | } |
| 2299 | 2299 | |
| 2300 | 2300 | // add any fill color rules |
| 2301 | - if(!empty($fill)){ |
|
| 2302 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 2301 | + if (!empty($fill)) { |
|
| 2302 | + $output .= implode(",", $fill) . "{fill: $color_code;} "; |
|
| 2303 | 2303 | } |
| 2304 | - if(!empty($fill_i)){ |
|
| 2305 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 2304 | + if (!empty($fill_i)) { |
|
| 2305 | + $output .= implode(",", $fill_i) . "{fill: $color_code !important;} "; |
|
| 2306 | 2306 | } |
| 2307 | 2307 | |
| 2308 | 2308 | |
| 2309 | 2309 | $prefix = $compatibility ? ".bsui " : ""; |
| 2310 | 2310 | |
| 2311 | 2311 | // darken |
| 2312 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 2313 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 2314 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 2312 | + $darker_075 = self::css_hex_lighten_darken($color_code, "-0.075"); |
|
| 2313 | + $darker_10 = self::css_hex_lighten_darken($color_code, "-0.10"); |
|
| 2314 | + $darker_125 = self::css_hex_lighten_darken($color_code, "-0.125"); |
|
| 2315 | 2315 | |
| 2316 | 2316 | // lighten |
| 2317 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 2317 | + $lighten_25 = self::css_hex_lighten_darken($color_code, "0.25"); |
|
| 2318 | 2318 | |
| 2319 | 2319 | // opacity see https://css-tricks.com/8-digit-hex-codes/ |
| 2320 | - $op_25 = $color_code."40"; // 25% opacity |
|
| 2320 | + $op_25 = $color_code . "40"; // 25% opacity |
|
| 2321 | 2321 | |
| 2322 | 2322 | |
| 2323 | 2323 | // button states |
| 2324 | - $output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 2325 | - $output .= $prefix ." .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2326 | - $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
| 2327 | - $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2324 | + $output .= $prefix . " .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: " . $darker_075 . "; border-color: " . $darker_10 . ";} "; |
|
| 2325 | + $output .= $prefix . " .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2326 | + $output .= $prefix . " .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: " . $darker_10 . "; border-color: " . $darker_125 . ";} "; |
|
| 2327 | + $output .= $prefix . " .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2328 | 2328 | |
| 2329 | 2329 | |
| 2330 | 2330 | // dropdown's |
| 2331 | - $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
| 2331 | + $output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
| 2332 | 2332 | |
| 2333 | 2333 | |
| 2334 | 2334 | // input states |
| 2335 | - $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2335 | + $output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2336 | 2336 | |
| 2337 | 2337 | // page link |
| 2338 | - $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2338 | + $output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2339 | 2339 | |
| 2340 | 2340 | return $output; |
| 2341 | 2341 | } |
@@ -2349,30 +2349,30 @@ discard block |
||
| 2349 | 2349 | * |
| 2350 | 2350 | * @return string |
| 2351 | 2351 | */ |
| 2352 | - public static function css_secondary($color_code,$compatibility){; |
|
| 2352 | + public static function css_secondary($color_code, $compatibility) {; |
|
| 2353 | 2353 | $color_code = sanitize_hex_color($color_code); |
| 2354 | - if(!$color_code){return '';} |
|
| 2354 | + if (!$color_code) {return ''; } |
|
| 2355 | 2355 | /** |
| 2356 | 2356 | * c = color, b = background color, o = border-color, f = fill |
| 2357 | 2357 | */ |
| 2358 | 2358 | $selectors = array( |
| 2359 | - '.btn-secondary' => array('b','o'), |
|
| 2360 | - '.btn-secondary.disabled' => array('b','o'), |
|
| 2361 | - '.btn-secondary:disabled' => array('b','o'), |
|
| 2362 | - '.btn-outline-secondary' => array('c','o'), |
|
| 2363 | - '.btn-outline-secondary:hover' => array('b','o'), |
|
| 2359 | + '.btn-secondary' => array('b', 'o'), |
|
| 2360 | + '.btn-secondary.disabled' => array('b', 'o'), |
|
| 2361 | + '.btn-secondary:disabled' => array('b', 'o'), |
|
| 2362 | + '.btn-outline-secondary' => array('c', 'o'), |
|
| 2363 | + '.btn-outline-secondary:hover' => array('b', 'o'), |
|
| 2364 | 2364 | '.btn-outline-secondary.disabled' => array('c'), |
| 2365 | 2365 | '.btn-outline-secondary:disabled' => array('c'), |
| 2366 | - '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
| 2367 | - '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
| 2368 | - '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
|
| 2366 | + '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b', 'o'), |
|
| 2367 | + '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b', 'o'), |
|
| 2368 | + '.btn-outline-secondary.dropdown-toggle' => array('b', 'o'), |
|
| 2369 | 2369 | '.badge-secondary' => array('b'), |
| 2370 | - '.alert-secondary' => array('b','o'), |
|
| 2370 | + '.alert-secondary' => array('b', 'o'), |
|
| 2371 | 2371 | '.btn-link.btn-secondary' => array('c'), |
| 2372 | 2372 | ); |
| 2373 | 2373 | |
| 2374 | 2374 | $important_selectors = array( |
| 2375 | - '.bg-secondary' => array('b','f'), |
|
| 2375 | + '.bg-secondary' => array('b', 'f'), |
|
| 2376 | 2376 | '.border-secondary' => array('o'), |
| 2377 | 2377 | '.text-secondary' => array('c'), |
| 2378 | 2378 | ); |
@@ -2389,77 +2389,77 @@ discard block |
||
| 2389 | 2389 | $output = ''; |
| 2390 | 2390 | |
| 2391 | 2391 | // build rules into each type |
| 2392 | - foreach($selectors as $selector => $types){ |
|
| 2393 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 2394 | - $types = array_combine($types,$types); |
|
| 2395 | - if(isset($types['c'])){$color[] = $selector;} |
|
| 2396 | - if(isset($types['b'])){$background[] = $selector;} |
|
| 2397 | - if(isset($types['o'])){$border[] = $selector;} |
|
| 2398 | - if(isset($types['f'])){$fill[] = $selector;} |
|
| 2392 | + foreach ($selectors as $selector => $types) { |
|
| 2393 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
| 2394 | + $types = array_combine($types, $types); |
|
| 2395 | + if (isset($types['c'])) {$color[] = $selector; } |
|
| 2396 | + if (isset($types['b'])) {$background[] = $selector; } |
|
| 2397 | + if (isset($types['o'])) {$border[] = $selector; } |
|
| 2398 | + if (isset($types['f'])) {$fill[] = $selector; } |
|
| 2399 | 2399 | } |
| 2400 | 2400 | |
| 2401 | 2401 | // build rules into each type |
| 2402 | - foreach($important_selectors as $selector => $types){ |
|
| 2403 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
| 2404 | - $types = array_combine($types,$types); |
|
| 2405 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
| 2406 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
| 2407 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
| 2408 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
| 2402 | + foreach ($important_selectors as $selector => $types) { |
|
| 2403 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
| 2404 | + $types = array_combine($types, $types); |
|
| 2405 | + if (isset($types['c'])) {$color_i[] = $selector; } |
|
| 2406 | + if (isset($types['b'])) {$background_i[] = $selector; } |
|
| 2407 | + if (isset($types['o'])) {$border_i[] = $selector; } |
|
| 2408 | + if (isset($types['f'])) {$fill_i[] = $selector; } |
|
| 2409 | 2409 | } |
| 2410 | 2410 | |
| 2411 | 2411 | // add any color rules |
| 2412 | - if(!empty($color)){ |
|
| 2413 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
| 2412 | + if (!empty($color)) { |
|
| 2413 | + $output .= implode(",", $color) . "{color: $color_code;} "; |
|
| 2414 | 2414 | } |
| 2415 | - if(!empty($color_i)){ |
|
| 2416 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
| 2415 | + if (!empty($color_i)) { |
|
| 2416 | + $output .= implode(",", $color_i) . "{color: $color_code !important;} "; |
|
| 2417 | 2417 | } |
| 2418 | 2418 | |
| 2419 | 2419 | // add any background color rules |
| 2420 | - if(!empty($background)){ |
|
| 2421 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
| 2420 | + if (!empty($background)) { |
|
| 2421 | + $output .= implode(",", $background) . "{background-color: $color_code;} "; |
|
| 2422 | 2422 | } |
| 2423 | - if(!empty($background_i)){ |
|
| 2424 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
| 2423 | + if (!empty($background_i)) { |
|
| 2424 | + $output .= implode(",", $background_i) . "{background-color: $color_code !important;} "; |
|
| 2425 | 2425 | } |
| 2426 | 2426 | |
| 2427 | 2427 | // add any border color rules |
| 2428 | - if(!empty($border)){ |
|
| 2429 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
| 2428 | + if (!empty($border)) { |
|
| 2429 | + $output .= implode(",", $border) . "{border-color: $color_code;} "; |
|
| 2430 | 2430 | } |
| 2431 | - if(!empty($border_i)){ |
|
| 2432 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
| 2431 | + if (!empty($border_i)) { |
|
| 2432 | + $output .= implode(",", $border_i) . "{border-color: $color_code !important;} "; |
|
| 2433 | 2433 | } |
| 2434 | 2434 | |
| 2435 | 2435 | // add any fill color rules |
| 2436 | - if(!empty($fill)){ |
|
| 2437 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
| 2436 | + if (!empty($fill)) { |
|
| 2437 | + $output .= implode(",", $fill) . "{fill: $color_code;} "; |
|
| 2438 | 2438 | } |
| 2439 | - if(!empty($fill_i)){ |
|
| 2440 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
| 2439 | + if (!empty($fill_i)) { |
|
| 2440 | + $output .= implode(",", $fill_i) . "{fill: $color_code !important;} "; |
|
| 2441 | 2441 | } |
| 2442 | 2442 | |
| 2443 | 2443 | |
| 2444 | 2444 | $prefix = $compatibility ? ".bsui " : ""; |
| 2445 | 2445 | |
| 2446 | 2446 | // darken |
| 2447 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
| 2448 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
| 2449 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
| 2447 | + $darker_075 = self::css_hex_lighten_darken($color_code, "-0.075"); |
|
| 2448 | + $darker_10 = self::css_hex_lighten_darken($color_code, "-0.10"); |
|
| 2449 | + $darker_125 = self::css_hex_lighten_darken($color_code, "-0.125"); |
|
| 2450 | 2450 | |
| 2451 | 2451 | // lighten |
| 2452 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
| 2452 | + $lighten_25 = self::css_hex_lighten_darken($color_code, "0.25"); |
|
| 2453 | 2453 | |
| 2454 | 2454 | // opacity see https://css-tricks.com/8-digit-hex-codes/ |
| 2455 | - $op_25 = $color_code."40"; // 25% opacity |
|
| 2455 | + $op_25 = $color_code . "40"; // 25% opacity |
|
| 2456 | 2456 | |
| 2457 | 2457 | |
| 2458 | 2458 | // button states |
| 2459 | - $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
| 2460 | - $output .= $prefix ." .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2461 | - $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
| 2462 | - $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2459 | + $output .= $prefix . " .btn-secondary:hover{background-color: " . $darker_075 . "; border-color: " . $darker_10 . ";} "; |
|
| 2460 | + $output .= $prefix . " .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2461 | + $output .= $prefix . " .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: " . $darker_10 . "; border-color: " . $darker_125 . ";} "; |
|
| 2462 | + $output .= $prefix . " .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
| 2463 | 2463 | |
| 2464 | 2464 | |
| 2465 | 2465 | return $output; |
@@ -2495,8 +2495,8 @@ discard block |
||
| 2495 | 2495 | /** |
| 2496 | 2496 | * Check if we should display examples. |
| 2497 | 2497 | */ |
| 2498 | - public function maybe_show_examples(){ |
|
| 2499 | - if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
| 2498 | + public function maybe_show_examples() { |
|
| 2499 | + if (current_user_can('manage_options') && isset($_REQUEST['preview-aui'])) { |
|
| 2500 | 2500 | echo "<head>"; |
| 2501 | 2501 | wp_head(); |
| 2502 | 2502 | echo "</head>"; |
@@ -2512,7 +2512,7 @@ discard block |
||
| 2512 | 2512 | * |
| 2513 | 2513 | * @return string |
| 2514 | 2514 | */ |
| 2515 | - public function get_examples(){ |
|
| 2515 | + public function get_examples() { |
|
| 2516 | 2516 | $output = ''; |
| 2517 | 2517 | |
| 2518 | 2518 | |
@@ -2618,74 +2618,74 @@ discard block |
||
| 2618 | 2618 | */ |
| 2619 | 2619 | public static function calendar_params() { |
| 2620 | 2620 | $params = array( |
| 2621 | - 'month_long_1' => __( 'January', 'aui' ), |
|
| 2622 | - 'month_long_2' => __( 'February', 'aui' ), |
|
| 2623 | - 'month_long_3' => __( 'March', 'aui' ), |
|
| 2624 | - 'month_long_4' => __( 'April', 'aui' ), |
|
| 2625 | - 'month_long_5' => __( 'May', 'aui' ), |
|
| 2626 | - 'month_long_6' => __( 'June', 'aui' ), |
|
| 2627 | - 'month_long_7' => __( 'July', 'aui' ), |
|
| 2628 | - 'month_long_8' => __( 'August', 'aui' ), |
|
| 2629 | - 'month_long_9' => __( 'September', 'aui' ), |
|
| 2630 | - 'month_long_10' => __( 'October', 'aui' ), |
|
| 2631 | - 'month_long_11' => __( 'November', 'aui' ), |
|
| 2632 | - 'month_long_12' => __( 'December', 'aui' ), |
|
| 2633 | - 'month_s_1' => _x( 'Jan', 'January abbreviation', 'aui' ), |
|
| 2634 | - 'month_s_2' => _x( 'Feb', 'February abbreviation', 'aui' ), |
|
| 2635 | - 'month_s_3' => _x( 'Mar', 'March abbreviation', 'aui' ), |
|
| 2636 | - 'month_s_4' => _x( 'Apr', 'April abbreviation', 'aui' ), |
|
| 2637 | - 'month_s_5' => _x( 'May', 'May abbreviation', 'aui' ), |
|
| 2638 | - 'month_s_6' => _x( 'Jun', 'June abbreviation', 'aui' ), |
|
| 2639 | - 'month_s_7' => _x( 'Jul', 'July abbreviation', 'aui' ), |
|
| 2640 | - 'month_s_8' => _x( 'Aug', 'August abbreviation', 'aui' ), |
|
| 2641 | - 'month_s_9' => _x( 'Sep', 'September abbreviation', 'aui' ), |
|
| 2642 | - 'month_s_10' => _x( 'Oct', 'October abbreviation', 'aui' ), |
|
| 2643 | - 'month_s_11' => _x( 'Nov', 'November abbreviation', 'aui' ), |
|
| 2644 | - 'month_s_12' => _x( 'Dec', 'December abbreviation', 'aui' ), |
|
| 2645 | - 'day_s1_1' => _x( 'S', 'Sunday initial', 'aui' ), |
|
| 2646 | - 'day_s1_2' => _x( 'M', 'Monday initial', 'aui' ), |
|
| 2647 | - 'day_s1_3' => _x( 'T', 'Tuesday initial', 'aui' ), |
|
| 2648 | - 'day_s1_4' => _x( 'W', 'Wednesday initial', 'aui' ), |
|
| 2649 | - 'day_s1_5' => _x( 'T', 'Friday initial', 'aui' ), |
|
| 2650 | - 'day_s1_6' => _x( 'F', 'Thursday initial', 'aui' ), |
|
| 2651 | - 'day_s1_7' => _x( 'S', 'Saturday initial', 'aui' ), |
|
| 2652 | - 'day_s2_1' => __( 'Su', 'aui' ), |
|
| 2653 | - 'day_s2_2' => __( 'Mo', 'aui' ), |
|
| 2654 | - 'day_s2_3' => __( 'Tu', 'aui' ), |
|
| 2655 | - 'day_s2_4' => __( 'We', 'aui' ), |
|
| 2656 | - 'day_s2_5' => __( 'Th', 'aui' ), |
|
| 2657 | - 'day_s2_6' => __( 'Fr', 'aui' ), |
|
| 2658 | - 'day_s2_7' => __( 'Sa', 'aui' ), |
|
| 2659 | - 'day_s3_1' => __( 'Sun', 'aui' ), |
|
| 2660 | - 'day_s3_2' => __( 'Mon', 'aui' ), |
|
| 2661 | - 'day_s3_3' => __( 'Tue', 'aui' ), |
|
| 2662 | - 'day_s3_4' => __( 'Wed', 'aui' ), |
|
| 2663 | - 'day_s3_5' => __( 'Thu', 'aui' ), |
|
| 2664 | - 'day_s3_6' => __( 'Fri', 'aui' ), |
|
| 2665 | - 'day_s3_7' => __( 'Sat', 'aui' ), |
|
| 2666 | - 'day_s5_1' => __( 'Sunday', 'aui' ), |
|
| 2667 | - 'day_s5_2' => __( 'Monday', 'aui' ), |
|
| 2668 | - 'day_s5_3' => __( 'Tuesday', 'aui' ), |
|
| 2669 | - 'day_s5_4' => __( 'Wednesday', 'aui' ), |
|
| 2670 | - 'day_s5_5' => __( 'Thursday', 'aui' ), |
|
| 2671 | - 'day_s5_6' => __( 'Friday', 'aui' ), |
|
| 2672 | - 'day_s5_7' => __( 'Saturday', 'aui' ), |
|
| 2673 | - 'am_lower' => __( 'am', 'aui' ), |
|
| 2674 | - 'pm_lower' => __( 'pm', 'aui' ), |
|
| 2675 | - 'am_upper' => __( 'AM', 'aui' ), |
|
| 2676 | - 'pm_upper' => __( 'PM', 'aui' ), |
|
| 2677 | - 'firstDayOfWeek' => (int) get_option( 'start_of_week' ), |
|
| 2621 | + 'month_long_1' => __('January', 'aui'), |
|
| 2622 | + 'month_long_2' => __('February', 'aui'), |
|
| 2623 | + 'month_long_3' => __('March', 'aui'), |
|
| 2624 | + 'month_long_4' => __('April', 'aui'), |
|
| 2625 | + 'month_long_5' => __('May', 'aui'), |
|
| 2626 | + 'month_long_6' => __('June', 'aui'), |
|
| 2627 | + 'month_long_7' => __('July', 'aui'), |
|
| 2628 | + 'month_long_8' => __('August', 'aui'), |
|
| 2629 | + 'month_long_9' => __('September', 'aui'), |
|
| 2630 | + 'month_long_10' => __('October', 'aui'), |
|
| 2631 | + 'month_long_11' => __('November', 'aui'), |
|
| 2632 | + 'month_long_12' => __('December', 'aui'), |
|
| 2633 | + 'month_s_1' => _x('Jan', 'January abbreviation', 'aui'), |
|
| 2634 | + 'month_s_2' => _x('Feb', 'February abbreviation', 'aui'), |
|
| 2635 | + 'month_s_3' => _x('Mar', 'March abbreviation', 'aui'), |
|
| 2636 | + 'month_s_4' => _x('Apr', 'April abbreviation', 'aui'), |
|
| 2637 | + 'month_s_5' => _x('May', 'May abbreviation', 'aui'), |
|
| 2638 | + 'month_s_6' => _x('Jun', 'June abbreviation', 'aui'), |
|
| 2639 | + 'month_s_7' => _x('Jul', 'July abbreviation', 'aui'), |
|
| 2640 | + 'month_s_8' => _x('Aug', 'August abbreviation', 'aui'), |
|
| 2641 | + 'month_s_9' => _x('Sep', 'September abbreviation', 'aui'), |
|
| 2642 | + 'month_s_10' => _x('Oct', 'October abbreviation', 'aui'), |
|
| 2643 | + 'month_s_11' => _x('Nov', 'November abbreviation', 'aui'), |
|
| 2644 | + 'month_s_12' => _x('Dec', 'December abbreviation', 'aui'), |
|
| 2645 | + 'day_s1_1' => _x('S', 'Sunday initial', 'aui'), |
|
| 2646 | + 'day_s1_2' => _x('M', 'Monday initial', 'aui'), |
|
| 2647 | + 'day_s1_3' => _x('T', 'Tuesday initial', 'aui'), |
|
| 2648 | + 'day_s1_4' => _x('W', 'Wednesday initial', 'aui'), |
|
| 2649 | + 'day_s1_5' => _x('T', 'Friday initial', 'aui'), |
|
| 2650 | + 'day_s1_6' => _x('F', 'Thursday initial', 'aui'), |
|
| 2651 | + 'day_s1_7' => _x('S', 'Saturday initial', 'aui'), |
|
| 2652 | + 'day_s2_1' => __('Su', 'aui'), |
|
| 2653 | + 'day_s2_2' => __('Mo', 'aui'), |
|
| 2654 | + 'day_s2_3' => __('Tu', 'aui'), |
|
| 2655 | + 'day_s2_4' => __('We', 'aui'), |
|
| 2656 | + 'day_s2_5' => __('Th', 'aui'), |
|
| 2657 | + 'day_s2_6' => __('Fr', 'aui'), |
|
| 2658 | + 'day_s2_7' => __('Sa', 'aui'), |
|
| 2659 | + 'day_s3_1' => __('Sun', 'aui'), |
|
| 2660 | + 'day_s3_2' => __('Mon', 'aui'), |
|
| 2661 | + 'day_s3_3' => __('Tue', 'aui'), |
|
| 2662 | + 'day_s3_4' => __('Wed', 'aui'), |
|
| 2663 | + 'day_s3_5' => __('Thu', 'aui'), |
|
| 2664 | + 'day_s3_6' => __('Fri', 'aui'), |
|
| 2665 | + 'day_s3_7' => __('Sat', 'aui'), |
|
| 2666 | + 'day_s5_1' => __('Sunday', 'aui'), |
|
| 2667 | + 'day_s5_2' => __('Monday', 'aui'), |
|
| 2668 | + 'day_s5_3' => __('Tuesday', 'aui'), |
|
| 2669 | + 'day_s5_4' => __('Wednesday', 'aui'), |
|
| 2670 | + 'day_s5_5' => __('Thursday', 'aui'), |
|
| 2671 | + 'day_s5_6' => __('Friday', 'aui'), |
|
| 2672 | + 'day_s5_7' => __('Saturday', 'aui'), |
|
| 2673 | + 'am_lower' => __('am', 'aui'), |
|
| 2674 | + 'pm_lower' => __('pm', 'aui'), |
|
| 2675 | + 'am_upper' => __('AM', 'aui'), |
|
| 2676 | + 'pm_upper' => __('PM', 'aui'), |
|
| 2677 | + 'firstDayOfWeek' => (int) get_option('start_of_week'), |
|
| 2678 | 2678 | 'time_24hr' => false, |
| 2679 | - 'year' => __( 'Year', 'aui' ), |
|
| 2680 | - 'hour' => __( 'Hour', 'aui' ), |
|
| 2681 | - 'minute' => __( 'Minute', 'aui' ), |
|
| 2682 | - 'weekAbbreviation' => __( 'Wk', 'aui' ), |
|
| 2683 | - 'rangeSeparator' => __( ' to ', 'aui' ), |
|
| 2684 | - 'scrollTitle' => __( 'Scroll to increment', 'aui' ), |
|
| 2685 | - 'toggleTitle' => __( 'Click to toggle', 'aui' ) |
|
| 2679 | + 'year' => __('Year', 'aui'), |
|
| 2680 | + 'hour' => __('Hour', 'aui'), |
|
| 2681 | + 'minute' => __('Minute', 'aui'), |
|
| 2682 | + 'weekAbbreviation' => __('Wk', 'aui'), |
|
| 2683 | + 'rangeSeparator' => __(' to ', 'aui'), |
|
| 2684 | + 'scrollTitle' => __('Scroll to increment', 'aui'), |
|
| 2685 | + 'toggleTitle' => __('Click to toggle', 'aui') |
|
| 2686 | 2686 | ); |
| 2687 | 2687 | |
| 2688 | - return apply_filters( 'ayecode_ui_calendar_params', $params ); |
|
| 2688 | + return apply_filters('ayecode_ui_calendar_params', $params); |
|
| 2689 | 2689 | } |
| 2690 | 2690 | |
| 2691 | 2691 | /** |
@@ -2698,47 +2698,47 @@ discard block |
||
| 2698 | 2698 | public static function flatpickr_locale() { |
| 2699 | 2699 | $params = self::calendar_params(); |
| 2700 | 2700 | |
| 2701 | - if ( is_string( $params ) ) { |
|
| 2702 | - $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' ); |
|
| 2701 | + if (is_string($params)) { |
|
| 2702 | + $params = html_entity_decode($params, ENT_QUOTES, 'UTF-8'); |
|
| 2703 | 2703 | } else { |
| 2704 | - foreach ( (array) $params as $key => $value ) { |
|
| 2705 | - if ( ! is_scalar( $value ) ) { |
|
| 2704 | + foreach ((array) $params as $key => $value) { |
|
| 2705 | + if (!is_scalar($value)) { |
|
| 2706 | 2706 | continue; |
| 2707 | 2707 | } |
| 2708 | 2708 | |
| 2709 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2709 | + $params[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
| 2710 | 2710 | } |
| 2711 | 2711 | } |
| 2712 | 2712 | |
| 2713 | 2713 | $day_s3 = array(); |
| 2714 | 2714 | $day_s5 = array(); |
| 2715 | 2715 | |
| 2716 | - for ( $i = 1; $i <= 7; $i ++ ) { |
|
| 2717 | - $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
| 2718 | - $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
| 2716 | + for ($i = 1; $i <= 7; $i++) { |
|
| 2717 | + $day_s3[] = addslashes($params['day_s3_' . $i]); |
|
| 2718 | + $day_s5[] = addslashes($params['day_s3_' . $i]); |
|
| 2719 | 2719 | } |
| 2720 | 2720 | |
| 2721 | 2721 | $month_s = array(); |
| 2722 | 2722 | $month_long = array(); |
| 2723 | 2723 | |
| 2724 | - for ( $i = 1; $i <= 12; $i ++ ) { |
|
| 2725 | - $month_s[] = addslashes( $params[ 'month_s_' . $i ] ); |
|
| 2726 | - $month_long[] = addslashes( $params[ 'month_long_' . $i ] ); |
|
| 2724 | + for ($i = 1; $i <= 12; $i++) { |
|
| 2725 | + $month_s[] = addslashes($params['month_s_' . $i]); |
|
| 2726 | + $month_long[] = addslashes($params['month_long_' . $i]); |
|
| 2727 | 2727 | } |
| 2728 | 2728 | |
| 2729 | 2729 | ob_start(); |
| 2730 | -if ( 0 ) { ?><script><?php } ?> |
|
| 2730 | +if (0) { ?><script><?php } ?> |
|
| 2731 | 2731 | { |
| 2732 | 2732 | weekdays: { |
| 2733 | - shorthand: ['<?php echo implode( "','", $day_s3 ); ?>'], |
|
| 2734 | - longhand: ['<?php echo implode( "','", $day_s5 ); ?>'], |
|
| 2733 | + shorthand: ['<?php echo implode("','", $day_s3); ?>'], |
|
| 2734 | + longhand: ['<?php echo implode("','", $day_s5); ?>'], |
|
| 2735 | 2735 | }, |
| 2736 | 2736 | months: { |
| 2737 | - shorthand: ['<?php echo implode( "','", $month_s ); ?>'], |
|
| 2738 | - longhand: ['<?php echo implode( "','", $month_long ); ?>'], |
|
| 2737 | + shorthand: ['<?php echo implode("','", $month_s); ?>'], |
|
| 2738 | + longhand: ['<?php echo implode("','", $month_long); ?>'], |
|
| 2739 | 2739 | }, |
| 2740 | 2740 | daysInMonth: [31,28,31,30,31,30,31,31,30,31,30,31], |
| 2741 | - firstDayOfWeek: <?php echo (int) $params[ 'firstDayOfWeek' ]; ?>, |
|
| 2741 | + firstDayOfWeek: <?php echo (int) $params['firstDayOfWeek']; ?>, |
|
| 2742 | 2742 | ordinal: function (nth) { |
| 2743 | 2743 | var s = nth % 100; |
| 2744 | 2744 | if (s > 3 && s < 21) |
@@ -2754,21 +2754,21 @@ discard block |
||
| 2754 | 2754 | return "th"; |
| 2755 | 2755 | } |
| 2756 | 2756 | }, |
| 2757 | - rangeSeparator: '<?php echo addslashes( $params[ 'rangeSeparator' ] ); ?>', |
|
| 2758 | - weekAbbreviation: '<?php echo addslashes( $params[ 'weekAbbreviation' ] ); ?>', |
|
| 2759 | - scrollTitle: '<?php echo addslashes( $params[ 'scrollTitle' ] ); ?>', |
|
| 2760 | - toggleTitle: '<?php echo addslashes( $params[ 'toggleTitle' ] ); ?>', |
|
| 2761 | - amPM: ['<?php echo addslashes( $params[ 'am_upper' ] ); ?>','<?php echo addslashes( $params[ 'pm_upper' ] ); ?>'], |
|
| 2762 | - yearAriaLabel: '<?php echo addslashes( $params[ 'year' ] ); ?>', |
|
| 2763 | - hourAriaLabel: '<?php echo addslashes( $params[ 'hour' ] ); ?>', |
|
| 2764 | - minuteAriaLabel: '<?php echo addslashes( $params[ 'minute' ] ); ?>', |
|
| 2765 | - time_24hr: <?php echo ( $params[ 'time_24hr' ] ? 'true' : 'false' ) ; ?> |
|
| 2757 | + rangeSeparator: '<?php echo addslashes($params['rangeSeparator']); ?>', |
|
| 2758 | + weekAbbreviation: '<?php echo addslashes($params['weekAbbreviation']); ?>', |
|
| 2759 | + scrollTitle: '<?php echo addslashes($params['scrollTitle']); ?>', |
|
| 2760 | + toggleTitle: '<?php echo addslashes($params['toggleTitle']); ?>', |
|
| 2761 | + amPM: ['<?php echo addslashes($params['am_upper']); ?>','<?php echo addslashes($params['pm_upper']); ?>'], |
|
| 2762 | + yearAriaLabel: '<?php echo addslashes($params['year']); ?>', |
|
| 2763 | + hourAriaLabel: '<?php echo addslashes($params['hour']); ?>', |
|
| 2764 | + minuteAriaLabel: '<?php echo addslashes($params['minute']); ?>', |
|
| 2765 | + time_24hr: <?php echo ($params['time_24hr'] ? 'true' : 'false'); ?> |
|
| 2766 | 2766 | } |
| 2767 | -<?php if ( 0 ) { ?></script><?php } ?> |
|
| 2767 | +<?php if (0) { ?></script><?php } ?> |
|
| 2768 | 2768 | <?php |
| 2769 | 2769 | $locale = ob_get_clean(); |
| 2770 | 2770 | |
| 2771 | - return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) ); |
|
| 2771 | + return apply_filters('ayecode_ui_flatpickr_locale', trim($locale)); |
|
| 2772 | 2772 | } |
| 2773 | 2773 | |
| 2774 | 2774 | /** |
@@ -2780,20 +2780,20 @@ discard block |
||
| 2780 | 2780 | */ |
| 2781 | 2781 | public static function select2_params() { |
| 2782 | 2782 | $params = array( |
| 2783 | - 'i18n_select_state_text' => esc_attr__( 'Select an option…', 'aui' ), |
|
| 2784 | - 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'aui' ), |
|
| 2785 | - 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'aui' ), |
|
| 2786 | - 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'aui' ), |
|
| 2787 | - 'i18n_input_too_short_n' => _x( 'Please enter %item% or more characters', 'enhanced select', 'aui' ), |
|
| 2788 | - 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'aui' ), |
|
| 2789 | - 'i18n_input_too_long_n' => _x( 'Please delete %item% characters', 'enhanced select', 'aui' ), |
|
| 2790 | - 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'aui' ), |
|
| 2791 | - 'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'aui' ), |
|
| 2792 | - 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'aui' ), |
|
| 2793 | - 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'aui' ) |
|
| 2783 | + 'i18n_select_state_text' => esc_attr__('Select an option…', 'aui'), |
|
| 2784 | + 'i18n_no_matches' => _x('No matches found', 'enhanced select', 'aui'), |
|
| 2785 | + 'i18n_ajax_error' => _x('Loading failed', 'enhanced select', 'aui'), |
|
| 2786 | + 'i18n_input_too_short_1' => _x('Please enter 1 or more characters', 'enhanced select', 'aui'), |
|
| 2787 | + 'i18n_input_too_short_n' => _x('Please enter %item% or more characters', 'enhanced select', 'aui'), |
|
| 2788 | + 'i18n_input_too_long_1' => _x('Please delete 1 character', 'enhanced select', 'aui'), |
|
| 2789 | + 'i18n_input_too_long_n' => _x('Please delete %item% characters', 'enhanced select', 'aui'), |
|
| 2790 | + 'i18n_selection_too_long_1' => _x('You can only select 1 item', 'enhanced select', 'aui'), |
|
| 2791 | + 'i18n_selection_too_long_n' => _x('You can only select %item% items', 'enhanced select', 'aui'), |
|
| 2792 | + 'i18n_load_more' => _x('Loading more results…', 'enhanced select', 'aui'), |
|
| 2793 | + 'i18n_searching' => _x('Searching…', 'enhanced select', 'aui') |
|
| 2794 | 2794 | ); |
| 2795 | 2795 | |
| 2796 | - return apply_filters( 'ayecode_ui_select2_params', $params ); |
|
| 2796 | + return apply_filters('ayecode_ui_select2_params', $params); |
|
| 2797 | 2797 | } |
| 2798 | 2798 | |
| 2799 | 2799 | /** |
@@ -2806,17 +2806,17 @@ discard block |
||
| 2806 | 2806 | public static function select2_locale() { |
| 2807 | 2807 | $params = self::select2_params(); |
| 2808 | 2808 | |
| 2809 | - foreach ( (array) $params as $key => $value ) { |
|
| 2810 | - if ( ! is_scalar( $value ) ) { |
|
| 2809 | + foreach ((array) $params as $key => $value) { |
|
| 2810 | + if (!is_scalar($value)) { |
|
| 2811 | 2811 | continue; |
| 2812 | 2812 | } |
| 2813 | 2813 | |
| 2814 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2814 | + $params[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
| 2815 | 2815 | } |
| 2816 | 2816 | |
| 2817 | - $locale = json_encode( $params ); |
|
| 2817 | + $locale = json_encode($params); |
|
| 2818 | 2818 | |
| 2819 | - return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) ); |
|
| 2819 | + return apply_filters('ayecode_ui_select2_locale', trim($locale)); |
|
| 2820 | 2820 | } |
| 2821 | 2821 | |
| 2822 | 2822 | /** |
@@ -2829,35 +2829,35 @@ discard block |
||
| 2829 | 2829 | public static function timeago_locale() { |
| 2830 | 2830 | $params = array( |
| 2831 | 2831 | 'prefix_ago' => '', |
| 2832 | - 'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'aui' ), |
|
| 2833 | - 'prefix_after' => _x( 'after', 'time ago', 'aui' ) . ' ', |
|
| 2832 | + 'suffix_ago' => ' ' . _x('ago', 'time ago', 'aui'), |
|
| 2833 | + 'prefix_after' => _x('after', 'time ago', 'aui') . ' ', |
|
| 2834 | 2834 | 'suffix_after' => '', |
| 2835 | - 'seconds' => _x( 'less than a minute', 'time ago', 'aui' ), |
|
| 2836 | - 'minute' => _x( 'about a minute', 'time ago', 'aui' ), |
|
| 2837 | - 'minutes' => _x( '%d minutes', 'time ago', 'aui' ), |
|
| 2838 | - 'hour' => _x( 'about an hour', 'time ago', 'aui' ), |
|
| 2839 | - 'hours' => _x( 'about %d hours', 'time ago', 'aui' ), |
|
| 2840 | - 'day' => _x( 'a day', 'time ago', 'aui' ), |
|
| 2841 | - 'days' => _x( '%d days', 'time ago', 'aui' ), |
|
| 2842 | - 'month' => _x( 'about a month', 'time ago', 'aui' ), |
|
| 2843 | - 'months' => _x( '%d months', 'time ago', 'aui' ), |
|
| 2844 | - 'year' => _x( 'about a year', 'time ago', 'aui' ), |
|
| 2845 | - 'years' => _x( '%d years', 'time ago', 'aui' ), |
|
| 2835 | + 'seconds' => _x('less than a minute', 'time ago', 'aui'), |
|
| 2836 | + 'minute' => _x('about a minute', 'time ago', 'aui'), |
|
| 2837 | + 'minutes' => _x('%d minutes', 'time ago', 'aui'), |
|
| 2838 | + 'hour' => _x('about an hour', 'time ago', 'aui'), |
|
| 2839 | + 'hours' => _x('about %d hours', 'time ago', 'aui'), |
|
| 2840 | + 'day' => _x('a day', 'time ago', 'aui'), |
|
| 2841 | + 'days' => _x('%d days', 'time ago', 'aui'), |
|
| 2842 | + 'month' => _x('about a month', 'time ago', 'aui'), |
|
| 2843 | + 'months' => _x('%d months', 'time ago', 'aui'), |
|
| 2844 | + 'year' => _x('about a year', 'time ago', 'aui'), |
|
| 2845 | + 'years' => _x('%d years', 'time ago', 'aui'), |
|
| 2846 | 2846 | ); |
| 2847 | 2847 | |
| 2848 | - $params = apply_filters( 'ayecode_ui_timeago_params', $params ); |
|
| 2848 | + $params = apply_filters('ayecode_ui_timeago_params', $params); |
|
| 2849 | 2849 | |
| 2850 | - foreach ( (array) $params as $key => $value ) { |
|
| 2851 | - if ( ! is_scalar( $value ) ) { |
|
| 2850 | + foreach ((array) $params as $key => $value) { |
|
| 2851 | + if (!is_scalar($value)) { |
|
| 2852 | 2852 | continue; |
| 2853 | 2853 | } |
| 2854 | 2854 | |
| 2855 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
| 2855 | + $params[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
| 2856 | 2856 | } |
| 2857 | 2857 | |
| 2858 | - $locale = json_encode( $params ); |
|
| 2858 | + $locale = json_encode($params); |
|
| 2859 | 2859 | |
| 2860 | - return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) ); |
|
| 2860 | + return apply_filters('ayecode_ui_timeago_locale', trim($locale)); |
|
| 2861 | 2861 | } |
| 2862 | 2862 | |
| 2863 | 2863 | /** |
@@ -2868,7 +2868,7 @@ discard block |
||
| 2868 | 2868 | * @return mixed |
| 2869 | 2869 | */ |
| 2870 | 2870 | public static function minify_js($input) { |
| 2871 | - if(trim($input) === "") return $input; |
|
| 2871 | + if (trim($input) === "") return $input; |
|
| 2872 | 2872 | return preg_replace( |
| 2873 | 2873 | array( |
| 2874 | 2874 | // Remove comment(s) |
@@ -2900,7 +2900,7 @@ discard block |
||
| 2900 | 2900 | * @return mixed |
| 2901 | 2901 | */ |
| 2902 | 2902 | public static function minify_css($input) { |
| 2903 | - if(trim($input) === "") return $input; |
|
| 2903 | + if (trim($input) === "") return $input; |
|
| 2904 | 2904 | return preg_replace( |
| 2905 | 2905 | array( |
| 2906 | 2906 | // Remove comment(s) |
@@ -3448,12 +3448,12 @@ discard block |
||
| 3448 | 3448 | }); |
| 3449 | 3449 | } |
| 3450 | 3450 | } |
| 3451 | -<?php do_action( 'aui_conditional_fields_js', $this ); ?> |
|
| 3451 | +<?php do_action('aui_conditional_fields_js', $this); ?> |
|
| 3452 | 3452 | </script> |
| 3453 | 3453 | <?php |
| 3454 | 3454 | $output = ob_get_clean(); |
| 3455 | 3455 | |
| 3456 | - return str_replace( array( '<script>', '</script>' ), '', self::minify_js( $output ) ); |
|
| 3456 | + return str_replace(array('<script>', '</script>'), '', self::minify_js($output)); |
|
| 3457 | 3457 | } |
| 3458 | 3458 | } |
| 3459 | 3459 | |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | |
| 421 | 421 | if( is_admin() && !$this->is_aui_screen()){ |
| 422 | 422 | // don't add wp-admin scripts if not requested to |
| 423 | - }else{ |
|
| 423 | + } else{ |
|
| 424 | 424 | $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
| 425 | 425 | |
| 426 | 426 | $rtl = is_rtl() ? '-rtl' : ''; |
@@ -1548,7 +1548,7 @@ discard block |
||
| 1548 | 1548 | |
| 1549 | 1549 | if( is_admin() && !$this->is_aui_screen()){ |
| 1550 | 1550 | // don't add wp-admin scripts if not requested to |
| 1551 | - }else { |
|
| 1551 | + } else { |
|
| 1552 | 1552 | |
| 1553 | 1553 | $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
| 1554 | 1554 | |
@@ -1932,7 +1932,7 @@ discard block |
||
| 1932 | 1932 | $colors[$color['slug']] = esc_attr($color['color']); |
| 1933 | 1933 | } |
| 1934 | 1934 | } |
| 1935 | - }else{ |
|
| 1935 | + } else{ |
|
| 1936 | 1936 | $settings = get_option('aui_options'); |
| 1937 | 1937 | $colors = array( |
| 1938 | 1938 | 'primary' => ! empty( $settings['color_primary'] ) ? $settings['color_primary'] : AUI_PRIMARY_COLOR, |
@@ -2019,9 +2019,9 @@ discard block |
||
| 2019 | 2019 | |
| 2020 | 2020 | if($compatibility===true || $compatibility===1){ |
| 2021 | 2021 | $compatibility = '.bsui'; |
| 2022 | - }elseif(!$compatibility){ |
|
| 2022 | + } elseif(!$compatibility){ |
|
| 2023 | 2023 | $compatibility = ''; |
| 2024 | - }else{ |
|
| 2024 | + } else{ |
|
| 2025 | 2025 | $compatibility = esc_attr($compatibility); |
| 2026 | 2026 | } |
| 2027 | 2027 | |
@@ -2868,7 +2868,9 @@ discard block |
||
| 2868 | 2868 | * @return mixed |
| 2869 | 2869 | */ |
| 2870 | 2870 | public static function minify_js($input) { |
| 2871 | - if(trim($input) === "") return $input; |
|
| 2871 | + if(trim($input) === "") { |
|
| 2872 | + return $input; |
|
| 2873 | + } |
|
| 2872 | 2874 | return preg_replace( |
| 2873 | 2875 | array( |
| 2874 | 2876 | // Remove comment(s) |
@@ -2900,7 +2902,9 @@ discard block |
||
| 2900 | 2902 | * @return mixed |
| 2901 | 2903 | */ |
| 2902 | 2904 | public static function minify_css($input) { |
| 2903 | - if(trim($input) === "") return $input; |
|
| 2905 | + if(trim($input) === "") { |
|
| 2906 | + return $input; |
|
| 2907 | + } |
|
| 2904 | 2908 | return preg_replace( |
| 2905 | 2909 | array( |
| 2906 | 2910 | // Remove comment(s) |
@@ -7,40 +7,40 @@ |
||
| 7 | 7 | * Bail if we are not in WP. |
| 8 | 8 | */ |
| 9 | 9 | if ( ! defined( 'ABSPATH' ) ) { |
| 10 | - exit; |
|
| 10 | + exit; |
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * Set the version only if its the current newest while loading. |
| 15 | 15 | */ |
| 16 | 16 | add_action('after_setup_theme', function () { |
| 17 | - global $ayecode_ui_version,$ayecode_ui_file_key; |
|
| 18 | - $this_version = "0.1.77"; |
|
| 19 | - if(empty($ayecode_ui_version) || version_compare($this_version , $ayecode_ui_version, '>')){ |
|
| 20 | - $ayecode_ui_version = $this_version ; |
|
| 21 | - $ayecode_ui_file_key = wp_hash( __FILE__ ); |
|
| 22 | - } |
|
| 17 | + global $ayecode_ui_version,$ayecode_ui_file_key; |
|
| 18 | + $this_version = "0.1.77"; |
|
| 19 | + if(empty($ayecode_ui_version) || version_compare($this_version , $ayecode_ui_version, '>')){ |
|
| 20 | + $ayecode_ui_version = $this_version ; |
|
| 21 | + $ayecode_ui_file_key = wp_hash( __FILE__ ); |
|
| 22 | + } |
|
| 23 | 23 | },0); |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * Load this version of WP Bootstrap Settings only if the file hash is the current one. |
| 27 | 27 | */ |
| 28 | 28 | add_action('after_setup_theme', function () { |
| 29 | - global $ayecode_ui_file_key; |
|
| 30 | - if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){ |
|
| 31 | - include_once( dirname( __FILE__ ) . '/includes/class-aui.php' ); |
|
| 32 | - include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' ); |
|
| 33 | - } |
|
| 29 | + global $ayecode_ui_file_key; |
|
| 30 | + if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){ |
|
| 31 | + include_once( dirname( __FILE__ ) . '/includes/class-aui.php' ); |
|
| 32 | + include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' ); |
|
| 33 | + } |
|
| 34 | 34 | },1); |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * Add the function that calls the class. |
| 38 | 38 | */ |
| 39 | 39 | if(!function_exists('aui')){ |
| 40 | - function aui(){ |
|
| 41 | - if(!class_exists("AUI",false)){ |
|
| 42 | - return false; |
|
| 43 | - } |
|
| 44 | - return AUI::instance(); |
|
| 45 | - } |
|
| 40 | + function aui(){ |
|
| 41 | + if(!class_exists("AUI",false)){ |
|
| 42 | + return false; |
|
| 43 | + } |
|
| 44 | + return AUI::instance(); |
|
| 45 | + } |
|
| 46 | 46 | } |
@@ -6,39 +6,39 @@ |
||
| 6 | 6 | /** |
| 7 | 7 | * Bail if we are not in WP. |
| 8 | 8 | */ |
| 9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 9 | +if (!defined('ABSPATH')) { |
|
| 10 | 10 | exit; |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * Set the version only if its the current newest while loading. |
| 15 | 15 | */ |
| 16 | -add_action('after_setup_theme', function () { |
|
| 17 | - global $ayecode_ui_version,$ayecode_ui_file_key; |
|
| 16 | +add_action('after_setup_theme', function() { |
|
| 17 | + global $ayecode_ui_version, $ayecode_ui_file_key; |
|
| 18 | 18 | $this_version = "0.1.77"; |
| 19 | - if(empty($ayecode_ui_version) || version_compare($this_version , $ayecode_ui_version, '>')){ |
|
| 20 | - $ayecode_ui_version = $this_version ; |
|
| 21 | - $ayecode_ui_file_key = wp_hash( __FILE__ ); |
|
| 19 | + if (empty($ayecode_ui_version) || version_compare($this_version, $ayecode_ui_version, '>')) { |
|
| 20 | + $ayecode_ui_version = $this_version; |
|
| 21 | + $ayecode_ui_file_key = wp_hash(__FILE__); |
|
| 22 | 22 | } |
| 23 | 23 | },0); |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * Load this version of WP Bootstrap Settings only if the file hash is the current one. |
| 27 | 27 | */ |
| 28 | -add_action('after_setup_theme', function () { |
|
| 28 | +add_action('after_setup_theme', function() { |
|
| 29 | 29 | global $ayecode_ui_file_key; |
| 30 | - if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){ |
|
| 31 | - include_once( dirname( __FILE__ ) . '/includes/class-aui.php' ); |
|
| 32 | - include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' ); |
|
| 30 | + if ($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash(__FILE__)) { |
|
| 31 | + include_once(dirname(__FILE__) . '/includes/class-aui.php'); |
|
| 32 | + include_once(dirname(__FILE__) . '/includes/ayecode-ui-settings.php'); |
|
| 33 | 33 | } |
| 34 | 34 | },1); |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * Add the function that calls the class. |
| 38 | 38 | */ |
| 39 | -if(!function_exists('aui')){ |
|
| 40 | - function aui(){ |
|
| 41 | - if(!class_exists("AUI",false)){ |
|
| 39 | +if (!function_exists('aui')) { |
|
| 40 | + function aui() { |
|
| 41 | + if (!class_exists("AUI", false)) { |
|
| 42 | 42 | return false; |
| 43 | 43 | } |
| 44 | 44 | return AUI::instance(); |
@@ -1,59 +1,59 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if ( ! defined( 'ABSPATH' ) ) { |
| 3 | - exit; |
|
| 3 | + exit; |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | if ( ! class_exists( 'WP_Super_Duper' ) ) { |
| 7 | 7 | |
| 8 | 8 | |
| 9 | - /** |
|
| 10 | - * A Class to be able to create a Widget, Shortcode or Block to be able to output content for WordPress. |
|
| 11 | - * |
|
| 12 | - * Should not be called direct but extended instead. |
|
| 13 | - * |
|
| 14 | - * Class WP_Super_Duper |
|
| 15 | - * @since 1.0.16 change log moved to file change-log.txt - CHANGED |
|
| 16 | - * @ver 1.1.1 |
|
| 17 | - */ |
|
| 18 | - class WP_Super_Duper extends WP_Widget { |
|
| 19 | - |
|
| 20 | - public $version = "1.1.1"; |
|
| 21 | - public $font_awesome_icon_version = "5.11.2"; |
|
| 22 | - public $block_code; |
|
| 23 | - public $options; |
|
| 24 | - public $base_id; |
|
| 25 | - public $settings_hash; |
|
| 26 | - public $arguments = array(); |
|
| 27 | - public $instance = array(); |
|
| 28 | - private $class_name; |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * The relative url to the current folder. |
|
| 32 | - * |
|
| 33 | - * @var string |
|
| 34 | - */ |
|
| 35 | - public $url = ''; |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * Take the array options and use them to build. |
|
| 39 | - */ |
|
| 40 | - public function __construct( $options ) { |
|
| 41 | - global $sd_widgets; |
|
| 42 | - |
|
| 43 | - $sd_widgets[ $options['base_id'] ] = array( |
|
| 44 | - 'name' => $options['name'], |
|
| 45 | - 'class_name' => $options['class_name'], |
|
| 46 | - 'output_types' => !empty($options['output_types']) ? $options['output_types'] : array() |
|
| 47 | - ); |
|
| 48 | - $this->base_id = $options['base_id']; |
|
| 49 | - // lets filter the options before we do anything |
|
| 50 | - $options = apply_filters( "wp_super_duper_options", $options ); |
|
| 51 | - $options = apply_filters( "wp_super_duper_options_{$this->base_id}", $options ); |
|
| 52 | - $options = $this->add_name_from_key( $options ); |
|
| 53 | - $this->options = $options; |
|
| 54 | - |
|
| 55 | - $this->base_id = $options['base_id']; |
|
| 56 | - $this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array(); |
|
| 9 | + /** |
|
| 10 | + * A Class to be able to create a Widget, Shortcode or Block to be able to output content for WordPress. |
|
| 11 | + * |
|
| 12 | + * Should not be called direct but extended instead. |
|
| 13 | + * |
|
| 14 | + * Class WP_Super_Duper |
|
| 15 | + * @since 1.0.16 change log moved to file change-log.txt - CHANGED |
|
| 16 | + * @ver 1.1.1 |
|
| 17 | + */ |
|
| 18 | + class WP_Super_Duper extends WP_Widget { |
|
| 19 | + |
|
| 20 | + public $version = "1.1.1"; |
|
| 21 | + public $font_awesome_icon_version = "5.11.2"; |
|
| 22 | + public $block_code; |
|
| 23 | + public $options; |
|
| 24 | + public $base_id; |
|
| 25 | + public $settings_hash; |
|
| 26 | + public $arguments = array(); |
|
| 27 | + public $instance = array(); |
|
| 28 | + private $class_name; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * The relative url to the current folder. |
|
| 32 | + * |
|
| 33 | + * @var string |
|
| 34 | + */ |
|
| 35 | + public $url = ''; |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * Take the array options and use them to build. |
|
| 39 | + */ |
|
| 40 | + public function __construct( $options ) { |
|
| 41 | + global $sd_widgets; |
|
| 42 | + |
|
| 43 | + $sd_widgets[ $options['base_id'] ] = array( |
|
| 44 | + 'name' => $options['name'], |
|
| 45 | + 'class_name' => $options['class_name'], |
|
| 46 | + 'output_types' => !empty($options['output_types']) ? $options['output_types'] : array() |
|
| 47 | + ); |
|
| 48 | + $this->base_id = $options['base_id']; |
|
| 49 | + // lets filter the options before we do anything |
|
| 50 | + $options = apply_filters( "wp_super_duper_options", $options ); |
|
| 51 | + $options = apply_filters( "wp_super_duper_options_{$this->base_id}", $options ); |
|
| 52 | + $options = $this->add_name_from_key( $options ); |
|
| 53 | + $this->options = $options; |
|
| 54 | + |
|
| 55 | + $this->base_id = $options['base_id']; |
|
| 56 | + $this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array(); |
|
| 57 | 57 | |
| 58 | 58 | // nested blocks can't work as a widget |
| 59 | 59 | if(!empty($this->options['nested-block'])){ |
@@ -64,234 +64,234 @@ discard block |
||
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - // init parent |
|
| 68 | - if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){ |
|
| 67 | + // init parent |
|
| 68 | + if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){ |
|
| 69 | 69 | parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] ); |
| 70 | - } |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | 72 | |
| 73 | - if ( isset( $options['class_name'] ) ) { |
|
| 74 | - // register widget |
|
| 75 | - $this->class_name = $options['class_name']; |
|
| 73 | + if ( isset( $options['class_name'] ) ) { |
|
| 74 | + // register widget |
|
| 75 | + $this->class_name = $options['class_name']; |
|
| 76 | 76 | |
| 77 | - // register shortcode, this needs to be done even for blocks and widgets |
|
| 77 | + // register shortcode, this needs to be done even for blocks and widgets |
|
| 78 | 78 | $this->register_shortcode(); |
| 79 | 79 | |
| 80 | 80 | |
| 81 | - // Fusion Builder (avada) support |
|
| 82 | - if ( function_exists( 'fusion_builder_map' ) ) { |
|
| 83 | - add_action( 'init', array( $this, 'register_fusion_element' ) ); |
|
| 84 | - } |
|
| 81 | + // Fusion Builder (avada) support |
|
| 82 | + if ( function_exists( 'fusion_builder_map' ) ) { |
|
| 83 | + add_action( 'init', array( $this, 'register_fusion_element' ) ); |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - // register block |
|
| 87 | - if(empty($this->options['output_types']) || in_array('block',$this->options['output_types'])){ |
|
| 88 | - add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) ); |
|
| 86 | + // register block |
|
| 87 | + if(empty($this->options['output_types']) || in_array('block',$this->options['output_types'])){ |
|
| 88 | + add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) ); |
|
| 89 | 89 | } |
| 90 | - } |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - // add the CSS and JS we need ONCE |
|
| 93 | - global $sd_widget_scripts; |
|
| 92 | + // add the CSS and JS we need ONCE |
|
| 93 | + global $sd_widget_scripts; |
|
| 94 | 94 | |
| 95 | - if ( ! $sd_widget_scripts ) { |
|
| 96 | - wp_add_inline_script( 'admin-widgets', $this->widget_js() ); |
|
| 97 | - wp_add_inline_script( 'customize-controls', $this->widget_js() ); |
|
| 98 | - wp_add_inline_style( 'widgets', $this->widget_css() ); |
|
| 95 | + if ( ! $sd_widget_scripts ) { |
|
| 96 | + wp_add_inline_script( 'admin-widgets', $this->widget_js() ); |
|
| 97 | + wp_add_inline_script( 'customize-controls', $this->widget_js() ); |
|
| 98 | + wp_add_inline_style( 'widgets', $this->widget_css() ); |
|
| 99 | 99 | |
| 100 | - // maybe add elementor editor styles |
|
| 101 | - add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'elementor_editor_styles' ) ); |
|
| 100 | + // maybe add elementor editor styles |
|
| 101 | + add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'elementor_editor_styles' ) ); |
|
| 102 | 102 | |
| 103 | - $sd_widget_scripts = true; |
|
| 103 | + $sd_widget_scripts = true; |
|
| 104 | 104 | |
| 105 | - // add shortcode insert button once |
|
| 106 | - add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) ); |
|
| 107 | - // generatepress theme sections compatibility |
|
| 108 | - if ( function_exists( 'generate_sections_sections_metabox' ) ) { |
|
| 109 | - add_action( 'generate_sections_metabox', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 110 | - } |
|
| 111 | - /* Load script on Divi theme builder page */ |
|
| 112 | - if ( function_exists( 'et_builder_is_tb_admin_screen' ) && et_builder_is_tb_admin_screen() ) { |
|
| 113 | - add_thickbox(); |
|
| 114 | - add_action( 'admin_footer', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 115 | - } |
|
| 105 | + // add shortcode insert button once |
|
| 106 | + add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) ); |
|
| 107 | + // generatepress theme sections compatibility |
|
| 108 | + if ( function_exists( 'generate_sections_sections_metabox' ) ) { |
|
| 109 | + add_action( 'generate_sections_metabox', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 110 | + } |
|
| 111 | + /* Load script on Divi theme builder page */ |
|
| 112 | + if ( function_exists( 'et_builder_is_tb_admin_screen' ) && et_builder_is_tb_admin_screen() ) { |
|
| 113 | + add_thickbox(); |
|
| 114 | + add_action( 'admin_footer', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - if ( $this->is_preview() ) { |
|
| 118 | - add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 119 | - // this makes the insert button work for elementor |
|
| 120 | - add_action( 'elementor/editor/after_enqueue_scripts', array( |
|
| 121 | - $this, |
|
| 122 | - 'shortcode_insert_button_script' |
|
| 123 | - ) ); // for elementor |
|
| 124 | - } |
|
| 125 | - // this makes the insert button work for cornerstone |
|
| 126 | - add_action( 'wp_print_footer_scripts', array( __CLASS__, 'maybe_cornerstone_builder' ) ); |
|
| 117 | + if ( $this->is_preview() ) { |
|
| 118 | + add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 119 | + // this makes the insert button work for elementor |
|
| 120 | + add_action( 'elementor/editor/after_enqueue_scripts', array( |
|
| 121 | + $this, |
|
| 122 | + 'shortcode_insert_button_script' |
|
| 123 | + ) ); // for elementor |
|
| 124 | + } |
|
| 125 | + // this makes the insert button work for cornerstone |
|
| 126 | + add_action( 'wp_print_footer_scripts', array( __CLASS__, 'maybe_cornerstone_builder' ) ); |
|
| 127 | 127 | |
| 128 | - add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) ); |
|
| 129 | - add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) ); |
|
| 128 | + add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) ); |
|
| 129 | + add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) ); |
|
| 130 | 130 | |
| 131 | - // add generator text to admin head |
|
| 132 | - add_action( 'admin_head', array( $this, 'generator' ) ); |
|
| 133 | - } |
|
| 131 | + // add generator text to admin head |
|
| 132 | + add_action( 'admin_head', array( $this, 'generator' ) ); |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | - do_action( 'wp_super_duper_widget_init', $options, $this ); |
|
| 136 | - } |
|
| 135 | + do_action( 'wp_super_duper_widget_init', $options, $this ); |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | 138 | /** |
| 139 | 139 | * The register widget function |
| 140 | 140 | * @return void |
| 141 | 141 | */ |
| 142 | - public function _register() { |
|
| 142 | + public function _register() { |
|
| 143 | 143 | if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){ |
| 144 | 144 | parent::_register(); |
| 145 | - } |
|
| 146 | - } |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - /** |
|
| 149 | - * Add our widget CSS to elementor editor. |
|
| 150 | - */ |
|
| 151 | - public function elementor_editor_styles() { |
|
| 152 | - wp_add_inline_style( 'elementor-editor', $this->widget_css( false ) ); |
|
| 153 | - } |
|
| 148 | + /** |
|
| 149 | + * Add our widget CSS to elementor editor. |
|
| 150 | + */ |
|
| 151 | + public function elementor_editor_styles() { |
|
| 152 | + wp_add_inline_style( 'elementor-editor', $this->widget_css( false ) ); |
|
| 153 | + } |
|
| 154 | 154 | |
| 155 | - public function register_fusion_element() { |
|
| 155 | + public function register_fusion_element() { |
|
| 156 | 156 | |
| 157 | - $options = $this->options; |
|
| 157 | + $options = $this->options; |
|
| 158 | 158 | |
| 159 | - if ( $this->base_id ) { |
|
| 159 | + if ( $this->base_id ) { |
|
| 160 | 160 | |
| 161 | - $params = $this->get_fusion_params(); |
|
| 161 | + $params = $this->get_fusion_params(); |
|
| 162 | 162 | |
| 163 | - $args = array( |
|
| 164 | - 'name' => $options['name'], |
|
| 165 | - 'shortcode' => $this->base_id, |
|
| 166 | - 'icon' => $options['block-icon'] ? $options['block-icon'] : 'far fa-square', |
|
| 167 | - 'allow_generator' => true, |
|
| 168 | - ); |
|
| 163 | + $args = array( |
|
| 164 | + 'name' => $options['name'], |
|
| 165 | + 'shortcode' => $this->base_id, |
|
| 166 | + 'icon' => $options['block-icon'] ? $options['block-icon'] : 'far fa-square', |
|
| 167 | + 'allow_generator' => true, |
|
| 168 | + ); |
|
| 169 | 169 | |
| 170 | - if ( ! empty( $params ) ) { |
|
| 171 | - $args['params'] = $params; |
|
| 172 | - } |
|
| 170 | + if ( ! empty( $params ) ) { |
|
| 171 | + $args['params'] = $params; |
|
| 172 | + } |
|
| 173 | 173 | |
| 174 | - fusion_builder_map( $args ); |
|
| 175 | - } |
|
| 174 | + fusion_builder_map( $args ); |
|
| 175 | + } |
|
| 176 | 176 | |
| 177 | - } |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | - public function get_fusion_params() { |
|
| 180 | - $params = array(); |
|
| 181 | - $arguments = $this->get_arguments(); |
|
| 182 | - |
|
| 183 | - if ( ! empty( $arguments ) ) { |
|
| 184 | - foreach ( $arguments as $key => $val ) { |
|
| 185 | - $param = array(); |
|
| 186 | - // type |
|
| 187 | - $param['type'] = str_replace( |
|
| 188 | - array( |
|
| 189 | - "text", |
|
| 190 | - "number", |
|
| 191 | - "email", |
|
| 192 | - "color", |
|
| 193 | - "checkbox" |
|
| 194 | - ), |
|
| 195 | - array( |
|
| 196 | - "textfield", |
|
| 197 | - "textfield", |
|
| 198 | - "textfield", |
|
| 199 | - "colorpicker", |
|
| 200 | - "select", |
|
| 201 | - |
|
| 202 | - ), |
|
| 203 | - $val['type'] ); |
|
| 204 | - |
|
| 205 | - // multiselect |
|
| 206 | - if ( $val['type'] == 'multiselect' || ( ( $param['type'] == 'select' || $val['type'] == 'select' ) && ! empty( $val['multiple'] ) ) ) { |
|
| 207 | - $param['type'] = 'multiple_select'; |
|
| 208 | - $param['multiple'] = true; |
|
| 209 | - } |
|
| 179 | + public function get_fusion_params() { |
|
| 180 | + $params = array(); |
|
| 181 | + $arguments = $this->get_arguments(); |
|
| 182 | + |
|
| 183 | + if ( ! empty( $arguments ) ) { |
|
| 184 | + foreach ( $arguments as $key => $val ) { |
|
| 185 | + $param = array(); |
|
| 186 | + // type |
|
| 187 | + $param['type'] = str_replace( |
|
| 188 | + array( |
|
| 189 | + "text", |
|
| 190 | + "number", |
|
| 191 | + "email", |
|
| 192 | + "color", |
|
| 193 | + "checkbox" |
|
| 194 | + ), |
|
| 195 | + array( |
|
| 196 | + "textfield", |
|
| 197 | + "textfield", |
|
| 198 | + "textfield", |
|
| 199 | + "colorpicker", |
|
| 200 | + "select", |
|
| 210 | 201 | |
| 211 | - // heading |
|
| 212 | - $param['heading'] = $val['title']; |
|
| 202 | + ), |
|
| 203 | + $val['type'] ); |
|
| 213 | 204 | |
| 214 | - // description |
|
| 215 | - $param['description'] = isset( $val['desc'] ) ? $val['desc'] : ''; |
|
| 205 | + // multiselect |
|
| 206 | + if ( $val['type'] == 'multiselect' || ( ( $param['type'] == 'select' || $val['type'] == 'select' ) && ! empty( $val['multiple'] ) ) ) { |
|
| 207 | + $param['type'] = 'multiple_select'; |
|
| 208 | + $param['multiple'] = true; |
|
| 209 | + } |
|
| 216 | 210 | |
| 217 | - // param_name |
|
| 218 | - $param['param_name'] = $key; |
|
| 211 | + // heading |
|
| 212 | + $param['heading'] = $val['title']; |
|
| 219 | 213 | |
| 220 | - // Default |
|
| 221 | - $param['default'] = isset( $val['default'] ) ? $val['default'] : ''; |
|
| 214 | + // description |
|
| 215 | + $param['description'] = isset( $val['desc'] ) ? $val['desc'] : ''; |
|
| 222 | 216 | |
| 223 | - // Group |
|
| 224 | - if ( isset( $val['group'] ) ) { |
|
| 225 | - $param['group'] = $val['group']; |
|
| 226 | - } |
|
| 217 | + // param_name |
|
| 218 | + $param['param_name'] = $key; |
|
| 227 | 219 | |
| 228 | - // value |
|
| 229 | - if ( $val['type'] == 'checkbox' ) { |
|
| 230 | - if ( isset( $val['default'] ) && $val['default'] == '0' ) { |
|
| 231 | - unset( $param['default'] ); |
|
| 232 | - } |
|
| 233 | - $param['value'] = array( '' => __( "No" ), '1' => __( "Yes" ) ); |
|
| 234 | - } elseif ( $param['type'] == 'select' || $param['type'] == 'multiple_select' ) { |
|
| 235 | - $param['value'] = isset( $val['options'] ) ? $val['options'] : array(); |
|
| 236 | - } else { |
|
| 237 | - $param['value'] = isset( $val['default'] ) ? $val['default'] : ''; |
|
| 238 | - } |
|
| 220 | + // Default |
|
| 221 | + $param['default'] = isset( $val['default'] ) ? $val['default'] : ''; |
|
| 239 | 222 | |
| 240 | - // setup the param |
|
| 241 | - $params[] = $param; |
|
| 223 | + // Group |
|
| 224 | + if ( isset( $val['group'] ) ) { |
|
| 225 | + $param['group'] = $val['group']; |
|
| 226 | + } |
|
| 242 | 227 | |
| 243 | - } |
|
| 244 | - } |
|
| 228 | + // value |
|
| 229 | + if ( $val['type'] == 'checkbox' ) { |
|
| 230 | + if ( isset( $val['default'] ) && $val['default'] == '0' ) { |
|
| 231 | + unset( $param['default'] ); |
|
| 232 | + } |
|
| 233 | + $param['value'] = array( '' => __( "No" ), '1' => __( "Yes" ) ); |
|
| 234 | + } elseif ( $param['type'] == 'select' || $param['type'] == 'multiple_select' ) { |
|
| 235 | + $param['value'] = isset( $val['options'] ) ? $val['options'] : array(); |
|
| 236 | + } else { |
|
| 237 | + $param['value'] = isset( $val['default'] ) ? $val['default'] : ''; |
|
| 238 | + } |
|
| 245 | 239 | |
| 240 | + // setup the param |
|
| 241 | + $params[] = $param; |
|
| 246 | 242 | |
| 247 | - return $params; |
|
| 248 | - } |
|
| 243 | + } |
|
| 244 | + } |
|
| 249 | 245 | |
| 250 | - /** |
|
| 251 | - * Maybe insert the shortcode inserter button in the footer if we are in the cornerstone builder |
|
| 252 | - */ |
|
| 253 | - public static function maybe_cornerstone_builder() { |
|
| 254 | - if ( did_action( 'cornerstone_before_boot_app' ) ) { |
|
| 255 | - self::shortcode_insert_button_script(); |
|
| 256 | - } |
|
| 257 | - } |
|
| 258 | 246 | |
| 259 | - /** |
|
| 260 | - * A function to ge the shortcode builder picker html. |
|
| 261 | - * |
|
| 262 | - * @param string $editor_id |
|
| 263 | - * |
|
| 264 | - * @return string |
|
| 265 | - */ |
|
| 266 | - public static function get_picker( $editor_id = '' ) { |
|
| 267 | - |
|
| 268 | - ob_start(); |
|
| 269 | - if ( isset( $_POST['editor_id'] ) ) { |
|
| 270 | - $editor_id = esc_attr( $_POST['editor_id'] ); |
|
| 271 | - } elseif ( isset( $_REQUEST['et_fb'] ) ) { |
|
| 272 | - $editor_id = 'main_content_content_vb_tiny_mce'; |
|
| 273 | - } |
|
| 247 | + return $params; |
|
| 248 | + } |
|
| 249 | + |
|
| 250 | + /** |
|
| 251 | + * Maybe insert the shortcode inserter button in the footer if we are in the cornerstone builder |
|
| 252 | + */ |
|
| 253 | + public static function maybe_cornerstone_builder() { |
|
| 254 | + if ( did_action( 'cornerstone_before_boot_app' ) ) { |
|
| 255 | + self::shortcode_insert_button_script(); |
|
| 256 | + } |
|
| 257 | + } |
|
| 258 | + |
|
| 259 | + /** |
|
| 260 | + * A function to ge the shortcode builder picker html. |
|
| 261 | + * |
|
| 262 | + * @param string $editor_id |
|
| 263 | + * |
|
| 264 | + * @return string |
|
| 265 | + */ |
|
| 266 | + public static function get_picker( $editor_id = '' ) { |
|
| 267 | + |
|
| 268 | + ob_start(); |
|
| 269 | + if ( isset( $_POST['editor_id'] ) ) { |
|
| 270 | + $editor_id = esc_attr( $_POST['editor_id'] ); |
|
| 271 | + } elseif ( isset( $_REQUEST['et_fb'] ) ) { |
|
| 272 | + $editor_id = 'main_content_content_vb_tiny_mce'; |
|
| 273 | + } |
|
| 274 | 274 | |
| 275 | - global $sd_widgets; |
|
| 275 | + global $sd_widgets; |
|
| 276 | 276 | |
| 277 | 277 | // print_r($sd_widgets);exit; |
| 278 | - ?> |
|
| 278 | + ?> |
|
| 279 | 279 | |
| 280 | 280 | <div class="sd-shortcode-left-wrap"> |
| 281 | 281 | <?php |
| 282 | - ksort( $sd_widgets ); |
|
| 283 | - // print_r($sd_widgets);exit; |
|
| 284 | - if ( ! empty( $sd_widgets ) ) { |
|
| 285 | - echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">'; |
|
| 286 | - echo "<option>" . __( 'Select shortcode' ) . "</option>"; |
|
| 287 | - foreach ( $sd_widgets as $shortcode => $class ) { |
|
| 288 | - if(!empty($class['output_types']) && !in_array('shortcode', $class['output_types'])){ continue; } |
|
| 289 | - echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>"; |
|
| 290 | - } |
|
| 291 | - echo "</select>"; |
|
| 282 | + ksort( $sd_widgets ); |
|
| 283 | + // print_r($sd_widgets);exit; |
|
| 284 | + if ( ! empty( $sd_widgets ) ) { |
|
| 285 | + echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">'; |
|
| 286 | + echo "<option>" . __( 'Select shortcode' ) . "</option>"; |
|
| 287 | + foreach ( $sd_widgets as $shortcode => $class ) { |
|
| 288 | + if(!empty($class['output_types']) && !in_array('shortcode', $class['output_types'])){ continue; } |
|
| 289 | + echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>"; |
|
| 290 | + } |
|
| 291 | + echo "</select>"; |
|
| 292 | 292 | |
| 293 | - } |
|
| 294 | - ?> |
|
| 293 | + } |
|
| 294 | + ?> |
|
| 295 | 295 | <div class="sd-shortcode-settings"></div> |
| 296 | 296 | |
| 297 | 297 | </div> |
@@ -302,8 +302,8 @@ discard block |
||
| 302 | 302 | <?php if ( $editor_id != '' ) { ?> |
| 303 | 303 | <button class="button sd-insert-shortcode-button" |
| 304 | 304 | onclick="sd_insert_shortcode(<?php if ( ! empty( $editor_id ) ) { |
| 305 | - echo "'" . $editor_id . "'"; |
|
| 306 | - } ?>)"><?php _e( 'Insert shortcode' ); ?></button> |
|
| 305 | + echo "'" . $editor_id . "'"; |
|
| 306 | + } ?>)"><?php _e( 'Insert shortcode' ); ?></button> |
|
| 307 | 307 | <?php } ?> |
| 308 | 308 | <button class="button" |
| 309 | 309 | onclick="sd_copy_to_clipboard()"><?php _e( 'Copy shortcode' ); ?></button> |
@@ -311,135 +311,135 @@ discard block |
||
| 311 | 311 | </div> |
| 312 | 312 | <?php |
| 313 | 313 | |
| 314 | - $html = ob_get_clean(); |
|
| 314 | + $html = ob_get_clean(); |
|
| 315 | 315 | |
| 316 | - if ( wp_doing_ajax() ) { |
|
| 317 | - echo $html; |
|
| 318 | - $should_die = true; |
|
| 316 | + if ( wp_doing_ajax() ) { |
|
| 317 | + echo $html; |
|
| 318 | + $should_die = true; |
|
| 319 | 319 | |
| 320 | - // some builder get the editor via ajax so we should not die on those occasions |
|
| 321 | - $dont_die = array( |
|
| 322 | - 'parent_tag',// WP Bakery |
|
| 323 | - 'avia_request' // enfold |
|
| 324 | - ); |
|
| 320 | + // some builder get the editor via ajax so we should not die on those occasions |
|
| 321 | + $dont_die = array( |
|
| 322 | + 'parent_tag',// WP Bakery |
|
| 323 | + 'avia_request' // enfold |
|
| 324 | + ); |
|
| 325 | 325 | |
| 326 | - foreach ( $dont_die as $request ) { |
|
| 327 | - if ( isset( $_REQUEST[ $request ] ) ) { |
|
| 328 | - $should_die = false; |
|
| 329 | - } |
|
| 330 | - } |
|
| 326 | + foreach ( $dont_die as $request ) { |
|
| 327 | + if ( isset( $_REQUEST[ $request ] ) ) { |
|
| 328 | + $should_die = false; |
|
| 329 | + } |
|
| 330 | + } |
|
| 331 | 331 | |
| 332 | - if ( $should_die ) { |
|
| 333 | - wp_die(); |
|
| 334 | - } |
|
| 332 | + if ( $should_die ) { |
|
| 333 | + wp_die(); |
|
| 334 | + } |
|
| 335 | 335 | |
| 336 | - } else { |
|
| 337 | - return $html; |
|
| 338 | - } |
|
| 336 | + } else { |
|
| 337 | + return $html; |
|
| 338 | + } |
|
| 339 | 339 | |
| 340 | - return ''; |
|
| 340 | + return ''; |
|
| 341 | 341 | |
| 342 | - } |
|
| 342 | + } |
|
| 343 | 343 | |
| 344 | - /** |
|
| 345 | - * Output the version in the admin header. |
|
| 346 | - */ |
|
| 347 | - public function generator() { |
|
| 348 | - echo '<meta name="generator" content="WP Super Duper v' . $this->version . '" />'; |
|
| 349 | - } |
|
| 344 | + /** |
|
| 345 | + * Output the version in the admin header. |
|
| 346 | + */ |
|
| 347 | + public function generator() { |
|
| 348 | + echo '<meta name="generator" content="WP Super Duper v' . $this->version . '" />'; |
|
| 349 | + } |
|
| 350 | 350 | |
| 351 | - /** |
|
| 352 | - * Get widget settings. |
|
| 353 | - * |
|
| 354 | - * @since 1.0.0 |
|
| 355 | - */ |
|
| 356 | - public static function get_widget_settings() { |
|
| 357 | - global $sd_widgets; |
|
| 358 | - |
|
| 359 | - $shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : ''; |
|
| 360 | - if ( ! $shortcode ) { |
|
| 361 | - wp_die(); |
|
| 362 | - } |
|
| 363 | - $widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : ''; |
|
| 364 | - if ( ! $widget_args ) { |
|
| 365 | - wp_die(); |
|
| 366 | - } |
|
| 367 | - $class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : ''; |
|
| 368 | - if ( ! $class_name ) { |
|
| 369 | - wp_die(); |
|
| 370 | - } |
|
| 351 | + /** |
|
| 352 | + * Get widget settings. |
|
| 353 | + * |
|
| 354 | + * @since 1.0.0 |
|
| 355 | + */ |
|
| 356 | + public static function get_widget_settings() { |
|
| 357 | + global $sd_widgets; |
|
| 358 | + |
|
| 359 | + $shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : ''; |
|
| 360 | + if ( ! $shortcode ) { |
|
| 361 | + wp_die(); |
|
| 362 | + } |
|
| 363 | + $widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : ''; |
|
| 364 | + if ( ! $widget_args ) { |
|
| 365 | + wp_die(); |
|
| 366 | + } |
|
| 367 | + $class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : ''; |
|
| 368 | + if ( ! $class_name ) { |
|
| 369 | + wp_die(); |
|
| 370 | + } |
|
| 371 | 371 | |
| 372 | - // invoke an instance method |
|
| 373 | - $widget = new $class_name; |
|
| 372 | + // invoke an instance method |
|
| 373 | + $widget = new $class_name; |
|
| 374 | 374 | |
| 375 | - ob_start(); |
|
| 376 | - $widget->form( array() ); |
|
| 377 | - $form = ob_get_clean(); |
|
| 378 | - echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>"; |
|
| 379 | - echo "<style>" . $widget->widget_css() . "</style>"; |
|
| 380 | - echo "<script>" . $widget->widget_js() . "</script>"; |
|
| 381 | - ?> |
|
| 375 | + ob_start(); |
|
| 376 | + $widget->form( array() ); |
|
| 377 | + $form = ob_get_clean(); |
|
| 378 | + echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>"; |
|
| 379 | + echo "<style>" . $widget->widget_css() . "</style>"; |
|
| 380 | + echo "<script>" . $widget->widget_js() . "</script>"; |
|
| 381 | + ?> |
|
| 382 | 382 | <?php |
| 383 | - wp_die(); |
|
| 384 | - } |
|
| 383 | + wp_die(); |
|
| 384 | + } |
|
| 385 | 385 | |
| 386 | - /** |
|
| 387 | - * Insert shortcode builder button to classic editor (not inside Gutenberg, not needed). |
|
| 388 | - * |
|
| 389 | - * @param string $editor_id Optional. Shortcode editor id. Default null. |
|
| 390 | - * @param string $insert_shortcode_function Optional. Insert shortcode function. Default null. |
|
| 391 | - * |
|
| 392 | - *@since 1.0.0 |
|
| 393 | - * |
|
| 394 | - */ |
|
| 395 | - public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) { |
|
| 396 | - global $sd_widgets, $shortcode_insert_button_once; |
|
| 397 | - if ( $shortcode_insert_button_once ) { |
|
| 398 | - return; |
|
| 399 | - } |
|
| 400 | - add_thickbox(); |
|
| 386 | + /** |
|
| 387 | + * Insert shortcode builder button to classic editor (not inside Gutenberg, not needed). |
|
| 388 | + * |
|
| 389 | + * @param string $editor_id Optional. Shortcode editor id. Default null. |
|
| 390 | + * @param string $insert_shortcode_function Optional. Insert shortcode function. Default null. |
|
| 391 | + * |
|
| 392 | + *@since 1.0.0 |
|
| 393 | + * |
|
| 394 | + */ |
|
| 395 | + public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) { |
|
| 396 | + global $sd_widgets, $shortcode_insert_button_once; |
|
| 397 | + if ( $shortcode_insert_button_once ) { |
|
| 398 | + return; |
|
| 399 | + } |
|
| 400 | + add_thickbox(); |
|
| 401 | 401 | |
| 402 | 402 | |
| 403 | - /** |
|
| 404 | - * Cornerstone makes us play dirty tricks :/ |
|
| 405 | - * All media_buttons are removed via JS unless they are two specific id's so we wrap our content in this ID so it is not removed. |
|
| 406 | - */ |
|
| 407 | - if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) { |
|
| 408 | - echo '<span id="insert-media-button">'; |
|
| 409 | - } |
|
| 403 | + /** |
|
| 404 | + * Cornerstone makes us play dirty tricks :/ |
|
| 405 | + * All media_buttons are removed via JS unless they are two specific id's so we wrap our content in this ID so it is not removed. |
|
| 406 | + */ |
|
| 407 | + if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) { |
|
| 408 | + echo '<span id="insert-media-button">'; |
|
| 409 | + } |
|
| 410 | 410 | |
| 411 | - echo self::shortcode_button( 'this', 'true' ); |
|
| 411 | + echo self::shortcode_button( 'this', 'true' ); |
|
| 412 | 412 | |
| 413 | - // see opening note |
|
| 414 | - if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) { |
|
| 415 | - echo '</span>'; // end #insert-media-button |
|
| 416 | - } |
|
| 413 | + // see opening note |
|
| 414 | + if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) { |
|
| 415 | + echo '</span>'; // end #insert-media-button |
|
| 416 | + } |
|
| 417 | 417 | |
| 418 | - // Add separate script for generatepress theme sections |
|
| 419 | - if ( function_exists( 'generate_sections_sections_metabox' ) && did_action( 'generate_sections_metabox' ) ) { |
|
| 420 | - } else { |
|
| 421 | - self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function ); |
|
| 422 | - } |
|
| 418 | + // Add separate script for generatepress theme sections |
|
| 419 | + if ( function_exists( 'generate_sections_sections_metabox' ) && did_action( 'generate_sections_metabox' ) ) { |
|
| 420 | + } else { |
|
| 421 | + self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function ); |
|
| 422 | + } |
|
| 423 | 423 | |
| 424 | - $shortcode_insert_button_once = true; |
|
| 425 | - } |
|
| 424 | + $shortcode_insert_button_once = true; |
|
| 425 | + } |
|
| 426 | 426 | |
| 427 | - /** |
|
| 428 | - * Gets the shortcode insert button html. |
|
| 429 | - * |
|
| 430 | - * @param string $id |
|
| 431 | - * @param string $search_for_id |
|
| 432 | - * |
|
| 433 | - * @return mixed |
|
| 434 | - */ |
|
| 435 | - public static function shortcode_button( $id = '', $search_for_id = '' ) { |
|
| 436 | - ob_start(); |
|
| 437 | - ?> |
|
| 427 | + /** |
|
| 428 | + * Gets the shortcode insert button html. |
|
| 429 | + * |
|
| 430 | + * @param string $id |
|
| 431 | + * @param string $search_for_id |
|
| 432 | + * |
|
| 433 | + * @return mixed |
|
| 434 | + */ |
|
| 435 | + public static function shortcode_button( $id = '', $search_for_id = '' ) { |
|
| 436 | + ob_start(); |
|
| 437 | + ?> |
|
| 438 | 438 | <span class="sd-lable-shortcode-inserter"> |
| 439 | 439 | <a onclick="sd_ajax_get_picker(<?php echo $id; |
| 440 | - if ( $search_for_id ) { |
|
| 441 | - echo "," . $search_for_id; |
|
| 442 | - } ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed" |
|
| 440 | + if ( $search_for_id ) { |
|
| 441 | + echo "," . $search_for_id; |
|
| 442 | + } ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed" |
|
| 443 | 443 | class="thickbox button super-duper-content-open" title="Add Shortcode"> |
| 444 | 444 | <span style="vertical-align: middle;line-height: 18px;font-size: 20px;" |
| 445 | 445 | class="dashicons dashicons-screenoptions"></span> |
@@ -450,21 +450,21 @@ discard block |
||
| 450 | 450 | </span> |
| 451 | 451 | |
| 452 | 452 | <?php |
| 453 | - $html = ob_get_clean(); |
|
| 453 | + $html = ob_get_clean(); |
|
| 454 | 454 | |
| 455 | - // remove line breaks so we can use it in js |
|
| 456 | - return preg_replace( "/\r|\n/", "", trim( $html ) ); |
|
| 457 | - } |
|
| 455 | + // remove line breaks so we can use it in js |
|
| 456 | + return preg_replace( "/\r|\n/", "", trim( $html ) ); |
|
| 457 | + } |
|
| 458 | 458 | |
| 459 | - /** |
|
| 460 | - * Makes SD work with the siteOrigin page builder. |
|
| 461 | - * |
|
| 462 | - * @return mixed |
|
| 463 | - *@since 1.0.6 |
|
| 464 | - */ |
|
| 465 | - public static function siteorigin_js() { |
|
| 466 | - ob_start(); |
|
| 467 | - ?> |
|
| 459 | + /** |
|
| 460 | + * Makes SD work with the siteOrigin page builder. |
|
| 461 | + * |
|
| 462 | + * @return mixed |
|
| 463 | + *@since 1.0.6 |
|
| 464 | + */ |
|
| 465 | + public static function siteorigin_js() { |
|
| 466 | + ob_start(); |
|
| 467 | + ?> |
|
| 468 | 468 | <script> |
| 469 | 469 | /** |
| 470 | 470 | * Check a form to see what items should be shown or hidden. |
@@ -540,29 +540,29 @@ discard block |
||
| 540 | 540 | }); |
| 541 | 541 | </script> |
| 542 | 542 | <?php |
| 543 | - $output = ob_get_clean(); |
|
| 543 | + $output = ob_get_clean(); |
|
| 544 | 544 | |
| 545 | - /* |
|
| 545 | + /* |
|
| 546 | 546 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 547 | 547 | */ |
| 548 | 548 | |
| 549 | - return str_replace( array( |
|
| 550 | - '<script>', |
|
| 551 | - '</script>' |
|
| 552 | - ), '', $output ); |
|
| 553 | - } |
|
| 549 | + return str_replace( array( |
|
| 550 | + '<script>', |
|
| 551 | + '</script>' |
|
| 552 | + ), '', $output ); |
|
| 553 | + } |
|
| 554 | 554 | |
| 555 | - /** |
|
| 556 | - * Output the JS and CSS for the shortcode insert button. |
|
| 557 | - * |
|
| 558 | - * @param string $editor_id |
|
| 559 | - * @param string $insert_shortcode_function |
|
| 560 | - * |
|
| 561 | - *@since 1.0.6 |
|
| 562 | - * |
|
| 563 | - */ |
|
| 564 | - public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) { |
|
| 565 | - ?> |
|
| 555 | + /** |
|
| 556 | + * Output the JS and CSS for the shortcode insert button. |
|
| 557 | + * |
|
| 558 | + * @param string $editor_id |
|
| 559 | + * @param string $insert_shortcode_function |
|
| 560 | + * |
|
| 561 | + *@since 1.0.6 |
|
| 562 | + * |
|
| 563 | + */ |
|
| 564 | + public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) { |
|
| 565 | + ?> |
|
| 566 | 566 | <style> |
| 567 | 567 | .sd-shortcode-left-wrap { |
| 568 | 568 | float: left; |
@@ -690,35 +690,35 @@ discard block |
||
| 690 | 690 | <?php } ?> |
| 691 | 691 | </style> |
| 692 | 692 | <?php |
| 693 | - if ( class_exists( 'SiteOrigin_Panels' ) ) { |
|
| 694 | - echo "<script>" . self::siteorigin_js() . "</script>"; |
|
| 695 | - } |
|
| 696 | - ?> |
|
| 693 | + if ( class_exists( 'SiteOrigin_Panels' ) ) { |
|
| 694 | + echo "<script>" . self::siteorigin_js() . "</script>"; |
|
| 695 | + } |
|
| 696 | + ?> |
|
| 697 | 697 | <script> |
| 698 | 698 | <?php |
| 699 | - if(! empty( $insert_shortcode_function )){ |
|
| 700 | - echo $insert_shortcode_function; |
|
| 701 | - }else{ |
|
| 702 | - |
|
| 703 | - /** |
|
| 704 | - * Function for super duper insert shortcode. |
|
| 705 | - * |
|
| 706 | - * @since 1.0.0 |
|
| 707 | - */ |
|
| 708 | - ?> |
|
| 699 | + if(! empty( $insert_shortcode_function )){ |
|
| 700 | + echo $insert_shortcode_function; |
|
| 701 | + }else{ |
|
| 702 | + |
|
| 703 | + /** |
|
| 704 | + * Function for super duper insert shortcode. |
|
| 705 | + * |
|
| 706 | + * @since 1.0.0 |
|
| 707 | + */ |
|
| 708 | + ?> |
|
| 709 | 709 | function sd_insert_shortcode($editor_id) { |
| 710 | 710 | $shortcode = jQuery('#TB_ajaxContent #sd-shortcode-output').val(); |
| 711 | 711 | if ($shortcode) { |
| 712 | 712 | if (!$editor_id) { |
| 713 | 713 | <?php |
| 714 | - if ( isset( $_REQUEST['et_fb'] ) ) { |
|
| 715 | - echo '$editor_id = "#main_content_content_vb_tiny_mce";'; |
|
| 716 | - } elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) { |
|
| 717 | - echo '$editor_id = "#elementor-controls .wp-editor-container textarea";'; |
|
| 718 | - } else { |
|
| 719 | - echo '$editor_id = "#wp-content-editor-container textarea";'; |
|
| 720 | - } |
|
| 721 | - ?> |
|
| 714 | + if ( isset( $_REQUEST['et_fb'] ) ) { |
|
| 715 | + echo '$editor_id = "#main_content_content_vb_tiny_mce";'; |
|
| 716 | + } elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) { |
|
| 717 | + echo '$editor_id = "#elementor-controls .wp-editor-container textarea";'; |
|
| 718 | + } else { |
|
| 719 | + echo '$editor_id = "#wp-content-editor-container textarea";'; |
|
| 720 | + } |
|
| 721 | + ?> |
|
| 722 | 722 | } else { |
| 723 | 723 | $editor_id = '#' + $editor_id; |
| 724 | 724 | } |
@@ -1045,18 +1045,18 @@ discard block |
||
| 1045 | 1045 | |
| 1046 | 1046 | </script> |
| 1047 | 1047 | <?php |
| 1048 | - } |
|
| 1048 | + } |
|
| 1049 | 1049 | |
| 1050 | - /** |
|
| 1051 | - * Gets some CSS for the widgets screen. |
|
| 1052 | - * |
|
| 1053 | - * @param bool $advanced If we should include advanced CSS. |
|
| 1054 | - * |
|
| 1055 | - * @return mixed |
|
| 1056 | - */ |
|
| 1057 | - public function widget_css( $advanced = true ) { |
|
| 1058 | - ob_start(); |
|
| 1059 | - ?> |
|
| 1050 | + /** |
|
| 1051 | + * Gets some CSS for the widgets screen. |
|
| 1052 | + * |
|
| 1053 | + * @param bool $advanced If we should include advanced CSS. |
|
| 1054 | + * |
|
| 1055 | + * @return mixed |
|
| 1056 | + */ |
|
| 1057 | + public function widget_css( $advanced = true ) { |
|
| 1058 | + ob_start(); |
|
| 1059 | + ?> |
|
| 1060 | 1060 | <style> |
| 1061 | 1061 | <?php if( $advanced ){ ?> |
| 1062 | 1062 | .sd-advanced-setting { |
@@ -1094,26 +1094,26 @@ discard block |
||
| 1094 | 1094 | } |
| 1095 | 1095 | </style> |
| 1096 | 1096 | <?php |
| 1097 | - $output = ob_get_clean(); |
|
| 1097 | + $output = ob_get_clean(); |
|
| 1098 | 1098 | |
| 1099 | - /* |
|
| 1099 | + /* |
|
| 1100 | 1100 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1101 | 1101 | */ |
| 1102 | 1102 | |
| 1103 | - return str_replace( array( |
|
| 1104 | - '<style>', |
|
| 1105 | - '</style>' |
|
| 1106 | - ), '', $output ); |
|
| 1107 | - } |
|
| 1103 | + return str_replace( array( |
|
| 1104 | + '<style>', |
|
| 1105 | + '</style>' |
|
| 1106 | + ), '', $output ); |
|
| 1107 | + } |
|
| 1108 | 1108 | |
| 1109 | - /** |
|
| 1110 | - * Gets some JS for the widgets screen. |
|
| 1111 | - * |
|
| 1112 | - * @return mixed |
|
| 1113 | - */ |
|
| 1114 | - public function widget_js() { |
|
| 1115 | - ob_start(); |
|
| 1116 | - ?> |
|
| 1109 | + /** |
|
| 1110 | + * Gets some JS for the widgets screen. |
|
| 1111 | + * |
|
| 1112 | + * @return mixed |
|
| 1113 | + */ |
|
| 1114 | + public function widget_js() { |
|
| 1115 | + ob_start(); |
|
| 1116 | + ?> |
|
| 1117 | 1117 | <script> |
| 1118 | 1118 | |
| 1119 | 1119 | /** |
@@ -1268,471 +1268,471 @@ discard block |
||
| 1268 | 1268 | <?php do_action( 'wp_super_duper_widget_js', $this ); ?> |
| 1269 | 1269 | </script> |
| 1270 | 1270 | <?php |
| 1271 | - $output = ob_get_clean(); |
|
| 1271 | + $output = ob_get_clean(); |
|
| 1272 | 1272 | |
| 1273 | - /* |
|
| 1273 | + /* |
|
| 1274 | 1274 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1275 | 1275 | */ |
| 1276 | 1276 | |
| 1277 | - return str_replace( array( |
|
| 1278 | - '<script>', |
|
| 1279 | - '</script>' |
|
| 1280 | - ), '', $output ); |
|
| 1281 | - } |
|
| 1277 | + return str_replace( array( |
|
| 1278 | + '<script>', |
|
| 1279 | + '</script>' |
|
| 1280 | + ), '', $output ); |
|
| 1281 | + } |
|
| 1282 | 1282 | |
| 1283 | 1283 | |
| 1284 | - /** |
|
| 1285 | - * Set the name from the argument key. |
|
| 1286 | - * |
|
| 1287 | - * @param $options |
|
| 1288 | - * |
|
| 1289 | - * @return mixed |
|
| 1290 | - */ |
|
| 1291 | - private function add_name_from_key( $options, $arguments = false ) { |
|
| 1292 | - if ( ! empty( $options['arguments'] ) ) { |
|
| 1293 | - foreach ( $options['arguments'] as $key => $val ) { |
|
| 1294 | - $options['arguments'][ $key ]['name'] = $key; |
|
| 1295 | - } |
|
| 1296 | - } elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) { |
|
| 1297 | - foreach ( $options as $key => $val ) { |
|
| 1298 | - $options[ $key ]['name'] = $key; |
|
| 1299 | - } |
|
| 1300 | - } |
|
| 1284 | + /** |
|
| 1285 | + * Set the name from the argument key. |
|
| 1286 | + * |
|
| 1287 | + * @param $options |
|
| 1288 | + * |
|
| 1289 | + * @return mixed |
|
| 1290 | + */ |
|
| 1291 | + private function add_name_from_key( $options, $arguments = false ) { |
|
| 1292 | + if ( ! empty( $options['arguments'] ) ) { |
|
| 1293 | + foreach ( $options['arguments'] as $key => $val ) { |
|
| 1294 | + $options['arguments'][ $key ]['name'] = $key; |
|
| 1295 | + } |
|
| 1296 | + } elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) { |
|
| 1297 | + foreach ( $options as $key => $val ) { |
|
| 1298 | + $options[ $key ]['name'] = $key; |
|
| 1299 | + } |
|
| 1300 | + } |
|
| 1301 | 1301 | |
| 1302 | - return $options; |
|
| 1303 | - } |
|
| 1302 | + return $options; |
|
| 1303 | + } |
|
| 1304 | 1304 | |
| 1305 | - /** |
|
| 1306 | - * Register the parent shortcode. |
|
| 1307 | - * |
|
| 1308 | - * @since 1.0.0 |
|
| 1309 | - */ |
|
| 1310 | - public function register_shortcode() { |
|
| 1311 | - add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) ); |
|
| 1312 | - add_action( 'wp_ajax_super_duper_output_shortcode', array( $this, 'render_shortcode' ) ); |
|
| 1313 | - } |
|
| 1305 | + /** |
|
| 1306 | + * Register the parent shortcode. |
|
| 1307 | + * |
|
| 1308 | + * @since 1.0.0 |
|
| 1309 | + */ |
|
| 1310 | + public function register_shortcode() { |
|
| 1311 | + add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) ); |
|
| 1312 | + add_action( 'wp_ajax_super_duper_output_shortcode', array( $this, 'render_shortcode' ) ); |
|
| 1313 | + } |
|
| 1314 | 1314 | |
| 1315 | - /** |
|
| 1316 | - * Render the shortcode via ajax so we can return it to Gutenberg. |
|
| 1317 | - * |
|
| 1318 | - * @since 1.0.0 |
|
| 1319 | - */ |
|
| 1320 | - public function render_shortcode() { |
|
| 1321 | - check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true ); |
|
| 1322 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 1323 | - wp_die(); |
|
| 1324 | - } |
|
| 1315 | + /** |
|
| 1316 | + * Render the shortcode via ajax so we can return it to Gutenberg. |
|
| 1317 | + * |
|
| 1318 | + * @since 1.0.0 |
|
| 1319 | + */ |
|
| 1320 | + public function render_shortcode() { |
|
| 1321 | + check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true ); |
|
| 1322 | + if ( ! current_user_can( 'manage_options' ) ) { |
|
| 1323 | + wp_die(); |
|
| 1324 | + } |
|
| 1325 | 1325 | |
| 1326 | - // we might need the $post value here so lets set it. |
|
| 1327 | - if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) { |
|
| 1328 | - $post_obj = get_post( absint( $_POST['post_id'] ) ); |
|
| 1329 | - if ( ! empty( $post_obj ) && empty( $post ) ) { |
|
| 1330 | - global $post; |
|
| 1331 | - $post = $post_obj; |
|
| 1332 | - } |
|
| 1333 | - } |
|
| 1326 | + // we might need the $post value here so lets set it. |
|
| 1327 | + if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) { |
|
| 1328 | + $post_obj = get_post( absint( $_POST['post_id'] ) ); |
|
| 1329 | + if ( ! empty( $post_obj ) && empty( $post ) ) { |
|
| 1330 | + global $post; |
|
| 1331 | + $post = $post_obj; |
|
| 1332 | + } |
|
| 1333 | + } |
|
| 1334 | 1334 | |
| 1335 | - if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) { |
|
| 1336 | - $is_preview = $this->is_preview(); |
|
| 1337 | - $shortcode_name = sanitize_title_with_dashes( $_POST['shortcode'] ); |
|
| 1338 | - $attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array(); |
|
| 1339 | - $attributes = ''; |
|
| 1340 | - if ( ! empty( $attributes_array ) ) { |
|
| 1341 | - foreach ( $attributes_array as $key => $value ) { |
|
| 1342 | - if ( is_array( $value ) ) { |
|
| 1343 | - $value = implode( ",", $value ); |
|
| 1344 | - } |
|
| 1335 | + if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) { |
|
| 1336 | + $is_preview = $this->is_preview(); |
|
| 1337 | + $shortcode_name = sanitize_title_with_dashes( $_POST['shortcode'] ); |
|
| 1338 | + $attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array(); |
|
| 1339 | + $attributes = ''; |
|
| 1340 | + if ( ! empty( $attributes_array ) ) { |
|
| 1341 | + foreach ( $attributes_array as $key => $value ) { |
|
| 1342 | + if ( is_array( $value ) ) { |
|
| 1343 | + $value = implode( ",", $value ); |
|
| 1344 | + } |
|
| 1345 | 1345 | |
| 1346 | - if ( ! empty( $value ) ) { |
|
| 1347 | - $value = wp_unslash( $value ); |
|
| 1346 | + if ( ! empty( $value ) ) { |
|
| 1347 | + $value = wp_unslash( $value ); |
|
| 1348 | 1348 | |
| 1349 | - // Encode [ and ]. |
|
| 1350 | - if ( $is_preview ) { |
|
| 1351 | - $value = $this->encode_shortcodes( $value ); |
|
| 1352 | - } |
|
| 1353 | - } |
|
| 1354 | - $attributes .= " " . sanitize_title_with_dashes( $key ) . "='" . esc_attr( $value ) . "' "; |
|
| 1355 | - } |
|
| 1356 | - } |
|
| 1349 | + // Encode [ and ]. |
|
| 1350 | + if ( $is_preview ) { |
|
| 1351 | + $value = $this->encode_shortcodes( $value ); |
|
| 1352 | + } |
|
| 1353 | + } |
|
| 1354 | + $attributes .= " " . sanitize_title_with_dashes( $key ) . "='" . esc_attr( $value ) . "' "; |
|
| 1355 | + } |
|
| 1356 | + } |
|
| 1357 | 1357 | |
| 1358 | - $shortcode = "[" . $shortcode_name . " " . $attributes . "]"; |
|
| 1358 | + $shortcode = "[" . $shortcode_name . " " . $attributes . "]"; |
|
| 1359 | 1359 | |
| 1360 | - $content = do_shortcode( $shortcode ); |
|
| 1360 | + $content = do_shortcode( $shortcode ); |
|
| 1361 | 1361 | |
| 1362 | - // Decode [ and ]. |
|
| 1363 | - if ( ! empty( $content ) && $is_preview ) { |
|
| 1364 | - $content = $this->decode_shortcodes( $content ); |
|
| 1365 | - } |
|
| 1362 | + // Decode [ and ]. |
|
| 1363 | + if ( ! empty( $content ) && $is_preview ) { |
|
| 1364 | + $content = $this->decode_shortcodes( $content ); |
|
| 1365 | + } |
|
| 1366 | 1366 | |
| 1367 | - echo $content; |
|
| 1368 | - } |
|
| 1369 | - wp_die(); |
|
| 1370 | - } |
|
| 1367 | + echo $content; |
|
| 1368 | + } |
|
| 1369 | + wp_die(); |
|
| 1370 | + } |
|
| 1371 | 1371 | |
| 1372 | - /** |
|
| 1373 | - * Output the shortcode. |
|
| 1374 | - * |
|
| 1375 | - * @param array $args |
|
| 1376 | - * @param string $content |
|
| 1377 | - * |
|
| 1378 | - * @return string |
|
| 1379 | - */ |
|
| 1380 | - public function shortcode_output( $args = array(), $content = '' ) { |
|
| 1381 | - $_instance = $args; |
|
| 1382 | - |
|
| 1383 | - $args = $this->argument_values( $args ); |
|
| 1384 | - |
|
| 1385 | - // add extra argument so we know its a output to gutenberg |
|
| 1386 | - //$args |
|
| 1387 | - $args = $this->string_to_bool( $args ); |
|
| 1388 | - |
|
| 1389 | - // if we have a enclosed shortcode we add it to the special `html` argument |
|
| 1390 | - if ( ! empty( $content ) ) { |
|
| 1391 | - $args['html'] = $content; |
|
| 1392 | - } |
|
| 1372 | + /** |
|
| 1373 | + * Output the shortcode. |
|
| 1374 | + * |
|
| 1375 | + * @param array $args |
|
| 1376 | + * @param string $content |
|
| 1377 | + * |
|
| 1378 | + * @return string |
|
| 1379 | + */ |
|
| 1380 | + public function shortcode_output( $args = array(), $content = '' ) { |
|
| 1381 | + $_instance = $args; |
|
| 1393 | 1382 | |
| 1394 | - if ( ! $this->is_preview() ) { |
|
| 1395 | - /** |
|
| 1396 | - * Filters the settings for a particular widget args. |
|
| 1397 | - * |
|
| 1398 | - * @param array $args The current widget instance's settings. |
|
| 1399 | - * @param WP_Super_Duper $widget The current widget settings. |
|
| 1400 | - * @param array $_instance An array of default widget arguments. |
|
| 1401 | - * |
|
| 1402 | - *@since 1.0.28 |
|
| 1403 | - * |
|
| 1404 | - */ |
|
| 1405 | - $args = apply_filters( 'wp_super_duper_widget_display_callback', $args, $this, $_instance ); |
|
| 1383 | + $args = $this->argument_values( $args ); |
|
| 1406 | 1384 | |
| 1407 | - if ( ! is_array( $args ) ) { |
|
| 1408 | - return $args; |
|
| 1409 | - } |
|
| 1410 | - } |
|
| 1385 | + // add extra argument so we know its a output to gutenberg |
|
| 1386 | + //$args |
|
| 1387 | + $args = $this->string_to_bool( $args ); |
|
| 1411 | 1388 | |
| 1412 | - $class = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : ''; |
|
| 1413 | - $class .= " sdel-".$this->get_instance_hash(); |
|
| 1389 | + // if we have a enclosed shortcode we add it to the special `html` argument |
|
| 1390 | + if ( ! empty( $content ) ) { |
|
| 1391 | + $args['html'] = $content; |
|
| 1392 | + } |
|
| 1414 | 1393 | |
| 1415 | - $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this ); |
|
| 1416 | - $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this ); |
|
| 1394 | + if ( ! $this->is_preview() ) { |
|
| 1395 | + /** |
|
| 1396 | + * Filters the settings for a particular widget args. |
|
| 1397 | + * |
|
| 1398 | + * @param array $args The current widget instance's settings. |
|
| 1399 | + * @param WP_Super_Duper $widget The current widget settings. |
|
| 1400 | + * @param array $_instance An array of default widget arguments. |
|
| 1401 | + * |
|
| 1402 | + *@since 1.0.28 |
|
| 1403 | + * |
|
| 1404 | + */ |
|
| 1405 | + $args = apply_filters( 'wp_super_duper_widget_display_callback', $args, $this, $_instance ); |
|
| 1406 | + |
|
| 1407 | + if ( ! is_array( $args ) ) { |
|
| 1408 | + return $args; |
|
| 1409 | + } |
|
| 1410 | + } |
|
| 1417 | 1411 | |
| 1418 | - $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this ); |
|
| 1419 | - $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this ); |
|
| 1412 | + $class = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : ''; |
|
| 1413 | + $class .= " sdel-".$this->get_instance_hash(); |
|
| 1420 | 1414 | |
| 1421 | - $shortcode_args = array(); |
|
| 1422 | - $output = ''; |
|
| 1423 | - $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false; |
|
| 1424 | - if ( isset( $args['no_wrap'] ) && $args['no_wrap'] ) { |
|
| 1425 | - $no_wrap = true; |
|
| 1426 | - } |
|
| 1427 | - $main_content = $this->output( $args, $shortcode_args, $content ); |
|
| 1428 | - if ( $main_content && ! $no_wrap ) { |
|
| 1429 | - // wrap the shortcode in a div with the same class as the widget |
|
| 1430 | - $output .= '<div class="' . $class . '" ' . $attrs . '>'; |
|
| 1431 | - if ( ! empty( $args['title'] ) ) { |
|
| 1432 | - // if its a shortcode and there is a title try to grab the title wrappers |
|
| 1433 | - $shortcode_args = array( 'before_title' => '', 'after_title' => '' ); |
|
| 1434 | - if ( empty( $instance ) ) { |
|
| 1435 | - global $wp_registered_sidebars; |
|
| 1436 | - if ( ! empty( $wp_registered_sidebars ) ) { |
|
| 1437 | - foreach ( $wp_registered_sidebars as $sidebar ) { |
|
| 1438 | - if ( ! empty( $sidebar['before_title'] ) ) { |
|
| 1439 | - $shortcode_args['before_title'] = $sidebar['before_title']; |
|
| 1440 | - $shortcode_args['after_title'] = $sidebar['after_title']; |
|
| 1441 | - break; |
|
| 1442 | - } |
|
| 1443 | - } |
|
| 1444 | - } |
|
| 1445 | - } |
|
| 1446 | - $output .= $this->output_title( $shortcode_args, $args ); |
|
| 1447 | - } |
|
| 1448 | - $output .= $main_content; |
|
| 1449 | - $output .= '</div>'; |
|
| 1450 | - } elseif ( $main_content && $no_wrap ) { |
|
| 1451 | - $output .= $main_content; |
|
| 1452 | - } |
|
| 1415 | + $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this ); |
|
| 1416 | + $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this ); |
|
| 1453 | 1417 | |
| 1454 | - // if preview show a placeholder if empty |
|
| 1455 | - if ( $this->is_preview() && $output == '' ) { |
|
| 1456 | - $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" ); |
|
| 1457 | - } |
|
| 1418 | + $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this ); |
|
| 1419 | + $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this ); |
|
| 1458 | 1420 | |
| 1459 | - return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this ); |
|
| 1460 | - } |
|
| 1421 | + $shortcode_args = array(); |
|
| 1422 | + $output = ''; |
|
| 1423 | + $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false; |
|
| 1424 | + if ( isset( $args['no_wrap'] ) && $args['no_wrap'] ) { |
|
| 1425 | + $no_wrap = true; |
|
| 1426 | + } |
|
| 1427 | + $main_content = $this->output( $args, $shortcode_args, $content ); |
|
| 1428 | + if ( $main_content && ! $no_wrap ) { |
|
| 1429 | + // wrap the shortcode in a div with the same class as the widget |
|
| 1430 | + $output .= '<div class="' . $class . '" ' . $attrs . '>'; |
|
| 1431 | + if ( ! empty( $args['title'] ) ) { |
|
| 1432 | + // if its a shortcode and there is a title try to grab the title wrappers |
|
| 1433 | + $shortcode_args = array( 'before_title' => '', 'after_title' => '' ); |
|
| 1434 | + if ( empty( $instance ) ) { |
|
| 1435 | + global $wp_registered_sidebars; |
|
| 1436 | + if ( ! empty( $wp_registered_sidebars ) ) { |
|
| 1437 | + foreach ( $wp_registered_sidebars as $sidebar ) { |
|
| 1438 | + if ( ! empty( $sidebar['before_title'] ) ) { |
|
| 1439 | + $shortcode_args['before_title'] = $sidebar['before_title']; |
|
| 1440 | + $shortcode_args['after_title'] = $sidebar['after_title']; |
|
| 1441 | + break; |
|
| 1442 | + } |
|
| 1443 | + } |
|
| 1444 | + } |
|
| 1445 | + } |
|
| 1446 | + $output .= $this->output_title( $shortcode_args, $args ); |
|
| 1447 | + } |
|
| 1448 | + $output .= $main_content; |
|
| 1449 | + $output .= '</div>'; |
|
| 1450 | + } elseif ( $main_content && $no_wrap ) { |
|
| 1451 | + $output .= $main_content; |
|
| 1452 | + } |
|
| 1461 | 1453 | |
| 1462 | - /** |
|
| 1463 | - * Placeholder text to show if output is empty and we are on a preview/builder page. |
|
| 1464 | - * |
|
| 1465 | - * @param string $name |
|
| 1466 | - * |
|
| 1467 | - * @return string |
|
| 1468 | - */ |
|
| 1469 | - public function preview_placeholder_text( $name = '' ) { |
|
| 1470 | - return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf( __( 'Placeholder for: %s' ), $name ) . "</div>"; |
|
| 1471 | - } |
|
| 1454 | + // if preview show a placeholder if empty |
|
| 1455 | + if ( $this->is_preview() && $output == '' ) { |
|
| 1456 | + $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" ); |
|
| 1457 | + } |
|
| 1472 | 1458 | |
| 1473 | - /** |
|
| 1474 | - * Sometimes booleans values can be turned to strings, so we fix that. |
|
| 1475 | - * |
|
| 1476 | - * @param $options |
|
| 1477 | - * |
|
| 1478 | - * @return mixed |
|
| 1479 | - */ |
|
| 1480 | - public function string_to_bool( $options ) { |
|
| 1481 | - // convert bool strings to booleans |
|
| 1482 | - foreach ( $options as $key => $val ) { |
|
| 1483 | - if ( $val == 'false' ) { |
|
| 1484 | - $options[ $key ] = false; |
|
| 1485 | - } elseif ( $val == 'true' ) { |
|
| 1486 | - $options[ $key ] = true; |
|
| 1487 | - } |
|
| 1488 | - } |
|
| 1459 | + return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this ); |
|
| 1460 | + } |
|
| 1489 | 1461 | |
| 1490 | - return $options; |
|
| 1491 | - } |
|
| 1462 | + /** |
|
| 1463 | + * Placeholder text to show if output is empty and we are on a preview/builder page. |
|
| 1464 | + * |
|
| 1465 | + * @param string $name |
|
| 1466 | + * |
|
| 1467 | + * @return string |
|
| 1468 | + */ |
|
| 1469 | + public function preview_placeholder_text( $name = '' ) { |
|
| 1470 | + return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf( __( 'Placeholder for: %s' ), $name ) . "</div>"; |
|
| 1471 | + } |
|
| 1492 | 1472 | |
| 1493 | - /** |
|
| 1494 | - * Get the argument values that are also filterable. |
|
| 1495 | - * |
|
| 1496 | - * @param $instance |
|
| 1497 | - * |
|
| 1498 | - * @return array |
|
| 1499 | - *@since 1.0.12 Don't set checkbox default value if the value is empty. |
|
| 1500 | - * |
|
| 1501 | - */ |
|
| 1502 | - public function argument_values( $instance ) { |
|
| 1503 | - $argument_values = array(); |
|
| 1504 | - |
|
| 1505 | - // set widget instance |
|
| 1506 | - $this->instance = $instance; |
|
| 1507 | - |
|
| 1508 | - if ( empty( $this->arguments ) ) { |
|
| 1509 | - $this->arguments = $this->get_arguments(); |
|
| 1510 | - } |
|
| 1473 | + /** |
|
| 1474 | + * Sometimes booleans values can be turned to strings, so we fix that. |
|
| 1475 | + * |
|
| 1476 | + * @param $options |
|
| 1477 | + * |
|
| 1478 | + * @return mixed |
|
| 1479 | + */ |
|
| 1480 | + public function string_to_bool( $options ) { |
|
| 1481 | + // convert bool strings to booleans |
|
| 1482 | + foreach ( $options as $key => $val ) { |
|
| 1483 | + if ( $val == 'false' ) { |
|
| 1484 | + $options[ $key ] = false; |
|
| 1485 | + } elseif ( $val == 'true' ) { |
|
| 1486 | + $options[ $key ] = true; |
|
| 1487 | + } |
|
| 1488 | + } |
|
| 1511 | 1489 | |
| 1512 | - if ( ! empty( $this->arguments ) ) { |
|
| 1513 | - foreach ( $this->arguments as $key => $args ) { |
|
| 1514 | - // set the input name from the key |
|
| 1515 | - $args['name'] = $key; |
|
| 1516 | - // |
|
| 1517 | - $argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : ''; |
|
| 1518 | - if ( $args['type'] == 'checkbox' && $argument_values[ $key ] == '' ) { |
|
| 1519 | - // don't set default for an empty checkbox |
|
| 1520 | - } elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) { |
|
| 1521 | - $argument_values[ $key ] = $args['default']; |
|
| 1522 | - } |
|
| 1523 | - } |
|
| 1524 | - } |
|
| 1490 | + return $options; |
|
| 1491 | + } |
|
| 1525 | 1492 | |
| 1526 | - return $argument_values; |
|
| 1527 | - } |
|
| 1493 | + /** |
|
| 1494 | + * Get the argument values that are also filterable. |
|
| 1495 | + * |
|
| 1496 | + * @param $instance |
|
| 1497 | + * |
|
| 1498 | + * @return array |
|
| 1499 | + *@since 1.0.12 Don't set checkbox default value if the value is empty. |
|
| 1500 | + * |
|
| 1501 | + */ |
|
| 1502 | + public function argument_values( $instance ) { |
|
| 1503 | + $argument_values = array(); |
|
| 1528 | 1504 | |
| 1529 | - /** |
|
| 1530 | - * Set arguments in super duper. |
|
| 1531 | - * |
|
| 1532 | - * @return array Set arguments. |
|
| 1533 | - *@since 1.0.0 |
|
| 1534 | - * |
|
| 1535 | - */ |
|
| 1536 | - public function set_arguments() { |
|
| 1537 | - return $this->arguments; |
|
| 1538 | - } |
|
| 1505 | + // set widget instance |
|
| 1506 | + $this->instance = $instance; |
|
| 1539 | 1507 | |
| 1540 | - /** |
|
| 1541 | - * Get arguments in super duper. |
|
| 1542 | - * |
|
| 1543 | - * @return array Get arguments. |
|
| 1544 | - *@since 1.0.0 |
|
| 1545 | - * |
|
| 1546 | - */ |
|
| 1547 | - public function get_arguments() { |
|
| 1548 | - if ( empty( $this->arguments ) ) { |
|
| 1549 | - $this->arguments = $this->set_arguments(); |
|
| 1550 | - } |
|
| 1508 | + if ( empty( $this->arguments ) ) { |
|
| 1509 | + $this->arguments = $this->get_arguments(); |
|
| 1510 | + } |
|
| 1551 | 1511 | |
| 1552 | - $this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance ); |
|
| 1553 | - $this->arguments = $this->add_name_from_key( $this->arguments, true ); |
|
| 1512 | + if ( ! empty( $this->arguments ) ) { |
|
| 1513 | + foreach ( $this->arguments as $key => $args ) { |
|
| 1514 | + // set the input name from the key |
|
| 1515 | + $args['name'] = $key; |
|
| 1516 | + // |
|
| 1517 | + $argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : ''; |
|
| 1518 | + if ( $args['type'] == 'checkbox' && $argument_values[ $key ] == '' ) { |
|
| 1519 | + // don't set default for an empty checkbox |
|
| 1520 | + } elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) { |
|
| 1521 | + $argument_values[ $key ] = $args['default']; |
|
| 1522 | + } |
|
| 1523 | + } |
|
| 1524 | + } |
|
| 1554 | 1525 | |
| 1555 | - return $this->arguments; |
|
| 1556 | - } |
|
| 1526 | + return $argument_values; |
|
| 1527 | + } |
|
| 1557 | 1528 | |
| 1558 | - /** |
|
| 1559 | - * This is the main output class for all 3 items, widget, shortcode and block, it is extended in the calling class. |
|
| 1560 | - * |
|
| 1561 | - * @param array $args |
|
| 1562 | - * @param array $widget_args |
|
| 1563 | - * @param string $content |
|
| 1564 | - */ |
|
| 1565 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 1529 | + /** |
|
| 1530 | + * Set arguments in super duper. |
|
| 1531 | + * |
|
| 1532 | + * @return array Set arguments. |
|
| 1533 | + *@since 1.0.0 |
|
| 1534 | + * |
|
| 1535 | + */ |
|
| 1536 | + public function set_arguments() { |
|
| 1537 | + return $this->arguments; |
|
| 1538 | + } |
|
| 1566 | 1539 | |
| 1567 | - } |
|
| 1540 | + /** |
|
| 1541 | + * Get arguments in super duper. |
|
| 1542 | + * |
|
| 1543 | + * @return array Get arguments. |
|
| 1544 | + *@since 1.0.0 |
|
| 1545 | + * |
|
| 1546 | + */ |
|
| 1547 | + public function get_arguments() { |
|
| 1548 | + if ( empty( $this->arguments ) ) { |
|
| 1549 | + $this->arguments = $this->set_arguments(); |
|
| 1550 | + } |
|
| 1568 | 1551 | |
| 1569 | - /** |
|
| 1570 | - * Add the dynamic block code inline when the wp-block in enqueued. |
|
| 1571 | - */ |
|
| 1572 | - public function register_block() { |
|
| 1573 | - wp_add_inline_script( 'wp-blocks', $this->block() ); |
|
| 1574 | - if ( class_exists( 'SiteOrigin_Panels' ) ) { |
|
| 1575 | - wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() ); |
|
| 1576 | - } |
|
| 1577 | - } |
|
| 1552 | + $this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance ); |
|
| 1553 | + $this->arguments = $this->add_name_from_key( $this->arguments, true ); |
|
| 1578 | 1554 | |
| 1579 | - /** |
|
| 1580 | - * Check if we need to show advanced options. |
|
| 1581 | - * |
|
| 1582 | - * @return bool |
|
| 1583 | - */ |
|
| 1584 | - public function block_show_advanced() { |
|
| 1585 | - |
|
| 1586 | - $show = false; |
|
| 1587 | - $arguments = $this->get_arguments(); |
|
| 1588 | - |
|
| 1589 | - if ( ! empty( $arguments ) ) { |
|
| 1590 | - foreach ( $arguments as $argument ) { |
|
| 1591 | - if ( isset( $argument['advanced'] ) && $argument['advanced'] ) { |
|
| 1592 | - $show = true; |
|
| 1593 | - break; // no need to continue if we know we have it |
|
| 1594 | - } |
|
| 1595 | - } |
|
| 1596 | - } |
|
| 1555 | + return $this->arguments; |
|
| 1556 | + } |
|
| 1597 | 1557 | |
| 1598 | - return $show; |
|
| 1599 | - } |
|
| 1558 | + /** |
|
| 1559 | + * This is the main output class for all 3 items, widget, shortcode and block, it is extended in the calling class. |
|
| 1560 | + * |
|
| 1561 | + * @param array $args |
|
| 1562 | + * @param array $widget_args |
|
| 1563 | + * @param string $content |
|
| 1564 | + */ |
|
| 1565 | + public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 1600 | 1566 | |
| 1601 | - /** |
|
| 1602 | - * Get the url path to the current folder. |
|
| 1603 | - * |
|
| 1604 | - * @return string |
|
| 1605 | - */ |
|
| 1606 | - public function get_url() { |
|
| 1607 | - $url = $this->url; |
|
| 1608 | - |
|
| 1609 | - if ( ! $url ) { |
|
| 1610 | - $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) ); |
|
| 1611 | - $content_url = untrailingslashit( WP_CONTENT_URL ); |
|
| 1612 | - |
|
| 1613 | - // Replace http:// to https://. |
|
| 1614 | - if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) { |
|
| 1615 | - $content_url = str_replace( 'http://', 'https://', $content_url ); |
|
| 1616 | - } |
|
| 1567 | + } |
|
| 1617 | 1568 | |
| 1618 | - // Check if we are inside a plugin |
|
| 1619 | - $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 1620 | - $url = str_replace( $content_dir, $content_url, $file_dir ); |
|
| 1621 | - $url = trailingslashit( $url ); |
|
| 1622 | - $this->url = $url; |
|
| 1623 | - } |
|
| 1569 | + /** |
|
| 1570 | + * Add the dynamic block code inline when the wp-block in enqueued. |
|
| 1571 | + */ |
|
| 1572 | + public function register_block() { |
|
| 1573 | + wp_add_inline_script( 'wp-blocks', $this->block() ); |
|
| 1574 | + if ( class_exists( 'SiteOrigin_Panels' ) ) { |
|
| 1575 | + wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() ); |
|
| 1576 | + } |
|
| 1577 | + } |
|
| 1624 | 1578 | |
| 1625 | - return $url; |
|
| 1626 | - } |
|
| 1579 | + /** |
|
| 1580 | + * Check if we need to show advanced options. |
|
| 1581 | + * |
|
| 1582 | + * @return bool |
|
| 1583 | + */ |
|
| 1584 | + public function block_show_advanced() { |
|
| 1627 | 1585 | |
| 1628 | - /** |
|
| 1629 | - * Get the url path to the current folder. |
|
| 1630 | - * |
|
| 1631 | - * @return string |
|
| 1632 | - */ |
|
| 1633 | - public function get_url_old() { |
|
| 1586 | + $show = false; |
|
| 1587 | + $arguments = $this->get_arguments(); |
|
| 1634 | 1588 | |
| 1635 | - $url = $this->url; |
|
| 1589 | + if ( ! empty( $arguments ) ) { |
|
| 1590 | + foreach ( $arguments as $argument ) { |
|
| 1591 | + if ( isset( $argument['advanced'] ) && $argument['advanced'] ) { |
|
| 1592 | + $show = true; |
|
| 1593 | + break; // no need to continue if we know we have it |
|
| 1594 | + } |
|
| 1595 | + } |
|
| 1596 | + } |
|
| 1636 | 1597 | |
| 1637 | - if ( ! $url ) { |
|
| 1638 | - // check if we are inside a plugin |
|
| 1639 | - $file_dir = str_replace( "/includes", "", dirname( __FILE__ ) ); |
|
| 1598 | + return $show; |
|
| 1599 | + } |
|
| 1640 | 1600 | |
| 1641 | - $dir_parts = explode( "/wp-content/", $file_dir ); |
|
| 1642 | - $url_parts = explode( "/wp-content/", plugins_url() ); |
|
| 1601 | + /** |
|
| 1602 | + * Get the url path to the current folder. |
|
| 1603 | + * |
|
| 1604 | + * @return string |
|
| 1605 | + */ |
|
| 1606 | + public function get_url() { |
|
| 1607 | + $url = $this->url; |
|
| 1643 | 1608 | |
| 1644 | - if ( ! empty( $url_parts[0] ) && ! empty( $dir_parts[1] ) ) { |
|
| 1645 | - $url = trailingslashit( $url_parts[0] . "/wp-content/" . $dir_parts[1] ); |
|
| 1646 | - $this->url = $url; |
|
| 1647 | - } |
|
| 1648 | - } |
|
| 1609 | + if ( ! $url ) { |
|
| 1610 | + $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) ); |
|
| 1611 | + $content_url = untrailingslashit( WP_CONTENT_URL ); |
|
| 1649 | 1612 | |
| 1613 | + // Replace http:// to https://. |
|
| 1614 | + if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) { |
|
| 1615 | + $content_url = str_replace( 'http://', 'https://', $content_url ); |
|
| 1616 | + } |
|
| 1650 | 1617 | |
| 1651 | - return $url; |
|
| 1652 | - } |
|
| 1618 | + // Check if we are inside a plugin |
|
| 1619 | + $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 1620 | + $url = str_replace( $content_dir, $content_url, $file_dir ); |
|
| 1621 | + $url = trailingslashit( $url ); |
|
| 1622 | + $this->url = $url; |
|
| 1623 | + } |
|
| 1653 | 1624 | |
| 1654 | - /** |
|
| 1655 | - * Generate the block icon. |
|
| 1656 | - * |
|
| 1657 | - * Enables the use of Font Awesome icons. |
|
| 1658 | - * |
|
| 1659 | - * @note xlink:href is actually deprecated but href is not supported by all so we use both. |
|
| 1660 | - * |
|
| 1661 | - * @param $icon |
|
| 1662 | - * |
|
| 1663 | - * @return string |
|
| 1664 | - *@since 1.1.0 |
|
| 1665 | - */ |
|
| 1666 | - public function get_block_icon( $icon ) { |
|
| 1667 | - |
|
| 1668 | - // check if we have a Font Awesome icon |
|
| 1669 | - $fa_type = ''; |
|
| 1670 | - if ( substr( $icon, 0, 7 ) === "fas fa-" ) { |
|
| 1671 | - $fa_type = 'solid'; |
|
| 1672 | - } elseif ( substr( $icon, 0, 7 ) === "far fa-" ) { |
|
| 1673 | - $fa_type = 'regular'; |
|
| 1674 | - } elseif ( substr( $icon, 0, 7 ) === "fab fa-" ) { |
|
| 1675 | - $fa_type = 'brands'; |
|
| 1676 | - } else { |
|
| 1677 | - $icon = "'" . $icon . "'"; |
|
| 1678 | - } |
|
| 1625 | + return $url; |
|
| 1626 | + } |
|
| 1679 | 1627 | |
| 1680 | - // set the icon if we found one |
|
| 1681 | - if ( $fa_type ) { |
|
| 1682 | - $fa_icon = str_replace( array( "fas fa-", "far fa-", "fab fa-" ), "", $icon ); |
|
| 1683 | - $icon = "el('svg',{width: 20, height: 20, viewBox: '0 0 20 20'},el('use', {'xlink:href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "','href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "'}))"; |
|
| 1684 | - } |
|
| 1628 | + /** |
|
| 1629 | + * Get the url path to the current folder. |
|
| 1630 | + * |
|
| 1631 | + * @return string |
|
| 1632 | + */ |
|
| 1633 | + public function get_url_old() { |
|
| 1685 | 1634 | |
| 1686 | - return $icon; |
|
| 1687 | - } |
|
| 1635 | + $url = $this->url; |
|
| 1636 | + |
|
| 1637 | + if ( ! $url ) { |
|
| 1638 | + // check if we are inside a plugin |
|
| 1639 | + $file_dir = str_replace( "/includes", "", dirname( __FILE__ ) ); |
|
| 1640 | + |
|
| 1641 | + $dir_parts = explode( "/wp-content/", $file_dir ); |
|
| 1642 | + $url_parts = explode( "/wp-content/", plugins_url() ); |
|
| 1643 | + |
|
| 1644 | + if ( ! empty( $url_parts[0] ) && ! empty( $dir_parts[1] ) ) { |
|
| 1645 | + $url = trailingslashit( $url_parts[0] . "/wp-content/" . $dir_parts[1] ); |
|
| 1646 | + $this->url = $url; |
|
| 1647 | + } |
|
| 1648 | + } |
|
| 1649 | + |
|
| 1650 | + |
|
| 1651 | + return $url; |
|
| 1652 | + } |
|
| 1653 | + |
|
| 1654 | + /** |
|
| 1655 | + * Generate the block icon. |
|
| 1656 | + * |
|
| 1657 | + * Enables the use of Font Awesome icons. |
|
| 1658 | + * |
|
| 1659 | + * @note xlink:href is actually deprecated but href is not supported by all so we use both. |
|
| 1660 | + * |
|
| 1661 | + * @param $icon |
|
| 1662 | + * |
|
| 1663 | + * @return string |
|
| 1664 | + *@since 1.1.0 |
|
| 1665 | + */ |
|
| 1666 | + public function get_block_icon( $icon ) { |
|
| 1667 | + |
|
| 1668 | + // check if we have a Font Awesome icon |
|
| 1669 | + $fa_type = ''; |
|
| 1670 | + if ( substr( $icon, 0, 7 ) === "fas fa-" ) { |
|
| 1671 | + $fa_type = 'solid'; |
|
| 1672 | + } elseif ( substr( $icon, 0, 7 ) === "far fa-" ) { |
|
| 1673 | + $fa_type = 'regular'; |
|
| 1674 | + } elseif ( substr( $icon, 0, 7 ) === "fab fa-" ) { |
|
| 1675 | + $fa_type = 'brands'; |
|
| 1676 | + } else { |
|
| 1677 | + $icon = "'" . $icon . "'"; |
|
| 1678 | + } |
|
| 1688 | 1679 | |
| 1689 | - public function group_arguments( $arguments ) { |
|
| 1680 | + // set the icon if we found one |
|
| 1681 | + if ( $fa_type ) { |
|
| 1682 | + $fa_icon = str_replace( array( "fas fa-", "far fa-", "fab fa-" ), "", $icon ); |
|
| 1683 | + $icon = "el('svg',{width: 20, height: 20, viewBox: '0 0 20 20'},el('use', {'xlink:href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "','href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "'}))"; |
|
| 1684 | + } |
|
| 1685 | + |
|
| 1686 | + return $icon; |
|
| 1687 | + } |
|
| 1688 | + |
|
| 1689 | + public function group_arguments( $arguments ) { |
|
| 1690 | 1690 | // echo '###';print_r($arguments); |
| 1691 | - if ( ! empty( $arguments ) ) { |
|
| 1692 | - $temp_arguments = array(); |
|
| 1693 | - $general = __( "General" ); |
|
| 1694 | - $add_sections = false; |
|
| 1695 | - foreach ( $arguments as $key => $args ) { |
|
| 1696 | - if ( isset( $args['group'] ) ) { |
|
| 1697 | - $temp_arguments[ $args['group'] ][ $key ] = $args; |
|
| 1698 | - $add_sections = true; |
|
| 1699 | - } else { |
|
| 1700 | - $temp_arguments[ $general ][ $key ] = $args; |
|
| 1701 | - } |
|
| 1702 | - } |
|
| 1691 | + if ( ! empty( $arguments ) ) { |
|
| 1692 | + $temp_arguments = array(); |
|
| 1693 | + $general = __( "General" ); |
|
| 1694 | + $add_sections = false; |
|
| 1695 | + foreach ( $arguments as $key => $args ) { |
|
| 1696 | + if ( isset( $args['group'] ) ) { |
|
| 1697 | + $temp_arguments[ $args['group'] ][ $key ] = $args; |
|
| 1698 | + $add_sections = true; |
|
| 1699 | + } else { |
|
| 1700 | + $temp_arguments[ $general ][ $key ] = $args; |
|
| 1701 | + } |
|
| 1702 | + } |
|
| 1703 | 1703 | |
| 1704 | - // only add sections if more than one |
|
| 1705 | - if ( $add_sections ) { |
|
| 1706 | - $arguments = $temp_arguments; |
|
| 1707 | - } |
|
| 1708 | - } |
|
| 1704 | + // only add sections if more than one |
|
| 1705 | + if ( $add_sections ) { |
|
| 1706 | + $arguments = $temp_arguments; |
|
| 1707 | + } |
|
| 1708 | + } |
|
| 1709 | 1709 | |
| 1710 | 1710 | // echo '###';print_r($arguments); |
| 1711 | - return $arguments; |
|
| 1712 | - } |
|
| 1711 | + return $arguments; |
|
| 1712 | + } |
|
| 1713 | 1713 | |
| 1714 | 1714 | |
| 1715 | - /** |
|
| 1716 | - * Output the JS for building the dynamic Guntenberg block. |
|
| 1717 | - * |
|
| 1718 | - * @return mixed |
|
| 1719 | - *@since 1.0.9 Save numbers as numbers and not strings. |
|
| 1720 | - * @since 1.1.0 Font Awesome classes can be used for icons. |
|
| 1721 | - * @since 1.0.4 Added block_wrap property which will set the block wrapping output element ie: div, span, p or empty for no wrap. |
|
| 1722 | - */ |
|
| 1723 | - public function block() { |
|
| 1715 | + /** |
|
| 1716 | + * Output the JS for building the dynamic Guntenberg block. |
|
| 1717 | + * |
|
| 1718 | + * @return mixed |
|
| 1719 | + *@since 1.0.9 Save numbers as numbers and not strings. |
|
| 1720 | + * @since 1.1.0 Font Awesome classes can be used for icons. |
|
| 1721 | + * @since 1.0.4 Added block_wrap property which will set the block wrapping output element ie: div, span, p or empty for no wrap. |
|
| 1722 | + */ |
|
| 1723 | + public function block() { |
|
| 1724 | 1724 | global $sd_is_js_functions_loaded; |
| 1725 | 1725 | |
| 1726 | - ob_start(); |
|
| 1726 | + ob_start(); |
|
| 1727 | 1727 | |
| 1728 | - $show_advanced = $this->block_show_advanced(); |
|
| 1728 | + $show_advanced = $this->block_show_advanced(); |
|
| 1729 | 1729 | |
| 1730 | 1730 | |
| 1731 | - ?> |
|
| 1731 | + ?> |
|
| 1732 | 1732 | <script> |
| 1733 | 1733 | |
| 1734 | 1734 | <?php |
| 1735 | - if(!$sd_is_js_functions_loaded){ |
|
| 1735 | + if(!$sd_is_js_functions_loaded){ |
|
| 1736 | 1736 | $sd_is_js_functions_loaded = true; |
| 1737 | 1737 | ?> |
| 1738 | 1738 | |
@@ -2078,10 +2078,10 @@ discard block |
||
| 2078 | 2078 | |
| 2079 | 2079 | } |
| 2080 | 2080 | |
| 2081 | - if(method_exists($this,'block_global_js')){ |
|
| 2082 | - echo $this->block_global_js(); |
|
| 2083 | - } |
|
| 2084 | - ?> |
|
| 2081 | + if(method_exists($this,'block_global_js')){ |
|
| 2082 | + echo $this->block_global_js(); |
|
| 2083 | + } |
|
| 2084 | + ?> |
|
| 2085 | 2085 | |
| 2086 | 2086 | jQuery(function() { |
| 2087 | 2087 | |
@@ -2131,14 +2131,14 @@ discard block |
||
| 2131 | 2131 | icon: <?php echo $this->get_block_icon( $this->options['block-icon'] );?>,//'<?php echo isset( $this->options['block-icon'] ) ? esc_attr( $this->options['block-icon'] ) : 'shield-alt';?>', // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/. |
| 2132 | 2132 | supports: { |
| 2133 | 2133 | <?php |
| 2134 | - if ( isset( $this->options['block-supports'] ) ) { |
|
| 2135 | - echo $this->array_to_attributes( $this->options['block-supports'] ); |
|
| 2136 | - } |
|
| 2137 | - ?> |
|
| 2134 | + if ( isset( $this->options['block-supports'] ) ) { |
|
| 2135 | + echo $this->array_to_attributes( $this->options['block-supports'] ); |
|
| 2136 | + } |
|
| 2137 | + ?> |
|
| 2138 | 2138 | }, |
| 2139 | 2139 | <?php |
| 2140 | - if ( isset( $this->options['block-label'] ) ) { |
|
| 2141 | - ?> |
|
| 2140 | + if ( isset( $this->options['block-label'] ) ) { |
|
| 2141 | + ?> |
|
| 2142 | 2142 | __experimentalLabel( attributes, { context } ) { |
| 2143 | 2143 | return <?php echo $this->options['block-label']; ?>; |
| 2144 | 2144 | }, |
@@ -2147,7 +2147,7 @@ discard block |
||
| 2147 | 2147 | ?> |
| 2148 | 2148 | category: '<?php echo isset( $this->options['block-category'] ) ? esc_attr( $this->options['block-category'] ) : 'common';?>', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed. |
| 2149 | 2149 | <?php if ( isset( $this->options['block-keywords'] ) ) { |
| 2150 | - echo "keywords : " . $this->options['block-keywords'] . ","; |
|
| 2150 | + echo "keywords : " . $this->options['block-keywords'] . ","; |
|
| 2151 | 2151 | |
| 2152 | 2152 | // // block hover preview. |
| 2153 | 2153 | // $example_args = array(); |
@@ -2172,86 +2172,86 @@ discard block |
||
| 2172 | 2172 | |
| 2173 | 2173 | } |
| 2174 | 2174 | |
| 2175 | - // maybe set no_wrap |
|
| 2176 | - $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false; |
|
| 2177 | - if ( isset( $this->arguments['no_wrap'] ) && $this->arguments['no_wrap'] ) { |
|
| 2178 | - $no_wrap = true; |
|
| 2179 | - } |
|
| 2180 | - if ( $no_wrap ) { |
|
| 2181 | - $this->options['block-wrap'] = ''; |
|
| 2182 | - } |
|
| 2175 | + // maybe set no_wrap |
|
| 2176 | + $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false; |
|
| 2177 | + if ( isset( $this->arguments['no_wrap'] ) && $this->arguments['no_wrap'] ) { |
|
| 2178 | + $no_wrap = true; |
|
| 2179 | + } |
|
| 2180 | + if ( $no_wrap ) { |
|
| 2181 | + $this->options['block-wrap'] = ''; |
|
| 2182 | + } |
|
| 2183 | 2183 | |
| 2184 | - // maybe load the drag/drop functions. |
|
| 2185 | - $img_drag_drop = false; |
|
| 2184 | + // maybe load the drag/drop functions. |
|
| 2185 | + $img_drag_drop = false; |
|
| 2186 | 2186 | |
| 2187 | - $show_alignment = false; |
|
| 2188 | - // align feature |
|
| 2189 | - /*echo "supports: {"; |
|
| 2187 | + $show_alignment = false; |
|
| 2188 | + // align feature |
|
| 2189 | + /*echo "supports: {"; |
|
| 2190 | 2190 | echo " align: true,"; |
| 2191 | 2191 | echo " html: false"; |
| 2192 | 2192 | echo "},";*/ |
| 2193 | 2193 | |
| 2194 | - if ( ! empty( $this->arguments ) ) { |
|
| 2195 | - echo "attributes : {"; |
|
| 2194 | + if ( ! empty( $this->arguments ) ) { |
|
| 2195 | + echo "attributes : {"; |
|
| 2196 | 2196 | |
| 2197 | - if ( $show_advanced ) { |
|
| 2198 | - echo "show_advanced: {"; |
|
| 2199 | - echo " type: 'boolean',"; |
|
| 2200 | - echo " default: false,"; |
|
| 2201 | - echo "},"; |
|
| 2202 | - } |
|
| 2197 | + if ( $show_advanced ) { |
|
| 2198 | + echo "show_advanced: {"; |
|
| 2199 | + echo " type: 'boolean',"; |
|
| 2200 | + echo " default: false,"; |
|
| 2201 | + echo "},"; |
|
| 2202 | + } |
|
| 2203 | 2203 | |
| 2204 | - // block wrap element |
|
| 2205 | - if ( ! empty( $this->options['block-wrap'] ) ) { //@todo we should validate this? |
|
| 2206 | - echo "block_wrap: {"; |
|
| 2207 | - echo " type: 'string',"; |
|
| 2208 | - echo " default: '" . esc_attr( $this->options['block-wrap'] ) . "',"; |
|
| 2209 | - echo "},"; |
|
| 2210 | - } |
|
| 2204 | + // block wrap element |
|
| 2205 | + if ( ! empty( $this->options['block-wrap'] ) ) { //@todo we should validate this? |
|
| 2206 | + echo "block_wrap: {"; |
|
| 2207 | + echo " type: 'string',"; |
|
| 2208 | + echo " default: '" . esc_attr( $this->options['block-wrap'] ) . "',"; |
|
| 2209 | + echo "},"; |
|
| 2210 | + } |
|
| 2211 | 2211 | |
| 2212 | 2212 | |
| 2213 | 2213 | |
| 2214 | - foreach ( $this->arguments as $key => $args ) { |
|
| 2214 | + foreach ( $this->arguments as $key => $args ) { |
|
| 2215 | 2215 | |
| 2216 | - if( $args['type'] == 'image' || $args['type'] == 'images' ){ |
|
| 2217 | - $img_drag_drop = true; |
|
| 2218 | - } |
|
| 2216 | + if( $args['type'] == 'image' || $args['type'] == 'images' ){ |
|
| 2217 | + $img_drag_drop = true; |
|
| 2218 | + } |
|
| 2219 | 2219 | |
| 2220 | - // set if we should show alignment |
|
| 2221 | - if ( $key == 'alignment' ) { |
|
| 2222 | - $show_alignment = true; |
|
| 2223 | - } |
|
| 2220 | + // set if we should show alignment |
|
| 2221 | + if ( $key == 'alignment' ) { |
|
| 2222 | + $show_alignment = true; |
|
| 2223 | + } |
|
| 2224 | 2224 | |
| 2225 | - $extra = ''; |
|
| 2225 | + $extra = ''; |
|
| 2226 | 2226 | |
| 2227 | - if ( $args['type'] == 'notice' || $args['type'] == 'tab' ) { |
|
| 2228 | - continue; |
|
| 2229 | - } |
|
| 2230 | - elseif ( $args['type'] == 'checkbox' ) { |
|
| 2231 | - $type = 'boolean'; |
|
| 2232 | - $default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false'; |
|
| 2233 | - } elseif ( $args['type'] == 'number' ) { |
|
| 2234 | - $type = 'number'; |
|
| 2235 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2236 | - } elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) { |
|
| 2237 | - $type = 'array'; |
|
| 2238 | - if ( isset( $args['default'] ) && is_array( $args['default'] ) ) { |
|
| 2239 | - $default = ! empty( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]"; |
|
| 2240 | - } else { |
|
| 2241 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2242 | - } |
|
| 2243 | - } elseif ( $args['type'] == 'tagselect' ) { |
|
| 2244 | - $type = 'array'; |
|
| 2245 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2246 | - } elseif ( $args['type'] == 'multiselect' ) { |
|
| 2247 | - $type = 'array'; |
|
| 2248 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2249 | - } elseif ( $args['type'] == 'image_xy' ) { |
|
| 2250 | - $type = 'object'; |
|
| 2251 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2252 | - } elseif ( $args['type'] == 'image' ) { |
|
| 2253 | - $type = 'string'; |
|
| 2254 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2227 | + if ( $args['type'] == 'notice' || $args['type'] == 'tab' ) { |
|
| 2228 | + continue; |
|
| 2229 | + } |
|
| 2230 | + elseif ( $args['type'] == 'checkbox' ) { |
|
| 2231 | + $type = 'boolean'; |
|
| 2232 | + $default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false'; |
|
| 2233 | + } elseif ( $args['type'] == 'number' ) { |
|
| 2234 | + $type = 'number'; |
|
| 2235 | + $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2236 | + } elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) { |
|
| 2237 | + $type = 'array'; |
|
| 2238 | + if ( isset( $args['default'] ) && is_array( $args['default'] ) ) { |
|
| 2239 | + $default = ! empty( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]"; |
|
| 2240 | + } else { |
|
| 2241 | + $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2242 | + } |
|
| 2243 | + } elseif ( $args['type'] == 'tagselect' ) { |
|
| 2244 | + $type = 'array'; |
|
| 2245 | + $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2246 | + } elseif ( $args['type'] == 'multiselect' ) { |
|
| 2247 | + $type = 'array'; |
|
| 2248 | + $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2249 | + } elseif ( $args['type'] == 'image_xy' ) { |
|
| 2250 | + $type = 'object'; |
|
| 2251 | + $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2252 | + } elseif ( $args['type'] == 'image' ) { |
|
| 2253 | + $type = 'string'; |
|
| 2254 | + $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2255 | 2255 | |
| 2256 | 2256 | // add a field for ID |
| 2257 | 2257 | // echo $key . "_id : {"; |
@@ -2261,25 +2261,25 @@ discard block |
||
| 2261 | 2261 | // echo "type : 'object',"; |
| 2262 | 2262 | // echo "},"; |
| 2263 | 2263 | |
| 2264 | - } else { |
|
| 2265 | - $type = !empty($args['hidden_type']) ? esc_attr($args['hidden_type']) : 'string'; |
|
| 2266 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2264 | + } else { |
|
| 2265 | + $type = !empty($args['hidden_type']) ? esc_attr($args['hidden_type']) : 'string'; |
|
| 2266 | + $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2267 | 2267 | |
| 2268 | - } |
|
| 2269 | - echo $key . " : {"; |
|
| 2270 | - echo "type : '$type',"; |
|
| 2271 | - echo "default : $default,"; |
|
| 2272 | - echo "},"; |
|
| 2273 | - } |
|
| 2268 | + } |
|
| 2269 | + echo $key . " : {"; |
|
| 2270 | + echo "type : '$type',"; |
|
| 2271 | + echo "default : $default,"; |
|
| 2272 | + echo "},"; |
|
| 2273 | + } |
|
| 2274 | 2274 | |
| 2275 | - echo "content : {type : 'string',default: 'Please select the attributes in the block settings'},"; |
|
| 2276 | - echo "className: { type: 'string', default: '' },"; |
|
| 2275 | + echo "content : {type : 'string',default: 'Please select the attributes in the block settings'},"; |
|
| 2276 | + echo "className: { type: 'string', default: '' },"; |
|
| 2277 | 2277 | |
| 2278 | - echo "},"; |
|
| 2278 | + echo "},"; |
|
| 2279 | 2279 | |
| 2280 | - } |
|
| 2280 | + } |
|
| 2281 | 2281 | |
| 2282 | - ?> |
|
| 2282 | + ?> |
|
| 2283 | 2283 | |
| 2284 | 2284 | // The "edit" property must be a valid function. |
| 2285 | 2285 | edit: function (props) { |
@@ -2379,9 +2379,9 @@ discard block |
||
| 2379 | 2379 | |
| 2380 | 2380 | var $value = ''; |
| 2381 | 2381 | <?php |
| 2382 | - // if we have a post_type and a category then link them |
|
| 2383 | - if( isset($this->arguments['post_type']) && isset($this->arguments['category']) && !empty($this->arguments['category']['post_type_linked']) ){ |
|
| 2384 | - ?> |
|
| 2382 | + // if we have a post_type and a category then link them |
|
| 2383 | + if( isset($this->arguments['post_type']) && isset($this->arguments['category']) && !empty($this->arguments['category']['post_type_linked']) ){ |
|
| 2384 | + ?> |
|
| 2385 | 2385 | if(typeof(prev_attributes[props.clientId]) != 'undefined' ){ |
| 2386 | 2386 | $pt = props.attributes.post_type; |
| 2387 | 2387 | if(post_type_rest_slugs.length){ |
@@ -2472,8 +2472,8 @@ discard block |
||
| 2472 | 2472 | 'attributes': props.attributes, |
| 2473 | 2473 | 'block_parent_name': parentBlocks.length ? parentBlocks[parentBlocks.length - 1].name : '', |
| 2474 | 2474 | 'post_id': <?php global $post; if ( isset( $post->ID ) ) { |
| 2475 | - echo $post->ID; |
|
| 2476 | - }else{echo '0';}?>, |
|
| 2475 | + echo $post->ID; |
|
| 2476 | + }else{echo '0';}?>, |
|
| 2477 | 2477 | '_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>' |
| 2478 | 2478 | }; |
| 2479 | 2479 | |
@@ -2550,10 +2550,10 @@ discard block |
||
| 2550 | 2550 | |
| 2551 | 2551 | <?php |
| 2552 | 2552 | |
| 2553 | - if(! empty( $this->arguments )){ |
|
| 2553 | + if(! empty( $this->arguments )){ |
|
| 2554 | 2554 | |
| 2555 | - if ( $show_advanced ) { |
|
| 2556 | - ?> |
|
| 2555 | + if ( $show_advanced ) { |
|
| 2556 | + ?> |
|
| 2557 | 2557 | el('div', { |
| 2558 | 2558 | style: {'padding-left': '16px','padding-right': '16px'} |
| 2559 | 2559 | }, |
@@ -2571,146 +2571,146 @@ discard block |
||
| 2571 | 2571 | , |
| 2572 | 2572 | <?php |
| 2573 | 2573 | |
| 2574 | - } |
|
| 2574 | + } |
|
| 2575 | 2575 | |
| 2576 | - // print_r( $this->arguments); |
|
| 2576 | + // print_r( $this->arguments); |
|
| 2577 | 2577 | |
| 2578 | - //echo '####'; |
|
| 2578 | + //echo '####'; |
|
| 2579 | 2579 | |
| 2580 | - $arguments = $this->group_arguments( $this->arguments ); |
|
| 2580 | + $arguments = $this->group_arguments( $this->arguments ); |
|
| 2581 | 2581 | //print_r($arguments ); exit; |
| 2582 | - // Do we have sections? |
|
| 2583 | - $has_sections = $arguments == $this->arguments ? false : true; |
|
| 2582 | + // Do we have sections? |
|
| 2583 | + $has_sections = $arguments == $this->arguments ? false : true; |
|
| 2584 | 2584 | |
| 2585 | 2585 | |
| 2586 | - if($has_sections){ |
|
| 2587 | - $panel_count = 0; |
|
| 2588 | - $open_tab = ''; |
|
| 2586 | + if($has_sections){ |
|
| 2587 | + $panel_count = 0; |
|
| 2588 | + $open_tab = ''; |
|
| 2589 | 2589 | |
| 2590 | - $open_tab_groups = array(); |
|
| 2591 | - $used_tabs = array(); |
|
| 2592 | - foreach($arguments as $key => $args){ |
|
| 2590 | + $open_tab_groups = array(); |
|
| 2591 | + $used_tabs = array(); |
|
| 2592 | + foreach($arguments as $key => $args){ |
|
| 2593 | 2593 | |
| 2594 | - $close_tab = false; |
|
| 2595 | - $close_tabs = false; |
|
| 2594 | + $close_tab = false; |
|
| 2595 | + $close_tabs = false; |
|
| 2596 | 2596 | |
| 2597 | - if(!empty($this->options['block_group_tabs'])) { |
|
| 2598 | - foreach($this->options['block_group_tabs'] as $tab_name => $tab_args){ |
|
| 2599 | - if(in_array($key,$tab_args['groups'])){ |
|
| 2597 | + if(!empty($this->options['block_group_tabs'])) { |
|
| 2598 | + foreach($this->options['block_group_tabs'] as $tab_name => $tab_args){ |
|
| 2599 | + if(in_array($key,$tab_args['groups'])){ |
|
| 2600 | 2600 | |
| 2601 | - $open_tab_groups[] = $key; |
|
| 2601 | + $open_tab_groups[] = $key; |
|
| 2602 | 2602 | |
| 2603 | - if($open_tab != $tab_name){ |
|
| 2604 | - $tab_args['tab']['tabs_open'] = $open_tab == '' ? true : false; |
|
| 2605 | - $tab_args['tab']['open'] = true; |
|
| 2603 | + if($open_tab != $tab_name){ |
|
| 2604 | + $tab_args['tab']['tabs_open'] = $open_tab == '' ? true : false; |
|
| 2605 | + $tab_args['tab']['open'] = true; |
|
| 2606 | 2606 | |
| 2607 | - $this->block_tab_start( '', $tab_args ); |
|
| 2607 | + $this->block_tab_start( '', $tab_args ); |
|
| 2608 | 2608 | // echo '###open'.$tab_name;print_r($tab_args); |
| 2609 | - $open_tab = $tab_name; |
|
| 2610 | - $used_tabs[] = $tab_name; |
|
| 2611 | - } |
|
| 2609 | + $open_tab = $tab_name; |
|
| 2610 | + $used_tabs[] = $tab_name; |
|
| 2611 | + } |
|
| 2612 | 2612 | |
| 2613 | - if($open_tab_groups == $tab_args['groups']){ |
|
| 2614 | - //$open_tab = ''; |
|
| 2615 | - $close_tab = true; |
|
| 2616 | - $open_tab_groups = array(); |
|
| 2613 | + if($open_tab_groups == $tab_args['groups']){ |
|
| 2614 | + //$open_tab = ''; |
|
| 2615 | + $close_tab = true; |
|
| 2616 | + $open_tab_groups = array(); |
|
| 2617 | 2617 | |
| 2618 | 2618 | // print_r(array_keys($this->options['block_group_tabs']));echo '####';print_r($used_tabs); |
| 2619 | - if($used_tabs == array_keys($this->options['block_group_tabs'])){ |
|
| 2619 | + if($used_tabs == array_keys($this->options['block_group_tabs'])){ |
|
| 2620 | 2620 | // echo '@@@'; |
| 2621 | - $close_tabs = true; |
|
| 2622 | - } |
|
| 2623 | - } |
|
| 2621 | + $close_tabs = true; |
|
| 2622 | + } |
|
| 2623 | + } |
|
| 2624 | 2624 | |
| 2625 | - } |
|
| 2626 | - } |
|
| 2627 | - } |
|
| 2625 | + } |
|
| 2626 | + } |
|
| 2627 | + } |
|
| 2628 | 2628 | |
| 2629 | 2629 | // |
| 2630 | 2630 | |
| 2631 | - // print_r($arguments);exit; |
|
| 2631 | + // print_r($arguments);exit; |
|
| 2632 | 2632 | |
| 2633 | - ?> |
|
| 2633 | + ?> |
|
| 2634 | 2634 | el(wp.components.PanelBody, { |
| 2635 | 2635 | title: '<?php esc_attr_e( $key ); ?>', |
| 2636 | 2636 | initialOpen: <?php if ( $panel_count ) { |
| 2637 | - echo "false"; |
|
| 2638 | - } else { |
|
| 2639 | - echo "true"; |
|
| 2640 | - }?> |
|
| 2637 | + echo "false"; |
|
| 2638 | + } else { |
|
| 2639 | + echo "true"; |
|
| 2640 | + }?> |
|
| 2641 | 2641 | }, |
| 2642 | 2642 | <?php |
| 2643 | 2643 | |
| 2644 | 2644 | |
| 2645 | 2645 | |
| 2646 | - foreach ( $args as $k => $a ) { |
|
| 2646 | + foreach ( $args as $k => $a ) { |
|
| 2647 | 2647 | |
| 2648 | - $this->block_tab_start( $k, $a ); |
|
| 2649 | - $this->block_row_start( $k, $a ); |
|
| 2650 | - $this->build_block_arguments( $k, $a ); |
|
| 2651 | - $this->block_row_end( $k, $a ); |
|
| 2652 | - $this->block_tab_end( $k, $a ); |
|
| 2653 | - } |
|
| 2654 | - ?> |
|
| 2648 | + $this->block_tab_start( $k, $a ); |
|
| 2649 | + $this->block_row_start( $k, $a ); |
|
| 2650 | + $this->build_block_arguments( $k, $a ); |
|
| 2651 | + $this->block_row_end( $k, $a ); |
|
| 2652 | + $this->block_tab_end( $k, $a ); |
|
| 2653 | + } |
|
| 2654 | + ?> |
|
| 2655 | 2655 | ), |
| 2656 | 2656 | <?php |
| 2657 | - $panel_count ++; |
|
| 2657 | + $panel_count ++; |
|
| 2658 | 2658 | |
| 2659 | 2659 | |
| 2660 | - if($close_tab || $close_tabs){ |
|
| 2661 | - $tab_args = array( |
|
| 2662 | - 'tab' => array( |
|
| 2663 | - 'tabs_close' => $close_tabs, |
|
| 2664 | - 'close' => true, |
|
| 2665 | - ) |
|
| 2660 | + if($close_tab || $close_tabs){ |
|
| 2661 | + $tab_args = array( |
|
| 2662 | + 'tab' => array( |
|
| 2663 | + 'tabs_close' => $close_tabs, |
|
| 2664 | + 'close' => true, |
|
| 2665 | + ) |
|
| 2666 | 2666 | |
| 2667 | - ); |
|
| 2668 | - $this->block_tab_end( '', $tab_args ); |
|
| 2667 | + ); |
|
| 2668 | + $this->block_tab_end( '', $tab_args ); |
|
| 2669 | 2669 | // echo '###close'; print_r($tab_args); |
| 2670 | - $panel_count = 0; |
|
| 2671 | - } |
|
| 2670 | + $panel_count = 0; |
|
| 2671 | + } |
|
| 2672 | 2672 | // |
| 2673 | 2673 | |
| 2674 | - } |
|
| 2675 | - }else { |
|
| 2676 | - ?> |
|
| 2674 | + } |
|
| 2675 | + }else { |
|
| 2676 | + ?> |
|
| 2677 | 2677 | el(wp.components.PanelBody, { |
| 2678 | 2678 | title: '<?php esc_attr_e( "Settings" ); ?>', |
| 2679 | 2679 | initialOpen: true |
| 2680 | 2680 | }, |
| 2681 | 2681 | <?php |
| 2682 | - foreach ( $this->arguments as $key => $args ) { |
|
| 2683 | - $this->block_row_start( $key, $args ); |
|
| 2684 | - $this->build_block_arguments( $key, $args ); |
|
| 2685 | - $this->block_row_end( $key, $args ); |
|
| 2686 | - } |
|
| 2687 | - ?> |
|
| 2682 | + foreach ( $this->arguments as $key => $args ) { |
|
| 2683 | + $this->block_row_start( $key, $args ); |
|
| 2684 | + $this->build_block_arguments( $key, $args ); |
|
| 2685 | + $this->block_row_end( $key, $args ); |
|
| 2686 | + } |
|
| 2687 | + ?> |
|
| 2688 | 2688 | ), |
| 2689 | 2689 | <?php |
| 2690 | - } |
|
| 2690 | + } |
|
| 2691 | 2691 | |
| 2692 | - } |
|
| 2693 | - ?> |
|
| 2692 | + } |
|
| 2693 | + ?> |
|
| 2694 | 2694 | |
| 2695 | 2695 | ), |
| 2696 | 2696 | |
| 2697 | 2697 | <?php |
| 2698 | - // If the user sets block-output array then build it |
|
| 2699 | - if ( ! empty( $this->options['block-output'] ) ) { |
|
| 2700 | - $this->block_element( $this->options['block-output'] ); |
|
| 2701 | - }elseif(!empty($this->options['block-edit-return'])){ |
|
| 2702 | - echo $this->options['block-edit-return']; |
|
| 2703 | - }else{ |
|
| 2704 | - // if no block-output is set then we try and get the shortcode html output via ajax. |
|
| 2705 | - ?> |
|
| 2698 | + // If the user sets block-output array then build it |
|
| 2699 | + if ( ! empty( $this->options['block-output'] ) ) { |
|
| 2700 | + $this->block_element( $this->options['block-output'] ); |
|
| 2701 | + }elseif(!empty($this->options['block-edit-return'])){ |
|
| 2702 | + echo $this->options['block-edit-return']; |
|
| 2703 | + }else{ |
|
| 2704 | + // if no block-output is set then we try and get the shortcode html output via ajax. |
|
| 2705 | + ?> |
|
| 2706 | 2706 | el('div', wp.blockEditor.useBlockProps({ |
| 2707 | 2707 | dangerouslySetInnerHTML: {__html: onChangeContent()}, |
| 2708 | 2708 | className: props.className, |
| 2709 | 2709 | style: {'minHeight': '30px'} |
| 2710 | 2710 | })) |
| 2711 | 2711 | <?php |
| 2712 | - } |
|
| 2713 | - ?> |
|
| 2712 | + } |
|
| 2713 | + ?> |
|
| 2714 | 2714 | ]; // end return |
| 2715 | 2715 | |
| 2716 | 2716 | <?php |
@@ -2729,11 +2729,11 @@ discard block |
||
| 2729 | 2729 | $html = ''; |
| 2730 | 2730 | <?php |
| 2731 | 2731 | |
| 2732 | - if(! empty( $this->arguments )){ |
|
| 2732 | + if(! empty( $this->arguments )){ |
|
| 2733 | 2733 | |
| 2734 | - foreach($this->arguments as $key => $args){ |
|
| 2735 | - // if($args['type']=='tabs'){continue;} |
|
| 2736 | - ?> |
|
| 2734 | + foreach($this->arguments as $key => $args){ |
|
| 2735 | + // if($args['type']=='tabs'){continue;} |
|
| 2736 | + ?> |
|
| 2737 | 2737 | if (attr.hasOwnProperty("<?php echo esc_attr( $key );?>")) { |
| 2738 | 2738 | if ('<?php echo esc_attr( $key );?>' == 'html') { |
| 2739 | 2739 | $html = attr.<?php echo esc_attr( $key );?>; |
@@ -2744,10 +2744,10 @@ discard block |
||
| 2744 | 2744 | } |
| 2745 | 2745 | } |
| 2746 | 2746 | <?php |
| 2747 | - } |
|
| 2748 | - } |
|
| 2747 | + } |
|
| 2748 | + } |
|
| 2749 | 2749 | |
| 2750 | - ?> |
|
| 2750 | + ?> |
|
| 2751 | 2751 | content += "]"; |
| 2752 | 2752 | |
| 2753 | 2753 | <?php |
@@ -2794,7 +2794,7 @@ discard block |
||
| 2794 | 2794 | // $this->block_element( $this->options['block-output'], true ); |
| 2795 | 2795 | // echo ";"; |
| 2796 | 2796 | |
| 2797 | - ?> |
|
| 2797 | + ?> |
|
| 2798 | 2798 | return el( |
| 2799 | 2799 | '', |
| 2800 | 2800 | {}, |
@@ -2804,9 +2804,9 @@ discard block |
||
| 2804 | 2804 | ); |
| 2805 | 2805 | <?php |
| 2806 | 2806 | |
| 2807 | - }elseif(!empty($this->options['block-save-return'])){ |
|
| 2808 | - echo 'return ' . $this->options['block-save-return']; |
|
| 2809 | - }elseif(!empty($this->options['nested-block'])){ |
|
| 2807 | + }elseif(!empty($this->options['block-save-return'])){ |
|
| 2808 | + echo 'return ' . $this->options['block-save-return']; |
|
| 2809 | + }elseif(!empty($this->options['nested-block'])){ |
|
| 2810 | 2810 | ?> |
| 2811 | 2811 | return el( |
| 2812 | 2812 | '', |
@@ -2816,22 +2816,22 @@ discard block |
||
| 2816 | 2816 | el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id'];?>]"}}) |
| 2817 | 2817 | ); |
| 2818 | 2818 | <?php |
| 2819 | - }elseif(!empty( $this->options['block-save-return'] ) ){ |
|
| 2819 | + }elseif(!empty( $this->options['block-save-return'] ) ){ |
|
| 2820 | 2820 | echo "return ". $this->options['block-edit-return'].";"; |
| 2821 | - }elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){ |
|
| 2822 | - ?> |
|
| 2821 | + }elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){ |
|
| 2822 | + ?> |
|
| 2823 | 2823 | return content; |
| 2824 | 2824 | <?php |
| 2825 | - }else{ |
|
| 2826 | - ?> |
|
| 2825 | + }else{ |
|
| 2826 | + ?> |
|
| 2827 | 2827 | var block_wrap = 'div'; |
| 2828 | 2828 | if (attr.hasOwnProperty("block_wrap")) { |
| 2829 | 2829 | block_wrap = attr.block_wrap; |
| 2830 | 2830 | } |
| 2831 | 2831 | return el(block_wrap, wp.blockEditor.useBlockProps.save( {dangerouslySetInnerHTML: {__html: content}, className: align} )); |
| 2832 | 2832 | <?php |
| 2833 | - } |
|
| 2834 | - ?> |
|
| 2833 | + } |
|
| 2834 | + ?> |
|
| 2835 | 2835 | |
| 2836 | 2836 | |
| 2837 | 2837 | } |
@@ -2845,29 +2845,29 @@ discard block |
||
| 2845 | 2845 | }); |
| 2846 | 2846 | </script> |
| 2847 | 2847 | <?php |
| 2848 | - $output = ob_get_clean(); |
|
| 2848 | + $output = ob_get_clean(); |
|
| 2849 | 2849 | |
| 2850 | - /* |
|
| 2850 | + /* |
|
| 2851 | 2851 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 2852 | 2852 | */ |
| 2853 | 2853 | |
| 2854 | - return str_replace( array( |
|
| 2855 | - '<script>', |
|
| 2856 | - '</script>' |
|
| 2857 | - ), '', $output ); |
|
| 2858 | - } |
|
| 2854 | + return str_replace( array( |
|
| 2855 | + '<script>', |
|
| 2856 | + '</script>' |
|
| 2857 | + ), '', $output ); |
|
| 2858 | + } |
|
| 2859 | 2859 | |
| 2860 | 2860 | |
| 2861 | 2861 | |
| 2862 | - public function block_row_start($key, $args){ |
|
| 2862 | + public function block_row_start($key, $args){ |
|
| 2863 | 2863 | |
| 2864 | - // check for row |
|
| 2865 | - if(!empty($args['row'])){ |
|
| 2864 | + // check for row |
|
| 2865 | + if(!empty($args['row'])){ |
|
| 2866 | 2866 | |
| 2867 | - if(!empty($args['row']['open'])){ |
|
| 2867 | + if(!empty($args['row']['open'])){ |
|
| 2868 | 2868 | |
| 2869 | - // element require |
|
| 2870 | - $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : ""; |
|
| 2869 | + // element require |
|
| 2870 | + $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : ""; |
|
| 2871 | 2871 | $device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : ''; |
| 2872 | 2872 | $device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : ''; |
| 2873 | 2873 | $device_type_icon = ''; |
@@ -2878,10 +2878,10 @@ discard block |
||
| 2878 | 2878 | }elseif($device_type=='Mobile'){ |
| 2879 | 2879 | $device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;"></span>'; |
| 2880 | 2880 | } |
| 2881 | - echo $element_require; |
|
| 2881 | + echo $element_require; |
|
| 2882 | 2882 | echo $device_type_require; |
| 2883 | 2883 | |
| 2884 | - if(false){?><script><?php }?> |
|
| 2884 | + if(false){?><script><?php }?> |
|
| 2885 | 2885 | el('div', { |
| 2886 | 2886 | className: 'bsui components-base-control', |
| 2887 | 2887 | }, |
@@ -2919,51 +2919,51 @@ discard block |
||
| 2919 | 2919 | }, |
| 2920 | 2920 | |
| 2921 | 2921 | <?php |
| 2922 | - if(false){?></script><?php } |
|
| 2923 | - }elseif(!empty($args['row']['close'])){ |
|
| 2924 | - if(false){?><script><?php }?> |
|
| 2922 | + if(false){?></script><?php } |
|
| 2923 | + }elseif(!empty($args['row']['close'])){ |
|
| 2924 | + if(false){?><script><?php }?> |
|
| 2925 | 2925 | el( |
| 2926 | 2926 | 'div', |
| 2927 | 2927 | { |
| 2928 | 2928 | className: 'col pl-0', |
| 2929 | 2929 | }, |
| 2930 | 2930 | <?php |
| 2931 | - if(false){?></script><?php } |
|
| 2932 | - }else{ |
|
| 2933 | - if(false){?><script><?php }?> |
|
| 2931 | + if(false){?></script><?php } |
|
| 2932 | + }else{ |
|
| 2933 | + if(false){?><script><?php }?> |
|
| 2934 | 2934 | el( |
| 2935 | 2935 | 'div', |
| 2936 | 2936 | { |
| 2937 | 2937 | className: 'col pl-0 pr-2', |
| 2938 | 2938 | }, |
| 2939 | 2939 | <?php |
| 2940 | - if(false){?></script><?php } |
|
| 2941 | - } |
|
| 2940 | + if(false){?></script><?php } |
|
| 2941 | + } |
|
| 2942 | 2942 | |
| 2943 | - } |
|
| 2943 | + } |
|
| 2944 | 2944 | |
| 2945 | - } |
|
| 2945 | + } |
|
| 2946 | 2946 | |
| 2947 | - public function block_row_end($key, $args){ |
|
| 2947 | + public function block_row_end($key, $args){ |
|
| 2948 | 2948 | |
| 2949 | - if(!empty($args['row'])){ |
|
| 2950 | - // maybe close |
|
| 2951 | - if(!empty($args['row']['close'])){ |
|
| 2952 | - echo "))"; |
|
| 2953 | - } |
|
| 2949 | + if(!empty($args['row'])){ |
|
| 2950 | + // maybe close |
|
| 2951 | + if(!empty($args['row']['close'])){ |
|
| 2952 | + echo "))"; |
|
| 2953 | + } |
|
| 2954 | 2954 | |
| 2955 | - echo "),"; |
|
| 2956 | - } |
|
| 2957 | - } |
|
| 2955 | + echo "),"; |
|
| 2956 | + } |
|
| 2957 | + } |
|
| 2958 | 2958 | |
| 2959 | - public function block_tab_start($key, $args){ |
|
| 2959 | + public function block_tab_start($key, $args){ |
|
| 2960 | 2960 | |
| 2961 | - // check for row |
|
| 2962 | - if(!empty($args['tab'])){ |
|
| 2961 | + // check for row |
|
| 2962 | + if(!empty($args['tab'])){ |
|
| 2963 | 2963 | |
| 2964 | - if(!empty($args['tab']['tabs_open'])){ |
|
| 2964 | + if(!empty($args['tab']['tabs_open'])){ |
|
| 2965 | 2965 | |
| 2966 | - if(false){?><script><?php }?> |
|
| 2966 | + if(false){?><script><?php }?> |
|
| 2967 | 2967 | |
| 2968 | 2968 | el('div',{className: 'bsui'}, |
| 2969 | 2969 | |
@@ -2976,12 +2976,12 @@ discard block |
||
| 2976 | 2976 | tabs: [ |
| 2977 | 2977 | |
| 2978 | 2978 | <?php |
| 2979 | - if(false){?></script><?php } |
|
| 2980 | - } |
|
| 2979 | + if(false){?></script><?php } |
|
| 2980 | + } |
|
| 2981 | 2981 | |
| 2982 | - if(!empty($args['tab']['open'])){ |
|
| 2982 | + if(!empty($args['tab']['open'])){ |
|
| 2983 | 2983 | |
| 2984 | - if(false){?><script><?php }?> |
|
| 2984 | + if(false){?><script><?php }?> |
|
| 2985 | 2985 | { |
| 2986 | 2986 | name: '<?php echo addslashes( esc_attr( $args['tab']['key']) ); ?>', |
| 2987 | 2987 | title: el('div', {dangerouslySetInnerHTML: {__html: '<?php echo addslashes( esc_attr( $args['tab']['title']) ); ?>'}}), |
@@ -2990,23 +2990,23 @@ discard block |
||
| 2990 | 2990 | className: 'components-base-control__help mb-0', |
| 2991 | 2991 | dangerouslySetInnerHTML: {__html:'<?php echo addslashes( $args['tab']['desc'] ); ?>'} |
| 2992 | 2992 | }),<?php } |
| 2993 | - if(false){?></script><?php } |
|
| 2994 | - } |
|
| 2993 | + if(false){?></script><?php } |
|
| 2994 | + } |
|
| 2995 | 2995 | |
| 2996 | - } |
|
| 2996 | + } |
|
| 2997 | 2997 | |
| 2998 | - } |
|
| 2998 | + } |
|
| 2999 | 2999 | |
| 3000 | - public function block_tab_end($key, $args){ |
|
| 3000 | + public function block_tab_end($key, $args){ |
|
| 3001 | 3001 | |
| 3002 | - if(!empty($args['tab'])){ |
|
| 3003 | - // maybe close |
|
| 3004 | - if(!empty($args['tab']['close'])){ |
|
| 3005 | - echo ")}, /* tab close */"; |
|
| 3006 | - } |
|
| 3002 | + if(!empty($args['tab'])){ |
|
| 3003 | + // maybe close |
|
| 3004 | + if(!empty($args['tab']['close'])){ |
|
| 3005 | + echo ")}, /* tab close */"; |
|
| 3006 | + } |
|
| 3007 | 3007 | |
| 3008 | - if(!empty($args['tab']['tabs_close'])){ |
|
| 3009 | - if(false){?><script><?php }?> |
|
| 3008 | + if(!empty($args['tab']['tabs_close'])){ |
|
| 3009 | + if(false){?><script><?php }?> |
|
| 3010 | 3010 | ], |
| 3011 | 3011 | }, |
| 3012 | 3012 | ( tab ) => { |
@@ -3016,21 +3016,21 @@ discard block |
||
| 3016 | 3016 | } |
| 3017 | 3017 | )), /* tabs close */ |
| 3018 | 3018 | <?php if(false){ ?></script><?php } |
| 3019 | - } |
|
| 3020 | - } |
|
| 3021 | - } |
|
| 3019 | + } |
|
| 3020 | + } |
|
| 3021 | + } |
|
| 3022 | 3022 | |
| 3023 | - public function build_block_arguments( $key, $args ) { |
|
| 3024 | - $custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : ''; |
|
| 3025 | - $options = ''; |
|
| 3026 | - $extra = ''; |
|
| 3027 | - $require = ''; |
|
| 3023 | + public function build_block_arguments( $key, $args ) { |
|
| 3024 | + $custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : ''; |
|
| 3025 | + $options = ''; |
|
| 3026 | + $extra = ''; |
|
| 3027 | + $require = ''; |
|
| 3028 | 3028 | $inside_elements = ''; |
| 3029 | 3029 | |
| 3030 | - // `content` is a protected and special argument |
|
| 3031 | - if ( $key == 'content' ) { |
|
| 3032 | - return; |
|
| 3033 | - } |
|
| 3030 | + // `content` is a protected and special argument |
|
| 3031 | + if ( $key == 'content' ) { |
|
| 3032 | + return; |
|
| 3033 | + } |
|
| 3034 | 3034 | |
| 3035 | 3035 | $device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : ''; |
| 3036 | 3036 | $device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : ''; |
@@ -3043,51 +3043,51 @@ discard block |
||
| 3043 | 3043 | $device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>'; |
| 3044 | 3044 | } |
| 3045 | 3045 | |
| 3046 | - // icon |
|
| 3047 | - $icon = ''; |
|
| 3048 | - if( !empty( $args['icon'] ) ){ |
|
| 3049 | - $icon .= "el('div', {"; |
|
| 3050 | - $icon .= "dangerouslySetInnerHTML: {__html: '".self::get_widget_icon( esc_attr($args['icon']))."'},"; |
|
| 3051 | - $icon .= "className: 'text-center',"; |
|
| 3052 | - $icon .= "title: '".addslashes( $args['title'] )."',"; |
|
| 3053 | - $icon .= "}),"; |
|
| 3054 | - |
|
| 3055 | - // blank title as its added to the icon. |
|
| 3056 | - $args['title'] = ''; |
|
| 3057 | - } |
|
| 3046 | + // icon |
|
| 3047 | + $icon = ''; |
|
| 3048 | + if( !empty( $args['icon'] ) ){ |
|
| 3049 | + $icon .= "el('div', {"; |
|
| 3050 | + $icon .= "dangerouslySetInnerHTML: {__html: '".self::get_widget_icon( esc_attr($args['icon']))."'},"; |
|
| 3051 | + $icon .= "className: 'text-center',"; |
|
| 3052 | + $icon .= "title: '".addslashes( $args['title'] )."',"; |
|
| 3053 | + $icon .= "}),"; |
|
| 3054 | + |
|
| 3055 | + // blank title as its added to the icon. |
|
| 3056 | + $args['title'] = ''; |
|
| 3057 | + } |
|
| 3058 | 3058 | |
| 3059 | - // require advanced |
|
| 3060 | - $require_advanced = ! empty( $args['advanced'] ) ? "props.attributes.show_advanced && " : ""; |
|
| 3059 | + // require advanced |
|
| 3060 | + $require_advanced = ! empty( $args['advanced'] ) ? "props.attributes.show_advanced && " : ""; |
|
| 3061 | 3061 | |
| 3062 | - // element require |
|
| 3063 | - $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : ""; |
|
| 3062 | + // element require |
|
| 3063 | + $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : ""; |
|
| 3064 | 3064 | |
| 3065 | 3065 | |
| 3066 | - $onchange = "props.setAttributes({ $key: $key } )"; |
|
| 3067 | - $onchangecomplete = ""; |
|
| 3068 | - $value = "props.attributes.$key"; |
|
| 3069 | - $text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'colorx','range' ); |
|
| 3070 | - if ( in_array( $args['type'], $text_type ) ) { |
|
| 3071 | - $type = 'TextControl'; |
|
| 3072 | - // Save numbers as numbers and not strings |
|
| 3073 | - if ( $args['type'] == 'number' ) { |
|
| 3074 | - $onchange = "props.setAttributes({ $key: $key ? Number($key) : '' } )"; |
|
| 3075 | - } |
|
| 3076 | - }else if ( $args['type'] == 'styleid' ) { |
|
| 3077 | - $type = 'TextControl'; |
|
| 3078 | - $args['type'] == 'text'; |
|
| 3079 | - // Save numbers as numbers and not strings |
|
| 3080 | - $value = "props.attributes.$key ? props.attributes.$key : 'aaabbbccc'"; |
|
| 3081 | - }else if ( $args['type'] == 'notice' ) { |
|
| 3082 | - |
|
| 3083 | - $notice_message = !empty($args['desc']) ? addslashes($args['desc']) : ''; |
|
| 3084 | - $notice_status = !empty($args['status']) ? esc_attr($args['status']) : 'info'; |
|
| 3085 | - |
|
| 3086 | - $notice = "el('div',{className:'bsui'},el(wp.components.Notice, {status: '$notice_status',isDismissible: false,className: 'm-0 pr-0 mb-3'},el('div',{dangerouslySetInnerHTML: {__html: '$notice_message'}}))),"; |
|
| 3087 | - echo $notice_message ? $element_require . $notice : ''; |
|
| 3088 | - return; |
|
| 3089 | - } |
|
| 3090 | - /* |
|
| 3066 | + $onchange = "props.setAttributes({ $key: $key } )"; |
|
| 3067 | + $onchangecomplete = ""; |
|
| 3068 | + $value = "props.attributes.$key"; |
|
| 3069 | + $text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'colorx','range' ); |
|
| 3070 | + if ( in_array( $args['type'], $text_type ) ) { |
|
| 3071 | + $type = 'TextControl'; |
|
| 3072 | + // Save numbers as numbers and not strings |
|
| 3073 | + if ( $args['type'] == 'number' ) { |
|
| 3074 | + $onchange = "props.setAttributes({ $key: $key ? Number($key) : '' } )"; |
|
| 3075 | + } |
|
| 3076 | + }else if ( $args['type'] == 'styleid' ) { |
|
| 3077 | + $type = 'TextControl'; |
|
| 3078 | + $args['type'] == 'text'; |
|
| 3079 | + // Save numbers as numbers and not strings |
|
| 3080 | + $value = "props.attributes.$key ? props.attributes.$key : 'aaabbbccc'"; |
|
| 3081 | + }else if ( $args['type'] == 'notice' ) { |
|
| 3082 | + |
|
| 3083 | + $notice_message = !empty($args['desc']) ? addslashes($args['desc']) : ''; |
|
| 3084 | + $notice_status = !empty($args['status']) ? esc_attr($args['status']) : 'info'; |
|
| 3085 | + |
|
| 3086 | + $notice = "el('div',{className:'bsui'},el(wp.components.Notice, {status: '$notice_status',isDismissible: false,className: 'm-0 pr-0 mb-3'},el('div',{dangerouslySetInnerHTML: {__html: '$notice_message'}}))),"; |
|
| 3087 | + echo $notice_message ? $element_require . $notice : ''; |
|
| 3088 | + return; |
|
| 3089 | + } |
|
| 3090 | + /* |
|
| 3091 | 3091 | * https://www.wptricks.com/question/set-current-tab-on-a-gutenberg-tabpanel-component-from-outside-that-component/ es5 layout |
| 3092 | 3092 | elseif($args['type']=='tabs'){ |
| 3093 | 3093 | ?> |
@@ -3140,23 +3140,23 @@ discard block |
||
| 3140 | 3140 | return; |
| 3141 | 3141 | } |
| 3142 | 3142 | */ |
| 3143 | - elseif ( $args['type'] == 'color' ) { |
|
| 3144 | - $type = 'ColorPicker'; |
|
| 3145 | - $onchange = ""; |
|
| 3146 | - $extra = "color: $value,"; |
|
| 3147 | - if(!empty($args['disable_alpha'])){ |
|
| 3148 | - $extra .= "disableAlpha: true,"; |
|
| 3149 | - } |
|
| 3150 | - $onchangecomplete = "onChangeComplete: function($key) { |
|
| 3143 | + elseif ( $args['type'] == 'color' ) { |
|
| 3144 | + $type = 'ColorPicker'; |
|
| 3145 | + $onchange = ""; |
|
| 3146 | + $extra = "color: $value,"; |
|
| 3147 | + if(!empty($args['disable_alpha'])){ |
|
| 3148 | + $extra .= "disableAlpha: true,"; |
|
| 3149 | + } |
|
| 3150 | + $onchangecomplete = "onChangeComplete: function($key) { |
|
| 3151 | 3151 | value = $key.rgb.a && $key.rgb.a < 1 ? \"rgba(\"+$key.rgb.r+\",\"+$key.rgb.g+\",\"+$key.rgb.b+\",\"+$key.rgb.a+\")\" : $key.hex; |
| 3152 | 3152 | props.setAttributes({ |
| 3153 | 3153 | $key: value |
| 3154 | 3154 | }); |
| 3155 | 3155 | },"; |
| 3156 | - }elseif ( $args['type'] == 'gradient' ) { |
|
| 3157 | - $type = 'GradientPicker'; |
|
| 3156 | + }elseif ( $args['type'] == 'gradient' ) { |
|
| 3157 | + $type = 'GradientPicker'; |
|
| 3158 | 3158 | |
| 3159 | - }elseif ( $args['type'] == 'image' ) { |
|
| 3159 | + }elseif ( $args['type'] == 'image' ) { |
|
| 3160 | 3160 | // print_r($args); |
| 3161 | 3161 | |
| 3162 | 3162 | $img_preview = isset($args['focalpoint']) && !$args['focalpoint'] ? " props.attributes.$key && el('img', { src: props.attributes.$key,style: {maxWidth:'100%',background: '#ccc'}})," : " ( props.attributes.$key || props.attributes.{$key}_use_featured ) && el(wp.components.FocalPointPicker,{ |
@@ -3181,15 +3181,15 @@ discard block |
||
| 3181 | 3181 | |
| 3182 | 3182 | |
| 3183 | 3183 | $value = '""'; |
| 3184 | - $type = 'MediaUpload'; |
|
| 3184 | + $type = 'MediaUpload'; |
|
| 3185 | 3185 | $extra .= "onSelect: function(media){ |
| 3186 | 3186 | return props.setAttributes({ |
| 3187 | 3187 | $key: media.url, |
| 3188 | 3188 | {$key}_id: media.id |
| 3189 | 3189 | }); |
| 3190 | 3190 | },"; |
| 3191 | - $extra .= "type: 'image',"; |
|
| 3192 | - $extra .= "render: function (obj) { |
|
| 3191 | + $extra .= "type: 'image',"; |
|
| 3192 | + $extra .= "render: function (obj) { |
|
| 3193 | 3193 | return el( 'div',{}, |
| 3194 | 3194 | ( !props.attributes.$key && !props.attributes.{$key}_use_featured ) && el( wp.components.Button, { |
| 3195 | 3195 | className: 'components-button components-circular-option-picker__clear is-primary is-smallx', |
@@ -3218,8 +3218,8 @@ discard block |
||
| 3218 | 3218 | $onchange = ""; |
| 3219 | 3219 | |
| 3220 | 3220 | //$inside_elements = ",el('div',{},'file upload')"; |
| 3221 | - }elseif ( $args['type'] == 'images' ) { |
|
| 3222 | - // print_r($args); |
|
| 3221 | + }elseif ( $args['type'] == 'images' ) { |
|
| 3222 | + // print_r($args); |
|
| 3223 | 3223 | |
| 3224 | 3224 | $img_preview = "props.attributes.$key && (function() { |
| 3225 | 3225 | |
@@ -3248,7 +3248,7 @@ discard block |
||
| 3248 | 3248 | |
| 3249 | 3249 | |
| 3250 | 3250 | $value = '""'; |
| 3251 | - $type = 'MediaUpload'; |
|
| 3251 | + $type = 'MediaUpload'; |
|
| 3252 | 3252 | $extra .= "onSelect: function(media){ |
| 3253 | 3253 | |
| 3254 | 3254 | let slim_images = props.attributes.$key ? JSON.parse('['+props.attributes.$key+']') : []; |
@@ -3262,9 +3262,9 @@ discard block |
||
| 3262 | 3262 | $key: JSON.stringify(slim_images).replace('[','').replace(']',''), |
| 3263 | 3263 | }); |
| 3264 | 3264 | },"; |
| 3265 | - $extra .= "type: 'image',"; |
|
| 3266 | - $extra .= "multiple: true,"; |
|
| 3267 | - $extra .= "render: function (obj) { |
|
| 3265 | + $extra .= "type: 'image',"; |
|
| 3266 | + $extra .= "multiple: true,"; |
|
| 3267 | + $extra .= "render: function (obj) { |
|
| 3268 | 3268 | |
| 3269 | 3269 | // init the sort |
| 3270 | 3270 | enableDragSort('sd-sortable'); |
@@ -3303,34 +3303,34 @@ discard block |
||
| 3303 | 3303 | $onchange = ""; |
| 3304 | 3304 | |
| 3305 | 3305 | //$inside_elements = ",el('div',{},'file upload')"; |
| 3306 | - } |
|
| 3307 | - elseif ( $args['type'] == 'checkbox' ) { |
|
| 3308 | - $type = 'CheckboxControl'; |
|
| 3309 | - $extra .= "checked: props.attributes.$key,"; |
|
| 3310 | - $onchange = "props.setAttributes({ $key: ! props.attributes.$key } )"; |
|
| 3311 | - } elseif ( $args['type'] == 'textarea' ) { |
|
| 3312 | - $type = 'TextareaControl'; |
|
| 3313 | - } elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) { |
|
| 3314 | - $type = 'SelectControl'; |
|
| 3315 | - |
|
| 3316 | - if($args['name'] == 'category' && !empty($args['post_type_linked'])){ |
|
| 3317 | - $options .= "options: taxonomies_".str_replace("-","_", $this->id).","; |
|
| 3318 | - }elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){ |
|
| 3319 | - $options .= "options: sort_by_".str_replace("-","_", $this->id).","; |
|
| 3320 | - }else { |
|
| 3321 | - |
|
| 3322 | - if ( ! empty( $args['options'] ) ) { |
|
| 3323 | - $options .= "options: ["; |
|
| 3324 | - foreach ( $args['options'] as $option_val => $option_label ) { |
|
| 3325 | - $options .= "{ value: '" . esc_attr( $option_val ) . "', label: '" . addslashes( $option_label ) . "' },"; |
|
| 3326 | - } |
|
| 3327 | - $options .= "],"; |
|
| 3328 | - } |
|
| 3329 | - } |
|
| 3330 | - if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550 |
|
| 3331 | - $extra .= ' multiple:true,style:{height:"auto",paddingRight:"8px"}, '; |
|
| 3332 | - } |
|
| 3333 | - } elseif ( $args['type'] == 'tagselect' ) { |
|
| 3306 | + } |
|
| 3307 | + elseif ( $args['type'] == 'checkbox' ) { |
|
| 3308 | + $type = 'CheckboxControl'; |
|
| 3309 | + $extra .= "checked: props.attributes.$key,"; |
|
| 3310 | + $onchange = "props.setAttributes({ $key: ! props.attributes.$key } )"; |
|
| 3311 | + } elseif ( $args['type'] == 'textarea' ) { |
|
| 3312 | + $type = 'TextareaControl'; |
|
| 3313 | + } elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) { |
|
| 3314 | + $type = 'SelectControl'; |
|
| 3315 | + |
|
| 3316 | + if($args['name'] == 'category' && !empty($args['post_type_linked'])){ |
|
| 3317 | + $options .= "options: taxonomies_".str_replace("-","_", $this->id).","; |
|
| 3318 | + }elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){ |
|
| 3319 | + $options .= "options: sort_by_".str_replace("-","_", $this->id).","; |
|
| 3320 | + }else { |
|
| 3321 | + |
|
| 3322 | + if ( ! empty( $args['options'] ) ) { |
|
| 3323 | + $options .= "options: ["; |
|
| 3324 | + foreach ( $args['options'] as $option_val => $option_label ) { |
|
| 3325 | + $options .= "{ value: '" . esc_attr( $option_val ) . "', label: '" . addslashes( $option_label ) . "' },"; |
|
| 3326 | + } |
|
| 3327 | + $options .= "],"; |
|
| 3328 | + } |
|
| 3329 | + } |
|
| 3330 | + if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550 |
|
| 3331 | + $extra .= ' multiple:true,style:{height:"auto",paddingRight:"8px"}, '; |
|
| 3332 | + } |
|
| 3333 | + } elseif ( $args['type'] == 'tagselect' ) { |
|
| 3334 | 3334 | // $type = 'FormTokenField'; |
| 3335 | 3335 | // |
| 3336 | 3336 | // if ( ! empty( $args['options'] ) ) { |
@@ -3365,39 +3365,39 @@ discard block |
||
| 3365 | 3365 | // $value = "[]"; |
| 3366 | 3366 | // $extra .= ' __experimentalExpandOnFocus: true,'; |
| 3367 | 3367 | |
| 3368 | - } elseif ( $args['type'] == 'alignment' ) { |
|
| 3369 | - $type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example |
|
| 3370 | - }elseif ( $args['type'] == 'margins' ) { |
|
| 3368 | + } elseif ( $args['type'] == 'alignment' ) { |
|
| 3369 | + $type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example |
|
| 3370 | + }elseif ( $args['type'] == 'margins' ) { |
|
| 3371 | 3371 | |
| 3372 | - } else { |
|
| 3373 | - return;// if we have not implemented the control then don't break the JS. |
|
| 3374 | - } |
|
| 3372 | + } else { |
|
| 3373 | + return;// if we have not implemented the control then don't break the JS. |
|
| 3374 | + } |
|
| 3375 | 3375 | |
| 3376 | 3376 | |
| 3377 | 3377 | |
| 3378 | - // color input does not show the labels so we add them |
|
| 3379 | - if($args['type']=='color'){ |
|
| 3380 | - // add show only if advanced |
|
| 3381 | - echo $require_advanced; |
|
| 3382 | - // add setting require if defined |
|
| 3383 | - echo $element_require; |
|
| 3384 | - echo "el('div', {style: {'marginBottom': '8px'}}, '".addslashes( $args['title'] )."'),"; |
|
| 3385 | - } |
|
| 3378 | + // color input does not show the labels so we add them |
|
| 3379 | + if($args['type']=='color'){ |
|
| 3380 | + // add show only if advanced |
|
| 3381 | + echo $require_advanced; |
|
| 3382 | + // add setting require if defined |
|
| 3383 | + echo $element_require; |
|
| 3384 | + echo "el('div', {style: {'marginBottom': '8px'}}, '".addslashes( $args['title'] )."'),"; |
|
| 3385 | + } |
|
| 3386 | 3386 | |
| 3387 | - // add show only if advanced |
|
| 3388 | - echo $require_advanced; |
|
| 3389 | - // add setting require if defined |
|
| 3390 | - echo $element_require; |
|
| 3387 | + // add show only if advanced |
|
| 3388 | + echo $require_advanced; |
|
| 3389 | + // add setting require if defined |
|
| 3390 | + echo $element_require; |
|
| 3391 | 3391 | echo $device_type_require; |
| 3392 | 3392 | |
| 3393 | - // icon |
|
| 3394 | - echo $icon; |
|
| 3395 | - ?> |
|
| 3393 | + // icon |
|
| 3394 | + echo $icon; |
|
| 3395 | + ?> |
|
| 3396 | 3396 | el( <?php echo $args['type'] == 'image' || $args['type'] == 'images' ? $type : "wp.components.".$type; ?>, { |
| 3397 | 3397 | label: <?php |
| 3398 | - if(empty($args['title'])){ |
|
| 3398 | + if(empty($args['title'])){ |
|
| 3399 | 3399 | echo "''"; |
| 3400 | - }elseif(empty($args['row']) && !empty($args['device_type'])){ |
|
| 3400 | + }elseif(empty($args['row']) && !empty($args['device_type'])){ |
|
| 3401 | 3401 | ?>el('label', { |
| 3402 | 3402 | className: 'components-base-control__label', |
| 3403 | 3403 | style: {width:"100%"} |
@@ -3412,22 +3412,22 @@ discard block |
||
| 3412 | 3412 | |
| 3413 | 3413 | )<?php |
| 3414 | 3414 | |
| 3415 | - }else{ |
|
| 3416 | - ?>'<?php echo addslashes( $args['title'] ); ?>'<?php |
|
| 3415 | + }else{ |
|
| 3416 | + ?>'<?php echo addslashes( $args['title'] ); ?>'<?php |
|
| 3417 | 3417 | |
| 3418 | - } |
|
| 3418 | + } |
|
| 3419 | 3419 | |
| 3420 | - ?>, |
|
| 3420 | + ?>, |
|
| 3421 | 3421 | help: <?php if ( isset( $args['desc'] ) ) { |
| 3422 | - echo "el('span',{dangerouslySetInnerHTML: {__html: '".wp_kses_post( addslashes($args['desc']) )."'}})"; |
|
| 3423 | - }else{ echo "''"; } ?>, |
|
| 3422 | + echo "el('span',{dangerouslySetInnerHTML: {__html: '".wp_kses_post( addslashes($args['desc']) )."'}})"; |
|
| 3423 | + }else{ echo "''"; } ?>, |
|
| 3424 | 3424 | value: <?php echo $value; ?>, |
| 3425 | 3425 | <?php if ( $type == 'TextControl' && $args['type'] != 'text' ) { |
| 3426 | - echo "type: '" . addslashes( $args['type'] ) . "',"; |
|
| 3427 | - } ?> |
|
| 3426 | + echo "type: '" . addslashes( $args['type'] ) . "',"; |
|
| 3427 | + } ?> |
|
| 3428 | 3428 | <?php if ( ! empty( $args['placeholder'] ) ) { |
| 3429 | - echo "placeholder: '" . addslashes( $args['placeholder'] ) . "',"; |
|
| 3430 | - } ?> |
|
| 3429 | + echo "placeholder: '" . addslashes( $args['placeholder'] ) . "',"; |
|
| 3430 | + } ?> |
|
| 3431 | 3431 | <?php echo $options; ?> |
| 3432 | 3432 | <?php echo $extra; ?> |
| 3433 | 3433 | <?php echo $custom_attributes; ?> |
@@ -3442,67 +3442,67 @@ discard block |
||
| 3442 | 3442 | <?php |
| 3443 | 3443 | |
| 3444 | 3444 | |
| 3445 | - } |
|
| 3445 | + } |
|
| 3446 | 3446 | |
| 3447 | - /** |
|
| 3448 | - * Convert an array of attributes to block string. |
|
| 3449 | - * |
|
| 3450 | - * @param $custom_attributes |
|
| 3451 | - * |
|
| 3452 | - * @return string |
|
| 3453 | - *@todo there is prob a faster way to do this, also we could add some validation here. |
|
| 3454 | - * |
|
| 3455 | - */ |
|
| 3456 | - public function array_to_attributes( $custom_attributes, $html = false ) { |
|
| 3457 | - $attributes = ''; |
|
| 3458 | - if ( ! empty( $custom_attributes ) ) { |
|
| 3459 | - |
|
| 3460 | - foreach ( $custom_attributes as $key => $val ) { |
|
| 3461 | - if(is_array($val)){ |
|
| 3462 | - $attributes .= $key.': {'.$this->array_to_attributes( $val, $html ).'},'; |
|
| 3463 | - }else{ |
|
| 3464 | - $attributes .= $html ? " $key='$val' " : "'$key': '$val',"; |
|
| 3465 | - } |
|
| 3466 | - } |
|
| 3447 | + /** |
|
| 3448 | + * Convert an array of attributes to block string. |
|
| 3449 | + * |
|
| 3450 | + * @param $custom_attributes |
|
| 3451 | + * |
|
| 3452 | + * @return string |
|
| 3453 | + *@todo there is prob a faster way to do this, also we could add some validation here. |
|
| 3454 | + * |
|
| 3455 | + */ |
|
| 3456 | + public function array_to_attributes( $custom_attributes, $html = false ) { |
|
| 3457 | + $attributes = ''; |
|
| 3458 | + if ( ! empty( $custom_attributes ) ) { |
|
| 3467 | 3459 | |
| 3468 | - } |
|
| 3460 | + foreach ( $custom_attributes as $key => $val ) { |
|
| 3461 | + if(is_array($val)){ |
|
| 3462 | + $attributes .= $key.': {'.$this->array_to_attributes( $val, $html ).'},'; |
|
| 3463 | + }else{ |
|
| 3464 | + $attributes .= $html ? " $key='$val' " : "'$key': '$val',"; |
|
| 3465 | + } |
|
| 3466 | + } |
|
| 3469 | 3467 | |
| 3470 | - return $attributes; |
|
| 3471 | - } |
|
| 3468 | + } |
|
| 3469 | + |
|
| 3470 | + return $attributes; |
|
| 3471 | + } |
|
| 3472 | 3472 | |
| 3473 | 3473 | |
| 3474 | 3474 | |
| 3475 | - /** |
|
| 3476 | - * A self looping function to create the output for JS block elements. |
|
| 3477 | - * |
|
| 3478 | - * This is what is output in the WP Editor visual view. |
|
| 3479 | - * |
|
| 3480 | - * @param $args |
|
| 3481 | - */ |
|
| 3482 | - public function block_element( $args, $save = false ) { |
|
| 3475 | + /** |
|
| 3476 | + * A self looping function to create the output for JS block elements. |
|
| 3477 | + * |
|
| 3478 | + * This is what is output in the WP Editor visual view. |
|
| 3479 | + * |
|
| 3480 | + * @param $args |
|
| 3481 | + */ |
|
| 3482 | + public function block_element( $args, $save = false ) { |
|
| 3483 | 3483 | |
| 3484 | 3484 | |
| 3485 | - if ( ! empty( $args ) ) { |
|
| 3486 | - foreach ( $args as $element => $new_args ) { |
|
| 3485 | + if ( ! empty( $args ) ) { |
|
| 3486 | + foreach ( $args as $element => $new_args ) { |
|
| 3487 | 3487 | |
| 3488 | - if ( is_array( $new_args ) ) { // its an element |
|
| 3488 | + if ( is_array( $new_args ) ) { // its an element |
|
| 3489 | 3489 | |
| 3490 | 3490 | |
| 3491 | - if ( isset( $new_args['element'] ) ) { |
|
| 3491 | + if ( isset( $new_args['element'] ) ) { |
|
| 3492 | 3492 | |
| 3493 | - if ( isset( $new_args['element_require'] ) ) { |
|
| 3494 | - echo str_replace( array( |
|
| 3495 | - "'+", |
|
| 3496 | - "+'" |
|
| 3497 | - ), '', $this->block_props_replace( $new_args['element_require'] ) ) . " && "; |
|
| 3498 | - unset( $new_args['element_require'] ); |
|
| 3499 | - } |
|
| 3493 | + if ( isset( $new_args['element_require'] ) ) { |
|
| 3494 | + echo str_replace( array( |
|
| 3495 | + "'+", |
|
| 3496 | + "+'" |
|
| 3497 | + ), '', $this->block_props_replace( $new_args['element_require'] ) ) . " && "; |
|
| 3498 | + unset( $new_args['element_require'] ); |
|
| 3499 | + } |
|
| 3500 | 3500 | |
| 3501 | 3501 | if($new_args['element']=='InnerBlocks'){ |
| 3502 | 3502 | echo "\n el( InnerBlocks, {"; |
| 3503 | 3503 | }elseif($new_args['element']=='innerBlocksProps'){ |
| 3504 | 3504 | $element = isset($new_args['inner_element']) ? esc_attr($new_args['inner_element']) : 'div'; |
| 3505 | - // echo "\n el( 'section', wp.blockEditor.useInnerBlocksProps( blockProps, {"; |
|
| 3505 | + // echo "\n el( 'section', wp.blockEditor.useInnerBlocksProps( blockProps, {"; |
|
| 3506 | 3506 | // echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( "; |
| 3507 | 3507 | echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( "; |
| 3508 | 3508 | echo $save ? "wp.blockEditor.useBlockProps.save( {" : "wp.blockEditor.useBlockProps( {"; |
@@ -3512,74 +3512,74 @@ discard block |
||
| 3512 | 3512 | echo !empty($new_args['innerBlocksProps']) && !$save ? $this->block_element( $new_args['innerBlocksProps'],$save ) : ''; |
| 3513 | 3513 | // echo '###'; |
| 3514 | 3514 | |
| 3515 | - // echo '###'; |
|
| 3515 | + // echo '###'; |
|
| 3516 | 3516 | }elseif($new_args['element']=='BlocksProps'){ |
| 3517 | 3517 | |
| 3518 | - if ( isset($new_args['if_inner_element']) ) { |
|
| 3519 | - $element = $new_args['if_inner_element']; |
|
| 3520 | - }else { |
|
| 3521 | - $element = isset($new_args['inner_element']) ? "'".esc_attr($new_args['inner_element'])."'" : "'div'"; |
|
| 3522 | - } |
|
| 3518 | + if ( isset($new_args['if_inner_element']) ) { |
|
| 3519 | + $element = $new_args['if_inner_element']; |
|
| 3520 | + }else { |
|
| 3521 | + $element = isset($new_args['inner_element']) ? "'".esc_attr($new_args['inner_element'])."'" : "'div'"; |
|
| 3522 | + } |
|
| 3523 | 3523 | |
| 3524 | - unset($new_args['inner_element']); |
|
| 3524 | + unset($new_args['inner_element']); |
|
| 3525 | 3525 | echo $save ? "\n el( $element, wp.blockEditor.useBlockProps.save( {" : "\n el( $element, wp.blockEditor.useBlockProps( {"; |
| 3526 | 3526 | echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : ''; |
| 3527 | 3527 | |
| 3528 | 3528 | |
| 3529 | - // echo "} ),"; |
|
| 3529 | + // echo "} ),"; |
|
| 3530 | 3530 | |
| 3531 | 3531 | }else{ |
| 3532 | 3532 | echo "\n el( '" . $new_args['element'] . "', {"; |
| 3533 | 3533 | } |
| 3534 | 3534 | |
| 3535 | 3535 | |
| 3536 | - // get the attributes |
|
| 3537 | - foreach ( $new_args as $new_key => $new_value ) { |
|
| 3536 | + // get the attributes |
|
| 3537 | + foreach ( $new_args as $new_key => $new_value ) { |
|
| 3538 | 3538 | |
| 3539 | 3539 | |
| 3540 | - if ( $new_key == 'element' || $new_key == 'content'|| $new_key == 'if_content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) { |
|
| 3541 | - // do nothing |
|
| 3542 | - } else { |
|
| 3543 | - echo $this->block_element( array( $new_key => $new_value ),$save ); |
|
| 3544 | - } |
|
| 3545 | - } |
|
| 3540 | + if ( $new_key == 'element' || $new_key == 'content'|| $new_key == 'if_content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) { |
|
| 3541 | + // do nothing |
|
| 3542 | + } else { |
|
| 3543 | + echo $this->block_element( array( $new_key => $new_value ),$save ); |
|
| 3544 | + } |
|
| 3545 | + } |
|
| 3546 | 3546 | |
| 3547 | - echo $new_args['element']=='BlocksProps' ? '} ),' : "},";// end attributes |
|
| 3547 | + echo $new_args['element']=='BlocksProps' ? '} ),' : "},";// end attributes |
|
| 3548 | 3548 | |
| 3549 | - // get the content |
|
| 3550 | - $first_item = 0; |
|
| 3551 | - foreach ( $new_args as $new_key => $new_value ) { |
|
| 3552 | - if ( $new_key === 'content' || $new_key === 'if_content' || is_array( $new_value ) ) { |
|
| 3549 | + // get the content |
|
| 3550 | + $first_item = 0; |
|
| 3551 | + foreach ( $new_args as $new_key => $new_value ) { |
|
| 3552 | + if ( $new_key === 'content' || $new_key === 'if_content' || is_array( $new_value ) ) { |
|
| 3553 | 3553 | |
| 3554 | - if ( $new_key === 'content' ) { |
|
| 3555 | - echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'"; |
|
| 3556 | - }else if ( $new_key === 'if_content' ) { |
|
| 3557 | - echo $this->block_props_replace( $new_value ); |
|
| 3558 | - } |
|
| 3554 | + if ( $new_key === 'content' ) { |
|
| 3555 | + echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'"; |
|
| 3556 | + }else if ( $new_key === 'if_content' ) { |
|
| 3557 | + echo $this->block_props_replace( $new_value ); |
|
| 3558 | + } |
|
| 3559 | 3559 | |
| 3560 | - if ( is_array( $new_value ) ) { |
|
| 3560 | + if ( is_array( $new_value ) ) { |
|
| 3561 | 3561 | |
| 3562 | - if ( isset( $new_value['element_require'] ) ) { |
|
| 3563 | - echo str_replace( array( |
|
| 3564 | - "'+", |
|
| 3565 | - "+'" |
|
| 3566 | - ), '', $this->block_props_replace( $new_value['element_require'] ) ) . " && "; |
|
| 3567 | - unset( $new_value['element_require'] ); |
|
| 3568 | - } |
|
| 3562 | + if ( isset( $new_value['element_require'] ) ) { |
|
| 3563 | + echo str_replace( array( |
|
| 3564 | + "'+", |
|
| 3565 | + "+'" |
|
| 3566 | + ), '', $this->block_props_replace( $new_value['element_require'] ) ) . " && "; |
|
| 3567 | + unset( $new_value['element_require'] ); |
|
| 3568 | + } |
|
| 3569 | 3569 | |
| 3570 | - if ( isset( $new_value['element_repeat'] ) ) { |
|
| 3571 | - $x = 1; |
|
| 3572 | - while ( $x <= absint( $new_value['element_repeat'] ) ) { |
|
| 3573 | - $this->block_element( array( '' => $new_value ),$save ); |
|
| 3574 | - $x ++; |
|
| 3575 | - } |
|
| 3576 | - } else { |
|
| 3577 | - $this->block_element( array( '' => $new_value ),$save ); |
|
| 3578 | - } |
|
| 3579 | - } |
|
| 3580 | - $first_item ++; |
|
| 3581 | - } |
|
| 3582 | - } |
|
| 3570 | + if ( isset( $new_value['element_repeat'] ) ) { |
|
| 3571 | + $x = 1; |
|
| 3572 | + while ( $x <= absint( $new_value['element_repeat'] ) ) { |
|
| 3573 | + $this->block_element( array( '' => $new_value ),$save ); |
|
| 3574 | + $x ++; |
|
| 3575 | + } |
|
| 3576 | + } else { |
|
| 3577 | + $this->block_element( array( '' => $new_value ),$save ); |
|
| 3578 | + } |
|
| 3579 | + } |
|
| 3580 | + $first_item ++; |
|
| 3581 | + } |
|
| 3582 | + } |
|
| 3583 | 3583 | |
| 3584 | 3584 | if($new_args['element']=='innerBlocksProps' || $new_args['element']=='xBlocksProps'){ |
| 3585 | 3585 | echo "))";// end content |
@@ -3588,517 +3588,517 @@ discard block |
||
| 3588 | 3588 | } |
| 3589 | 3589 | |
| 3590 | 3590 | |
| 3591 | - echo ", \n"; |
|
| 3591 | + echo ", \n"; |
|
| 3592 | 3592 | |
| 3593 | - } |
|
| 3594 | - } else { |
|
| 3593 | + } |
|
| 3594 | + } else { |
|
| 3595 | 3595 | |
| 3596 | - if ( substr( $element, 0, 3 ) === "if_" ) { |
|
| 3597 | - $extra = ''; |
|
| 3598 | - if( strpos($new_args, '[%WrapClass%]') !== false ){ |
|
| 3599 | - $new_args = str_replace('[%WrapClass%]"','" + sd_build_aui_class(props.attributes)',$new_args); |
|
| 3600 | - $new_args = str_replace('[%WrapClass%]','+ sd_build_aui_class(props.attributes)',$new_args); |
|
| 3601 | - } |
|
| 3602 | - echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ","; |
|
| 3603 | - } elseif ( $element == 'style' && strpos($new_args, '[%WrapStyle%]') !== false ) { |
|
| 3596 | + if ( substr( $element, 0, 3 ) === "if_" ) { |
|
| 3597 | + $extra = ''; |
|
| 3598 | + if( strpos($new_args, '[%WrapClass%]') !== false ){ |
|
| 3599 | + $new_args = str_replace('[%WrapClass%]"','" + sd_build_aui_class(props.attributes)',$new_args); |
|
| 3600 | + $new_args = str_replace('[%WrapClass%]','+ sd_build_aui_class(props.attributes)',$new_args); |
|
| 3601 | + } |
|
| 3602 | + echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ","; |
|
| 3603 | + } elseif ( $element == 'style' && strpos($new_args, '[%WrapStyle%]') !== false ) { |
|
| 3604 | 3604 | $new_args = str_replace('[%WrapStyle%]','',$new_args); |
| 3605 | 3605 | echo $element . ": {..." . $this->block_props_replace( $new_args ) . " , ...sd_build_aui_styles(props.attributes) },"; |
| 3606 | 3606 | // echo $element . ": " . $this->block_props_replace( $new_args ) . ","; |
| 3607 | - } elseif ( $element == 'style' ) { |
|
| 3608 | - echo $element . ": " . $this->block_props_replace( $new_args ) . ","; |
|
| 3609 | - } elseif ( ( $element == 'class' || $element == 'className' ) && strpos($new_args, '[%WrapClass%]') !== false ) { |
|
| 3607 | + } elseif ( $element == 'style' ) { |
|
| 3608 | + echo $element . ": " . $this->block_props_replace( $new_args ) . ","; |
|
| 3609 | + } elseif ( ( $element == 'class' || $element == 'className' ) && strpos($new_args, '[%WrapClass%]') !== false ) { |
|
| 3610 | 3610 | $new_args = str_replace('[%WrapClass%]','',$new_args); |
| 3611 | 3611 | echo $element . ": '" . $this->block_props_replace( $new_args ) . "' + sd_build_aui_class(props.attributes),"; |
| 3612 | - } elseif ( $element == 'template' && $new_args ) { |
|
| 3613 | - echo $element . ": $new_args,"; |
|
| 3614 | - } else { |
|
| 3615 | - echo $element . ": '" . $this->block_props_replace( $new_args ) . "',"; |
|
| 3616 | - } |
|
| 3612 | + } elseif ( $element == 'template' && $new_args ) { |
|
| 3613 | + echo $element . ": $new_args,"; |
|
| 3614 | + } else { |
|
| 3615 | + echo $element . ": '" . $this->block_props_replace( $new_args ) . "',"; |
|
| 3616 | + } |
|
| 3617 | 3617 | |
| 3618 | - } |
|
| 3619 | - } |
|
| 3620 | - } |
|
| 3621 | - } |
|
| 3618 | + } |
|
| 3619 | + } |
|
| 3620 | + } |
|
| 3621 | + } |
|
| 3622 | 3622 | |
| 3623 | - /** |
|
| 3624 | - * Replace block attributes placeholders with the proper naming. |
|
| 3625 | - * |
|
| 3626 | - * @param $string |
|
| 3627 | - * |
|
| 3628 | - * @return mixed |
|
| 3629 | - */ |
|
| 3630 | - public function block_props_replace( $string, $no_wrap = false ) { |
|
| 3631 | - |
|
| 3632 | - if ( $no_wrap ) { |
|
| 3633 | - $string = str_replace( array( "[%", "%]" ), array( "props.attributes.", "" ), $string ); |
|
| 3634 | - } else { |
|
| 3635 | - $string = str_replace( array( "[%", "%]" ), array( "'+props.attributes.", "+'" ), $string ); |
|
| 3636 | - } |
|
| 3623 | + /** |
|
| 3624 | + * Replace block attributes placeholders with the proper naming. |
|
| 3625 | + * |
|
| 3626 | + * @param $string |
|
| 3627 | + * |
|
| 3628 | + * @return mixed |
|
| 3629 | + */ |
|
| 3630 | + public function block_props_replace( $string, $no_wrap = false ) { |
|
| 3637 | 3631 | |
| 3638 | - return $string; |
|
| 3639 | - } |
|
| 3632 | + if ( $no_wrap ) { |
|
| 3633 | + $string = str_replace( array( "[%", "%]" ), array( "props.attributes.", "" ), $string ); |
|
| 3634 | + } else { |
|
| 3635 | + $string = str_replace( array( "[%", "%]" ), array( "'+props.attributes.", "+'" ), $string ); |
|
| 3636 | + } |
|
| 3640 | 3637 | |
| 3641 | - /** |
|
| 3642 | - * Outputs the content of the widget |
|
| 3643 | - * |
|
| 3644 | - * @param array $args |
|
| 3645 | - * @param array $instance |
|
| 3646 | - */ |
|
| 3647 | - public function widget( $args, $instance ) { |
|
| 3648 | - |
|
| 3649 | - // get the filtered values |
|
| 3650 | - $argument_values = $this->argument_values( $instance ); |
|
| 3651 | - $argument_values = $this->string_to_bool( $argument_values ); |
|
| 3652 | - $output = $this->output( $argument_values, $args ); |
|
| 3653 | - |
|
| 3654 | - $no_wrap = false; |
|
| 3655 | - if ( isset( $argument_values['no_wrap'] ) && $argument_values['no_wrap'] ) { |
|
| 3656 | - $no_wrap = true; |
|
| 3657 | - } |
|
| 3638 | + return $string; |
|
| 3639 | + } |
|
| 3658 | 3640 | |
| 3659 | - ob_start(); |
|
| 3660 | - if ( $output && ! $no_wrap ) { |
|
| 3641 | + /** |
|
| 3642 | + * Outputs the content of the widget |
|
| 3643 | + * |
|
| 3644 | + * @param array $args |
|
| 3645 | + * @param array $instance |
|
| 3646 | + */ |
|
| 3647 | + public function widget( $args, $instance ) { |
|
| 3661 | 3648 | |
| 3662 | - $class_original = $this->options['widget_ops']['classname']; |
|
| 3663 | - $class = $this->options['widget_ops']['classname']." sdel-".$this->get_instance_hash(); |
|
| 3649 | + // get the filtered values |
|
| 3650 | + $argument_values = $this->argument_values( $instance ); |
|
| 3651 | + $argument_values = $this->string_to_bool( $argument_values ); |
|
| 3652 | + $output = $this->output( $argument_values, $args ); |
|
| 3664 | 3653 | |
| 3665 | - // Before widget |
|
| 3666 | - $before_widget = $args['before_widget']; |
|
| 3667 | - $before_widget = str_replace($class_original,$class,$before_widget); |
|
| 3668 | - $before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this ); |
|
| 3669 | - $before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this ); |
|
| 3654 | + $no_wrap = false; |
|
| 3655 | + if ( isset( $argument_values['no_wrap'] ) && $argument_values['no_wrap'] ) { |
|
| 3656 | + $no_wrap = true; |
|
| 3657 | + } |
|
| 3670 | 3658 | |
| 3671 | - // After widget |
|
| 3672 | - $after_widget = $args['after_widget']; |
|
| 3673 | - $after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this ); |
|
| 3674 | - $after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this ); |
|
| 3659 | + ob_start(); |
|
| 3660 | + if ( $output && ! $no_wrap ) { |
|
| 3675 | 3661 | |
| 3676 | - echo $before_widget; |
|
| 3677 | - // elementor strips the widget wrapping div so we check for and add it back if needed |
|
| 3678 | - if ( $this->is_elementor_widget_output() ) { |
|
| 3679 | - // Filter class & attrs for elementor widget output. |
|
| 3680 | - $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this ); |
|
| 3681 | - $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this ); |
|
| 3662 | + $class_original = $this->options['widget_ops']['classname']; |
|
| 3663 | + $class = $this->options['widget_ops']['classname']." sdel-".$this->get_instance_hash(); |
|
| 3682 | 3664 | |
| 3683 | - $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this ); |
|
| 3684 | - $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this ); |
|
| 3665 | + // Before widget |
|
| 3666 | + $before_widget = $args['before_widget']; |
|
| 3667 | + $before_widget = str_replace($class_original,$class,$before_widget); |
|
| 3668 | + $before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this ); |
|
| 3669 | + $before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this ); |
|
| 3685 | 3670 | |
| 3686 | - echo "<span class='" . esc_attr( $class ) . "' " . $attrs . ">"; |
|
| 3687 | - } |
|
| 3688 | - echo $this->output_title( $args, $instance ); |
|
| 3689 | - echo $output; |
|
| 3690 | - if ( $this->is_elementor_widget_output() ) { |
|
| 3691 | - echo "</span>"; |
|
| 3692 | - } |
|
| 3693 | - echo $after_widget; |
|
| 3694 | - } elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty |
|
| 3695 | - $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" ); |
|
| 3696 | - echo $output; |
|
| 3697 | - } elseif ( $output && $no_wrap ) { |
|
| 3698 | - echo $output; |
|
| 3699 | - } |
|
| 3700 | - $output = ob_get_clean(); |
|
| 3671 | + // After widget |
|
| 3672 | + $after_widget = $args['after_widget']; |
|
| 3673 | + $after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this ); |
|
| 3674 | + $after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this ); |
|
| 3701 | 3675 | |
| 3702 | - $output = apply_filters( 'wp_super_duper_widget_output', $output, $instance, $args, $this ); |
|
| 3676 | + echo $before_widget; |
|
| 3677 | + // elementor strips the widget wrapping div so we check for and add it back if needed |
|
| 3678 | + if ( $this->is_elementor_widget_output() ) { |
|
| 3679 | + // Filter class & attrs for elementor widget output. |
|
| 3680 | + $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this ); |
|
| 3681 | + $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this ); |
|
| 3703 | 3682 | |
| 3704 | - echo $output; |
|
| 3705 | - } |
|
| 3683 | + $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this ); |
|
| 3684 | + $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this ); |
|
| 3706 | 3685 | |
| 3707 | - /** |
|
| 3708 | - * Tests if the current output is inside a elementor container. |
|
| 3709 | - * |
|
| 3710 | - * @return bool |
|
| 3711 | - *@since 1.0.4 |
|
| 3712 | - */ |
|
| 3713 | - public function is_elementor_widget_output() { |
|
| 3714 | - $result = false; |
|
| 3715 | - if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) { |
|
| 3716 | - $result = true; |
|
| 3717 | - } |
|
| 3686 | + echo "<span class='" . esc_attr( $class ) . "' " . $attrs . ">"; |
|
| 3687 | + } |
|
| 3688 | + echo $this->output_title( $args, $instance ); |
|
| 3689 | + echo $output; |
|
| 3690 | + if ( $this->is_elementor_widget_output() ) { |
|
| 3691 | + echo "</span>"; |
|
| 3692 | + } |
|
| 3693 | + echo $after_widget; |
|
| 3694 | + } elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty |
|
| 3695 | + $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" ); |
|
| 3696 | + echo $output; |
|
| 3697 | + } elseif ( $output && $no_wrap ) { |
|
| 3698 | + echo $output; |
|
| 3699 | + } |
|
| 3700 | + $output = ob_get_clean(); |
|
| 3718 | 3701 | |
| 3719 | - return $result; |
|
| 3720 | - } |
|
| 3702 | + $output = apply_filters( 'wp_super_duper_widget_output', $output, $instance, $args, $this ); |
|
| 3721 | 3703 | |
| 3722 | - /** |
|
| 3723 | - * Tests if the current output is inside a elementor preview. |
|
| 3724 | - * |
|
| 3725 | - * @return bool |
|
| 3726 | - *@since 1.0.4 |
|
| 3727 | - */ |
|
| 3728 | - public function is_elementor_preview() { |
|
| 3729 | - $result = false; |
|
| 3730 | - if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) { |
|
| 3731 | - $result = true; |
|
| 3732 | - } |
|
| 3704 | + echo $output; |
|
| 3705 | + } |
|
| 3733 | 3706 | |
| 3734 | - return $result; |
|
| 3735 | - } |
|
| 3707 | + /** |
|
| 3708 | + * Tests if the current output is inside a elementor container. |
|
| 3709 | + * |
|
| 3710 | + * @return bool |
|
| 3711 | + *@since 1.0.4 |
|
| 3712 | + */ |
|
| 3713 | + public function is_elementor_widget_output() { |
|
| 3714 | + $result = false; |
|
| 3715 | + if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) { |
|
| 3716 | + $result = true; |
|
| 3717 | + } |
|
| 3736 | 3718 | |
| 3737 | - /** |
|
| 3738 | - * Tests if the current output is inside a Divi preview. |
|
| 3739 | - * |
|
| 3740 | - * @return bool |
|
| 3741 | - *@since 1.0.6 |
|
| 3742 | - */ |
|
| 3743 | - public function is_divi_preview() { |
|
| 3744 | - $result = false; |
|
| 3745 | - if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) { |
|
| 3746 | - $result = true; |
|
| 3747 | - } |
|
| 3719 | + return $result; |
|
| 3720 | + } |
|
| 3748 | 3721 | |
| 3749 | - return $result; |
|
| 3750 | - } |
|
| 3722 | + /** |
|
| 3723 | + * Tests if the current output is inside a elementor preview. |
|
| 3724 | + * |
|
| 3725 | + * @return bool |
|
| 3726 | + *@since 1.0.4 |
|
| 3727 | + */ |
|
| 3728 | + public function is_elementor_preview() { |
|
| 3729 | + $result = false; |
|
| 3730 | + if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) { |
|
| 3731 | + $result = true; |
|
| 3732 | + } |
|
| 3751 | 3733 | |
| 3752 | - /** |
|
| 3753 | - * Tests if the current output is inside a Beaver builder preview. |
|
| 3754 | - * |
|
| 3755 | - * @return bool |
|
| 3756 | - *@since 1.0.6 |
|
| 3757 | - */ |
|
| 3758 | - public function is_beaver_preview() { |
|
| 3759 | - $result = false; |
|
| 3760 | - if ( isset( $_REQUEST['fl_builder'] ) ) { |
|
| 3761 | - $result = true; |
|
| 3762 | - } |
|
| 3734 | + return $result; |
|
| 3735 | + } |
|
| 3763 | 3736 | |
| 3764 | - return $result; |
|
| 3765 | - } |
|
| 3737 | + /** |
|
| 3738 | + * Tests if the current output is inside a Divi preview. |
|
| 3739 | + * |
|
| 3740 | + * @return bool |
|
| 3741 | + *@since 1.0.6 |
|
| 3742 | + */ |
|
| 3743 | + public function is_divi_preview() { |
|
| 3744 | + $result = false; |
|
| 3745 | + if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) { |
|
| 3746 | + $result = true; |
|
| 3747 | + } |
|
| 3766 | 3748 | |
| 3767 | - /** |
|
| 3768 | - * Tests if the current output is inside a siteorigin builder preview. |
|
| 3769 | - * |
|
| 3770 | - * @return bool |
|
| 3771 | - *@since 1.0.6 |
|
| 3772 | - */ |
|
| 3773 | - public function is_siteorigin_preview() { |
|
| 3774 | - $result = false; |
|
| 3775 | - if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) { |
|
| 3776 | - $result = true; |
|
| 3777 | - } |
|
| 3749 | + return $result; |
|
| 3750 | + } |
|
| 3778 | 3751 | |
| 3779 | - return $result; |
|
| 3780 | - } |
|
| 3752 | + /** |
|
| 3753 | + * Tests if the current output is inside a Beaver builder preview. |
|
| 3754 | + * |
|
| 3755 | + * @return bool |
|
| 3756 | + *@since 1.0.6 |
|
| 3757 | + */ |
|
| 3758 | + public function is_beaver_preview() { |
|
| 3759 | + $result = false; |
|
| 3760 | + if ( isset( $_REQUEST['fl_builder'] ) ) { |
|
| 3761 | + $result = true; |
|
| 3762 | + } |
|
| 3781 | 3763 | |
| 3782 | - /** |
|
| 3783 | - * Tests if the current output is inside a cornerstone builder preview. |
|
| 3784 | - * |
|
| 3785 | - * @return bool |
|
| 3786 | - *@since 1.0.8 |
|
| 3787 | - */ |
|
| 3788 | - public function is_cornerstone_preview() { |
|
| 3789 | - $result = false; |
|
| 3790 | - if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) { |
|
| 3791 | - $result = true; |
|
| 3792 | - } |
|
| 3764 | + return $result; |
|
| 3765 | + } |
|
| 3793 | 3766 | |
| 3794 | - return $result; |
|
| 3795 | - } |
|
| 3767 | + /** |
|
| 3768 | + * Tests if the current output is inside a siteorigin builder preview. |
|
| 3769 | + * |
|
| 3770 | + * @return bool |
|
| 3771 | + *@since 1.0.6 |
|
| 3772 | + */ |
|
| 3773 | + public function is_siteorigin_preview() { |
|
| 3774 | + $result = false; |
|
| 3775 | + if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) { |
|
| 3776 | + $result = true; |
|
| 3777 | + } |
|
| 3796 | 3778 | |
| 3797 | - /** |
|
| 3798 | - * Tests if the current output is inside a fusion builder preview. |
|
| 3799 | - * |
|
| 3800 | - * @return bool |
|
| 3801 | - *@since 1.1.0 |
|
| 3802 | - */ |
|
| 3803 | - public function is_fusion_preview() { |
|
| 3804 | - $result = false; |
|
| 3805 | - if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) { |
|
| 3806 | - $result = true; |
|
| 3807 | - } |
|
| 3779 | + return $result; |
|
| 3780 | + } |
|
| 3808 | 3781 | |
| 3809 | - return $result; |
|
| 3810 | - } |
|
| 3782 | + /** |
|
| 3783 | + * Tests if the current output is inside a cornerstone builder preview. |
|
| 3784 | + * |
|
| 3785 | + * @return bool |
|
| 3786 | + *@since 1.0.8 |
|
| 3787 | + */ |
|
| 3788 | + public function is_cornerstone_preview() { |
|
| 3789 | + $result = false; |
|
| 3790 | + if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) { |
|
| 3791 | + $result = true; |
|
| 3792 | + } |
|
| 3811 | 3793 | |
| 3812 | - /** |
|
| 3813 | - * Tests if the current output is inside a Oxygen builder preview. |
|
| 3814 | - * |
|
| 3815 | - * @return bool |
|
| 3816 | - *@since 1.0.18 |
|
| 3817 | - */ |
|
| 3818 | - public function is_oxygen_preview() { |
|
| 3819 | - $result = false; |
|
| 3820 | - if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) { |
|
| 3821 | - $result = true; |
|
| 3822 | - } |
|
| 3794 | + return $result; |
|
| 3795 | + } |
|
| 3823 | 3796 | |
| 3824 | - return $result; |
|
| 3825 | - } |
|
| 3797 | + /** |
|
| 3798 | + * Tests if the current output is inside a fusion builder preview. |
|
| 3799 | + * |
|
| 3800 | + * @return bool |
|
| 3801 | + *@since 1.1.0 |
|
| 3802 | + */ |
|
| 3803 | + public function is_fusion_preview() { |
|
| 3804 | + $result = false; |
|
| 3805 | + if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) { |
|
| 3806 | + $result = true; |
|
| 3807 | + } |
|
| 3826 | 3808 | |
| 3827 | - /** |
|
| 3828 | - * General function to check if we are in a preview situation. |
|
| 3829 | - * |
|
| 3830 | - * @return bool |
|
| 3831 | - *@since 1.0.6 |
|
| 3832 | - */ |
|
| 3833 | - public function is_preview() { |
|
| 3834 | - $preview = false; |
|
| 3835 | - if ( $this->is_divi_preview() ) { |
|
| 3836 | - $preview = true; |
|
| 3837 | - } elseif ( $this->is_elementor_preview() ) { |
|
| 3838 | - $preview = true; |
|
| 3839 | - } elseif ( $this->is_beaver_preview() ) { |
|
| 3840 | - $preview = true; |
|
| 3841 | - } elseif ( $this->is_siteorigin_preview() ) { |
|
| 3842 | - $preview = true; |
|
| 3843 | - } elseif ( $this->is_cornerstone_preview() ) { |
|
| 3844 | - $preview = true; |
|
| 3845 | - } elseif ( $this->is_fusion_preview() ) { |
|
| 3846 | - $preview = true; |
|
| 3847 | - } elseif ( $this->is_oxygen_preview() ) { |
|
| 3848 | - $preview = true; |
|
| 3849 | - } elseif( $this->is_block_content_call() ) { |
|
| 3850 | - $preview = true; |
|
| 3851 | - } |
|
| 3809 | + return $result; |
|
| 3810 | + } |
|
| 3852 | 3811 | |
| 3853 | - return $preview; |
|
| 3854 | - } |
|
| 3812 | + /** |
|
| 3813 | + * Tests if the current output is inside a Oxygen builder preview. |
|
| 3814 | + * |
|
| 3815 | + * @return bool |
|
| 3816 | + *@since 1.0.18 |
|
| 3817 | + */ |
|
| 3818 | + public function is_oxygen_preview() { |
|
| 3819 | + $result = false; |
|
| 3820 | + if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) { |
|
| 3821 | + $result = true; |
|
| 3822 | + } |
|
| 3855 | 3823 | |
| 3856 | - /** |
|
| 3857 | - * Output the super title. |
|
| 3858 | - * |
|
| 3859 | - * @param $args |
|
| 3860 | - * @param array $instance |
|
| 3861 | - * |
|
| 3862 | - * @return string |
|
| 3863 | - */ |
|
| 3864 | - public function output_title( $args, $instance = array() ) { |
|
| 3865 | - $output = ''; |
|
| 3866 | - if ( ! empty( $instance['title'] ) ) { |
|
| 3867 | - /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ |
|
| 3868 | - $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); |
|
| 3869 | - |
|
| 3870 | - if(empty($instance['widget_title_tag'])){ |
|
| 3871 | - $output = $args['before_title'] . $title . $args['after_title']; |
|
| 3872 | - }else{ |
|
| 3873 | - $title_tag = esc_attr( $instance['widget_title_tag'] ); |
|
| 3874 | - |
|
| 3875 | - // classes |
|
| 3876 | - $title_classes = array(); |
|
| 3877 | - $title_classes[] = !empty( $instance['widget_title_size_class'] ) ? sanitize_html_class( $instance['widget_title_size_class'] ) : ''; |
|
| 3878 | - $title_classes[] = !empty( $instance['widget_title_align_class'] ) ? sanitize_html_class( $instance['widget_title_align_class'] ) : ''; |
|
| 3879 | - $title_classes[] = !empty( $instance['widget_title_color_class'] ) ? "text-".sanitize_html_class( $instance['widget_title_color_class'] ) : ''; |
|
| 3880 | - $title_classes[] = !empty( $instance['widget_title_border_class'] ) ? sanitize_html_class( $instance['widget_title_border_class'] ) : ''; |
|
| 3881 | - $title_classes[] = !empty( $instance['widget_title_border_color_class'] ) ? "border-".sanitize_html_class( $instance['widget_title_border_color_class'] ) : ''; |
|
| 3882 | - $title_classes[] = !empty( $instance['widget_title_mt_class'] ) ? "mt-".absint( $instance['widget_title_mt_class'] ) : ''; |
|
| 3883 | - $title_classes[] = !empty( $instance['widget_title_mr_class'] ) ? "mr-".absint( $instance['widget_title_mr_class'] ) : ''; |
|
| 3884 | - $title_classes[] = !empty( $instance['widget_title_mb_class'] ) ? "mb-".absint( $instance['widget_title_mb_class'] ) : ''; |
|
| 3885 | - $title_classes[] = !empty( $instance['widget_title_ml_class'] ) ? "ml-".absint( $instance['widget_title_ml_class'] ) : ''; |
|
| 3886 | - $title_classes[] = !empty( $instance['widget_title_pt_class'] ) ? "pt-".absint( $instance['widget_title_pt_class'] ) : ''; |
|
| 3887 | - $title_classes[] = !empty( $instance['widget_title_pr_class'] ) ? "pr-".absint( $instance['widget_title_pr_class'] ) : ''; |
|
| 3888 | - $title_classes[] = !empty( $instance['widget_title_pb_class'] ) ? "pb-".absint( $instance['widget_title_pb_class'] ) : ''; |
|
| 3889 | - $title_classes[] = !empty( $instance['widget_title_pl_class'] ) ? "pl-".absint( $instance['widget_title_pl_class'] ) : ''; |
|
| 3890 | - |
|
| 3891 | - $class = !empty( $title_classes ) ? implode(" ",$title_classes) : ''; |
|
| 3892 | - $output = "<$title_tag class='$class' >$title</$title_tag>"; |
|
| 3893 | - } |
|
| 3824 | + return $result; |
|
| 3825 | + } |
|
| 3894 | 3826 | |
| 3895 | - } |
|
| 3827 | + /** |
|
| 3828 | + * General function to check if we are in a preview situation. |
|
| 3829 | + * |
|
| 3830 | + * @return bool |
|
| 3831 | + *@since 1.0.6 |
|
| 3832 | + */ |
|
| 3833 | + public function is_preview() { |
|
| 3834 | + $preview = false; |
|
| 3835 | + if ( $this->is_divi_preview() ) { |
|
| 3836 | + $preview = true; |
|
| 3837 | + } elseif ( $this->is_elementor_preview() ) { |
|
| 3838 | + $preview = true; |
|
| 3839 | + } elseif ( $this->is_beaver_preview() ) { |
|
| 3840 | + $preview = true; |
|
| 3841 | + } elseif ( $this->is_siteorigin_preview() ) { |
|
| 3842 | + $preview = true; |
|
| 3843 | + } elseif ( $this->is_cornerstone_preview() ) { |
|
| 3844 | + $preview = true; |
|
| 3845 | + } elseif ( $this->is_fusion_preview() ) { |
|
| 3846 | + $preview = true; |
|
| 3847 | + } elseif ( $this->is_oxygen_preview() ) { |
|
| 3848 | + $preview = true; |
|
| 3849 | + } elseif( $this->is_block_content_call() ) { |
|
| 3850 | + $preview = true; |
|
| 3851 | + } |
|
| 3896 | 3852 | |
| 3897 | - return $output; |
|
| 3898 | - } |
|
| 3853 | + return $preview; |
|
| 3854 | + } |
|
| 3855 | + |
|
| 3856 | + /** |
|
| 3857 | + * Output the super title. |
|
| 3858 | + * |
|
| 3859 | + * @param $args |
|
| 3860 | + * @param array $instance |
|
| 3861 | + * |
|
| 3862 | + * @return string |
|
| 3863 | + */ |
|
| 3864 | + public function output_title( $args, $instance = array() ) { |
|
| 3865 | + $output = ''; |
|
| 3866 | + if ( ! empty( $instance['title'] ) ) { |
|
| 3867 | + /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ |
|
| 3868 | + $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); |
|
| 3869 | + |
|
| 3870 | + if(empty($instance['widget_title_tag'])){ |
|
| 3871 | + $output = $args['before_title'] . $title . $args['after_title']; |
|
| 3872 | + }else{ |
|
| 3873 | + $title_tag = esc_attr( $instance['widget_title_tag'] ); |
|
| 3874 | + |
|
| 3875 | + // classes |
|
| 3876 | + $title_classes = array(); |
|
| 3877 | + $title_classes[] = !empty( $instance['widget_title_size_class'] ) ? sanitize_html_class( $instance['widget_title_size_class'] ) : ''; |
|
| 3878 | + $title_classes[] = !empty( $instance['widget_title_align_class'] ) ? sanitize_html_class( $instance['widget_title_align_class'] ) : ''; |
|
| 3879 | + $title_classes[] = !empty( $instance['widget_title_color_class'] ) ? "text-".sanitize_html_class( $instance['widget_title_color_class'] ) : ''; |
|
| 3880 | + $title_classes[] = !empty( $instance['widget_title_border_class'] ) ? sanitize_html_class( $instance['widget_title_border_class'] ) : ''; |
|
| 3881 | + $title_classes[] = !empty( $instance['widget_title_border_color_class'] ) ? "border-".sanitize_html_class( $instance['widget_title_border_color_class'] ) : ''; |
|
| 3882 | + $title_classes[] = !empty( $instance['widget_title_mt_class'] ) ? "mt-".absint( $instance['widget_title_mt_class'] ) : ''; |
|
| 3883 | + $title_classes[] = !empty( $instance['widget_title_mr_class'] ) ? "mr-".absint( $instance['widget_title_mr_class'] ) : ''; |
|
| 3884 | + $title_classes[] = !empty( $instance['widget_title_mb_class'] ) ? "mb-".absint( $instance['widget_title_mb_class'] ) : ''; |
|
| 3885 | + $title_classes[] = !empty( $instance['widget_title_ml_class'] ) ? "ml-".absint( $instance['widget_title_ml_class'] ) : ''; |
|
| 3886 | + $title_classes[] = !empty( $instance['widget_title_pt_class'] ) ? "pt-".absint( $instance['widget_title_pt_class'] ) : ''; |
|
| 3887 | + $title_classes[] = !empty( $instance['widget_title_pr_class'] ) ? "pr-".absint( $instance['widget_title_pr_class'] ) : ''; |
|
| 3888 | + $title_classes[] = !empty( $instance['widget_title_pb_class'] ) ? "pb-".absint( $instance['widget_title_pb_class'] ) : ''; |
|
| 3889 | + $title_classes[] = !empty( $instance['widget_title_pl_class'] ) ? "pl-".absint( $instance['widget_title_pl_class'] ) : ''; |
|
| 3890 | + |
|
| 3891 | + $class = !empty( $title_classes ) ? implode(" ",$title_classes) : ''; |
|
| 3892 | + $output = "<$title_tag class='$class' >$title</$title_tag>"; |
|
| 3893 | + } |
|
| 3894 | + |
|
| 3895 | + } |
|
| 3896 | + |
|
| 3897 | + return $output; |
|
| 3898 | + } |
|
| 3899 | 3899 | |
| 3900 | - /** |
|
| 3901 | - * Outputs the options form inputs for the widget. |
|
| 3902 | - * |
|
| 3903 | - * @param array $instance The widget options. |
|
| 3904 | - */ |
|
| 3905 | - public function form( $instance ) { |
|
| 3900 | + /** |
|
| 3901 | + * Outputs the options form inputs for the widget. |
|
| 3902 | + * |
|
| 3903 | + * @param array $instance The widget options. |
|
| 3904 | + */ |
|
| 3905 | + public function form( $instance ) { |
|
| 3906 | 3906 | |
| 3907 | - // set widget instance |
|
| 3908 | - $this->instance = $instance; |
|
| 3907 | + // set widget instance |
|
| 3908 | + $this->instance = $instance; |
|
| 3909 | 3909 | |
| 3910 | - // set it as a SD widget |
|
| 3911 | - echo $this->widget_advanced_toggle(); |
|
| 3910 | + // set it as a SD widget |
|
| 3911 | + echo $this->widget_advanced_toggle(); |
|
| 3912 | 3912 | |
| 3913 | - echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>"; |
|
| 3914 | - $arguments_raw = $this->get_arguments(); |
|
| 3913 | + echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>"; |
|
| 3914 | + $arguments_raw = $this->get_arguments(); |
|
| 3915 | 3915 | |
| 3916 | - if ( is_array( $arguments_raw ) ) { |
|
| 3916 | + if ( is_array( $arguments_raw ) ) { |
|
| 3917 | 3917 | |
| 3918 | - $arguments = $this->group_arguments( $arguments_raw ); |
|
| 3918 | + $arguments = $this->group_arguments( $arguments_raw ); |
|
| 3919 | 3919 | |
| 3920 | - // Do we have sections? |
|
| 3921 | - $has_sections = $arguments == $arguments_raw ? false : true; |
|
| 3920 | + // Do we have sections? |
|
| 3921 | + $has_sections = $arguments == $arguments_raw ? false : true; |
|
| 3922 | 3922 | |
| 3923 | 3923 | |
| 3924 | - if ( $has_sections ) { |
|
| 3925 | - $panel_count = 0; |
|
| 3926 | - foreach ( $arguments as $key => $args ) { |
|
| 3924 | + if ( $has_sections ) { |
|
| 3925 | + $panel_count = 0; |
|
| 3926 | + foreach ( $arguments as $key => $args ) { |
|
| 3927 | 3927 | |
| 3928 | - ?> |
|
| 3928 | + ?> |
|
| 3929 | 3929 | <script> |
| 3930 | 3930 | // jQuery(this).find("i").toggleClass("fas fa-chevron-up fas fa-chevron-down");jQuery(this).next().toggle(); |
| 3931 | 3931 | </script> |
| 3932 | 3932 | <?php |
| 3933 | 3933 | |
| 3934 | - $hide = $panel_count ? ' style="display:none;" ' : ''; |
|
| 3935 | - $icon_class = $panel_count ? 'fas fa-chevron-up' : 'fas fa-chevron-down'; |
|
| 3936 | - echo "<button onclick='jQuery(this).find(\"i\").toggleClass(\"fas fa-chevron-up fas fa-chevron-down\");jQuery(this).next().slideToggle();' type='button' class='sd-toggle-group-button sd-input-group-toggle" . sanitize_title_with_dashes( $key ) . "'>" . esc_attr( $key ) . " <i style='float:right;' class='" . $icon_class . "'></i></button>"; |
|
| 3937 | - echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes( $key ) . "' $hide>"; |
|
| 3934 | + $hide = $panel_count ? ' style="display:none;" ' : ''; |
|
| 3935 | + $icon_class = $panel_count ? 'fas fa-chevron-up' : 'fas fa-chevron-down'; |
|
| 3936 | + echo "<button onclick='jQuery(this).find(\"i\").toggleClass(\"fas fa-chevron-up fas fa-chevron-down\");jQuery(this).next().slideToggle();' type='button' class='sd-toggle-group-button sd-input-group-toggle" . sanitize_title_with_dashes( $key ) . "'>" . esc_attr( $key ) . " <i style='float:right;' class='" . $icon_class . "'></i></button>"; |
|
| 3937 | + echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes( $key ) . "' $hide>"; |
|
| 3938 | 3938 | |
| 3939 | - foreach ( $args as $k => $a ) { |
|
| 3939 | + foreach ( $args as $k => $a ) { |
|
| 3940 | 3940 | |
| 3941 | - $this->widget_inputs_row_start($k, $a); |
|
| 3942 | - $this->widget_inputs( $a, $instance ); |
|
| 3943 | - $this->widget_inputs_row_end($k, $a); |
|
| 3941 | + $this->widget_inputs_row_start($k, $a); |
|
| 3942 | + $this->widget_inputs( $a, $instance ); |
|
| 3943 | + $this->widget_inputs_row_end($k, $a); |
|
| 3944 | 3944 | |
| 3945 | - } |
|
| 3945 | + } |
|
| 3946 | 3946 | |
| 3947 | - echo "</div>"; |
|
| 3947 | + echo "</div>"; |
|
| 3948 | 3948 | |
| 3949 | - $panel_count ++; |
|
| 3949 | + $panel_count ++; |
|
| 3950 | 3950 | |
| 3951 | - } |
|
| 3952 | - } else { |
|
| 3953 | - foreach ( $arguments as $key => $args ) { |
|
| 3954 | - $this->widget_inputs_row_start($key, $args); |
|
| 3955 | - $this->widget_inputs( $args, $instance ); |
|
| 3956 | - $this->widget_inputs_row_end($key, $args); |
|
| 3957 | - } |
|
| 3958 | - } |
|
| 3951 | + } |
|
| 3952 | + } else { |
|
| 3953 | + foreach ( $arguments as $key => $args ) { |
|
| 3954 | + $this->widget_inputs_row_start($key, $args); |
|
| 3955 | + $this->widget_inputs( $args, $instance ); |
|
| 3956 | + $this->widget_inputs_row_end($key, $args); |
|
| 3957 | + } |
|
| 3958 | + } |
|
| 3959 | 3959 | |
| 3960 | - } |
|
| 3961 | - } |
|
| 3960 | + } |
|
| 3961 | + } |
|
| 3962 | 3962 | |
| 3963 | - public function widget_inputs_row_start($key, $args){ |
|
| 3964 | - if(!empty($args['row'])){ |
|
| 3965 | - // maybe open |
|
| 3966 | - if(!empty($args['row']['open'])){ |
|
| 3967 | - ?> |
|
| 3963 | + public function widget_inputs_row_start($key, $args){ |
|
| 3964 | + if(!empty($args['row'])){ |
|
| 3965 | + // maybe open |
|
| 3966 | + if(!empty($args['row']['open'])){ |
|
| 3967 | + ?> |
|
| 3968 | 3968 | <div class='bsui sd-argument ' data-argument='<?php echo esc_attr( $args['row']['key'] ); ?>' data-element_require='<?php if ( !empty($args['row']['element_require'])) { |
| 3969 | - echo $this->convert_element_require( $args['row']['element_require'] ); |
|
| 3970 | - } ?>'> |
|
| 3969 | + echo $this->convert_element_require( $args['row']['element_require'] ); |
|
| 3970 | + } ?>'> |
|
| 3971 | 3971 | <?php if(!empty($args['row']['title'])){ ?> |
| 3972 | 3972 | <label class="mb-0 "><?php echo esc_attr( $args['row']['title'] ); ?><?php echo $this->widget_field_desc( $args['row'] ); ?></label> |
| 3973 | 3973 | <?php }?> |
| 3974 | 3974 | <div class='row <?php if(!empty($args['row']['class'])){ echo esc_attr($args['row']['class']);} ?>'> |
| 3975 | 3975 | <div class='col pr-2'> |
| 3976 | 3976 | <?php |
| 3977 | - }elseif(!empty($args['row']['close'])){ |
|
| 3978 | - echo "<div class='col pl-0'>"; |
|
| 3979 | - }else{ |
|
| 3980 | - echo "<div class='col pl-0 pr-2'>"; |
|
| 3981 | - } |
|
| 3982 | - } |
|
| 3983 | - } |
|
| 3977 | + }elseif(!empty($args['row']['close'])){ |
|
| 3978 | + echo "<div class='col pl-0'>"; |
|
| 3979 | + }else{ |
|
| 3980 | + echo "<div class='col pl-0 pr-2'>"; |
|
| 3981 | + } |
|
| 3982 | + } |
|
| 3983 | + } |
|
| 3984 | 3984 | |
| 3985 | - public function widget_inputs_row_end($key, $args){ |
|
| 3985 | + public function widget_inputs_row_end($key, $args){ |
|
| 3986 | 3986 | |
| 3987 | - if(!empty($args['row'])){ |
|
| 3988 | - // maybe close |
|
| 3989 | - if(!empty($args['row']['close'])){ |
|
| 3990 | - echo "</div></div>"; |
|
| 3991 | - } |
|
| 3987 | + if(!empty($args['row'])){ |
|
| 3988 | + // maybe close |
|
| 3989 | + if(!empty($args['row']['close'])){ |
|
| 3990 | + echo "</div></div>"; |
|
| 3991 | + } |
|
| 3992 | 3992 | |
| 3993 | - echo "</div>"; |
|
| 3994 | - } |
|
| 3995 | - } |
|
| 3993 | + echo "</div>"; |
|
| 3994 | + } |
|
| 3995 | + } |
|
| 3996 | 3996 | |
| 3997 | - /** |
|
| 3998 | - * Get the hidden input that when added makes the advanced button show on widget settings. |
|
| 3999 | - * |
|
| 4000 | - * @return string |
|
| 4001 | - */ |
|
| 4002 | - public function widget_advanced_toggle() { |
|
| 4003 | - |
|
| 4004 | - $output = ''; |
|
| 4005 | - if ( $this->block_show_advanced() ) { |
|
| 4006 | - $val = 1; |
|
| 4007 | - } else { |
|
| 4008 | - $val = 0; |
|
| 4009 | - } |
|
| 3997 | + /** |
|
| 3998 | + * Get the hidden input that when added makes the advanced button show on widget settings. |
|
| 3999 | + * |
|
| 4000 | + * @return string |
|
| 4001 | + */ |
|
| 4002 | + public function widget_advanced_toggle() { |
|
| 4010 | 4003 | |
| 4011 | - $output .= "<input type='hidden' class='sd-show-advanced' value='$val' />"; |
|
| 4004 | + $output = ''; |
|
| 4005 | + if ( $this->block_show_advanced() ) { |
|
| 4006 | + $val = 1; |
|
| 4007 | + } else { |
|
| 4008 | + $val = 0; |
|
| 4009 | + } |
|
| 4012 | 4010 | |
| 4013 | - return $output; |
|
| 4014 | - } |
|
| 4011 | + $output .= "<input type='hidden' class='sd-show-advanced' value='$val' />"; |
|
| 4015 | 4012 | |
| 4016 | - /** |
|
| 4017 | - * Convert require element. |
|
| 4018 | - * |
|
| 4019 | - * @param string $input Input element. |
|
| 4020 | - * |
|
| 4021 | - * @return string $output |
|
| 4022 | - *@since 1.0.0 |
|
| 4023 | - * |
|
| 4024 | - */ |
|
| 4025 | - public function convert_element_require( $input ) { |
|
| 4026 | - |
|
| 4027 | - $input = str_replace( "'", '"', $input );// we only want double quotes |
|
| 4028 | - |
|
| 4029 | - $output = esc_attr( str_replace( array( "[%", "%]" ), array( |
|
| 4030 | - "jQuery(form).find('[data-argument=\"", |
|
| 4031 | - "\"]').find('input,select,textarea').val()" |
|
| 4032 | - ), $input ) ); |
|
| 4033 | - |
|
| 4034 | - return $output; |
|
| 4035 | - } |
|
| 4013 | + return $output; |
|
| 4014 | + } |
|
| 4036 | 4015 | |
| 4037 | - /** |
|
| 4038 | - * Builds the inputs for the widget options. |
|
| 4039 | - * |
|
| 4040 | - * @param $args |
|
| 4041 | - * @param $instance |
|
| 4042 | - */ |
|
| 4043 | - public function widget_inputs( $args, $instance ) { |
|
| 4044 | - |
|
| 4045 | - $class = ""; |
|
| 4046 | - $element_require = ""; |
|
| 4047 | - $custom_attributes = ""; |
|
| 4048 | - |
|
| 4049 | - // get value |
|
| 4050 | - if ( isset( $instance[ $args['name'] ] ) ) { |
|
| 4051 | - $value = $instance[ $args['name'] ]; |
|
| 4052 | - } elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) { |
|
| 4053 | - $value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] ); |
|
| 4054 | - } else { |
|
| 4055 | - $value = ''; |
|
| 4056 | - } |
|
| 4016 | + /** |
|
| 4017 | + * Convert require element. |
|
| 4018 | + * |
|
| 4019 | + * @param string $input Input element. |
|
| 4020 | + * |
|
| 4021 | + * @return string $output |
|
| 4022 | + *@since 1.0.0 |
|
| 4023 | + * |
|
| 4024 | + */ |
|
| 4025 | + public function convert_element_require( $input ) { |
|
| 4057 | 4026 | |
| 4058 | - // get placeholder |
|
| 4059 | - if ( ! empty( $args['placeholder'] ) ) { |
|
| 4060 | - $placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'"; |
|
| 4061 | - } else { |
|
| 4062 | - $placeholder = ''; |
|
| 4063 | - } |
|
| 4027 | + $input = str_replace( "'", '"', $input );// we only want double quotes |
|
| 4064 | 4028 | |
| 4065 | - // get if advanced |
|
| 4066 | - if ( isset( $args['advanced'] ) && $args['advanced'] ) { |
|
| 4067 | - $class .= " sd-advanced-setting "; |
|
| 4068 | - } |
|
| 4029 | + $output = esc_attr( str_replace( array( "[%", "%]" ), array( |
|
| 4030 | + "jQuery(form).find('[data-argument=\"", |
|
| 4031 | + "\"]').find('input,select,textarea').val()" |
|
| 4032 | + ), $input ) ); |
|
| 4069 | 4033 | |
| 4070 | - // element_require |
|
| 4071 | - if ( isset( $args['element_require'] ) && $args['element_require'] ) { |
|
| 4072 | - $element_require = $args['element_require']; |
|
| 4073 | - } |
|
| 4034 | + return $output; |
|
| 4035 | + } |
|
| 4074 | 4036 | |
| 4075 | - // custom_attributes |
|
| 4076 | - if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) { |
|
| 4077 | - $custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true ); |
|
| 4078 | - } |
|
| 4037 | + /** |
|
| 4038 | + * Builds the inputs for the widget options. |
|
| 4039 | + * |
|
| 4040 | + * @param $args |
|
| 4041 | + * @param $instance |
|
| 4042 | + */ |
|
| 4043 | + public function widget_inputs( $args, $instance ) { |
|
| 4044 | + |
|
| 4045 | + $class = ""; |
|
| 4046 | + $element_require = ""; |
|
| 4047 | + $custom_attributes = ""; |
|
| 4048 | + |
|
| 4049 | + // get value |
|
| 4050 | + if ( isset( $instance[ $args['name'] ] ) ) { |
|
| 4051 | + $value = $instance[ $args['name'] ]; |
|
| 4052 | + } elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) { |
|
| 4053 | + $value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] ); |
|
| 4054 | + } else { |
|
| 4055 | + $value = ''; |
|
| 4056 | + } |
|
| 4057 | + |
|
| 4058 | + // get placeholder |
|
| 4059 | + if ( ! empty( $args['placeholder'] ) ) { |
|
| 4060 | + $placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'"; |
|
| 4061 | + } else { |
|
| 4062 | + $placeholder = ''; |
|
| 4063 | + } |
|
| 4079 | 4064 | |
| 4065 | + // get if advanced |
|
| 4066 | + if ( isset( $args['advanced'] ) && $args['advanced'] ) { |
|
| 4067 | + $class .= " sd-advanced-setting "; |
|
| 4068 | + } |
|
| 4080 | 4069 | |
| 4081 | - // before wrapper |
|
| 4082 | - ?> |
|
| 4070 | + // element_require |
|
| 4071 | + if ( isset( $args['element_require'] ) && $args['element_require'] ) { |
|
| 4072 | + $element_require = $args['element_require']; |
|
| 4073 | + } |
|
| 4074 | + |
|
| 4075 | + // custom_attributes |
|
| 4076 | + if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) { |
|
| 4077 | + $custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true ); |
|
| 4078 | + } |
|
| 4079 | + |
|
| 4080 | + |
|
| 4081 | + // before wrapper |
|
| 4082 | + ?> |
|
| 4083 | 4083 | <p class="sd-argument <?php echo esc_attr( $class ); ?>" |
| 4084 | 4084 | data-argument='<?php echo esc_attr( $args['name'] ); ?>' |
| 4085 | 4085 | data-element_require='<?php if ( $element_require ) { |
| 4086 | - echo $this->convert_element_require( $element_require ); |
|
| 4087 | - } ?>' |
|
| 4086 | + echo $this->convert_element_require( $element_require ); |
|
| 4087 | + } ?>' |
|
| 4088 | 4088 | > |
| 4089 | 4089 | <?php |
| 4090 | 4090 | |
| 4091 | 4091 | |
| 4092 | - switch ( $args['type'] ) { |
|
| 4093 | - //array('text','password','number','email','tel','url','color') |
|
| 4094 | - case "text": |
|
| 4095 | - case "password": |
|
| 4096 | - case "number": |
|
| 4097 | - case "email": |
|
| 4098 | - case "tel": |
|
| 4099 | - case "url": |
|
| 4100 | - case "color": |
|
| 4101 | - ?> |
|
| 4092 | + switch ( $args['type'] ) { |
|
| 4093 | + //array('text','password','number','email','tel','url','color') |
|
| 4094 | + case "text": |
|
| 4095 | + case "password": |
|
| 4096 | + case "number": |
|
| 4097 | + case "email": |
|
| 4098 | + case "tel": |
|
| 4099 | + case "url": |
|
| 4100 | + case "color": |
|
| 4101 | + ?> |
|
| 4102 | 4102 | <label |
| 4103 | 4103 | for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args );?><?php echo $this->widget_field_desc( $args ); ?></label> |
| 4104 | 4104 | <input <?php echo $placeholder; ?> class="widefat" |
@@ -4109,47 +4109,47 @@ discard block |
||
| 4109 | 4109 | value="<?php echo esc_attr( $value ); ?>"> |
| 4110 | 4110 | <?php |
| 4111 | 4111 | |
| 4112 | - break; |
|
| 4113 | - case "select": |
|
| 4114 | - $multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false; |
|
| 4115 | - if ( $multiple ) { |
|
| 4116 | - if ( empty( $value ) ) { |
|
| 4117 | - $value = array(); |
|
| 4118 | - } |
|
| 4119 | - } |
|
| 4120 | - ?> |
|
| 4112 | + break; |
|
| 4113 | + case "select": |
|
| 4114 | + $multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false; |
|
| 4115 | + if ( $multiple ) { |
|
| 4116 | + if ( empty( $value ) ) { |
|
| 4117 | + $value = array(); |
|
| 4118 | + } |
|
| 4119 | + } |
|
| 4120 | + ?> |
|
| 4121 | 4121 | <label |
| 4122 | 4122 | for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args ); ?><?php echo $this->widget_field_desc( $args ); ?></label> |
| 4123 | 4123 | <select <?php echo $placeholder; ?> class="widefat" |
| 4124 | 4124 | <?php echo $custom_attributes; ?> |
| 4125 | 4125 | id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
| 4126 | 4126 | name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); |
| 4127 | - if ( $multiple ) { |
|
| 4128 | - echo "[]"; |
|
| 4129 | - } ?>" |
|
| 4127 | + if ( $multiple ) { |
|
| 4128 | + echo "[]"; |
|
| 4129 | + } ?>" |
|
| 4130 | 4130 | <?php if ( $multiple ) { |
| 4131 | - echo "multiple"; |
|
| 4132 | - } //@todo not implemented yet due to gutenberg not supporting it |
|
| 4133 | - ?> |
|
| 4131 | + echo "multiple"; |
|
| 4132 | + } //@todo not implemented yet due to gutenberg not supporting it |
|
| 4133 | + ?> |
|
| 4134 | 4134 | > |
| 4135 | 4135 | <?php |
| 4136 | 4136 | |
| 4137 | - if ( ! empty( $args['options'] ) ) { |
|
| 4138 | - foreach ( $args['options'] as $val => $label ) { |
|
| 4139 | - if ( $multiple ) { |
|
| 4140 | - $selected = in_array( $val, $value ) ? 'selected="selected"' : ''; |
|
| 4141 | - } else { |
|
| 4142 | - $selected = selected( $value, $val, false ); |
|
| 4143 | - } |
|
| 4144 | - echo "<option value='$val' " . $selected . ">$label</option>"; |
|
| 4145 | - } |
|
| 4146 | - } |
|
| 4147 | - ?> |
|
| 4137 | + if ( ! empty( $args['options'] ) ) { |
|
| 4138 | + foreach ( $args['options'] as $val => $label ) { |
|
| 4139 | + if ( $multiple ) { |
|
| 4140 | + $selected = in_array( $val, $value ) ? 'selected="selected"' : ''; |
|
| 4141 | + } else { |
|
| 4142 | + $selected = selected( $value, $val, false ); |
|
| 4143 | + } |
|
| 4144 | + echo "<option value='$val' " . $selected . ">$label</option>"; |
|
| 4145 | + } |
|
| 4146 | + } |
|
| 4147 | + ?> |
|
| 4148 | 4148 | </select> |
| 4149 | 4149 | <?php |
| 4150 | - break; |
|
| 4151 | - case "checkbox": |
|
| 4152 | - ?> |
|
| 4150 | + break; |
|
| 4151 | + case "checkbox": |
|
| 4152 | + ?> |
|
| 4153 | 4153 | <input <?php echo $placeholder; ?> |
| 4154 | 4154 | <?php checked( 1, $value, true ) ?> |
| 4155 | 4155 | <?php echo $custom_attributes; ?> |
@@ -4159,9 +4159,9 @@ discard block |
||
| 4159 | 4159 | <label |
| 4160 | 4160 | for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args );?><?php echo $this->widget_field_desc( $args ); ?></label> |
| 4161 | 4161 | <?php |
| 4162 | - break; |
|
| 4163 | - case "textarea": |
|
| 4164 | - ?> |
|
| 4162 | + break; |
|
| 4163 | + case "textarea": |
|
| 4164 | + ?> |
|
| 4165 | 4165 | <label |
| 4166 | 4166 | for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args ); ?><?php echo $this->widget_field_desc( $args ); ?></label> |
| 4167 | 4167 | <textarea <?php echo $placeholder; ?> class="widefat" |
@@ -4171,282 +4171,282 @@ discard block |
||
| 4171 | 4171 | ><?php echo esc_attr( $value ); ?></textarea> |
| 4172 | 4172 | <?php |
| 4173 | 4173 | |
| 4174 | - break; |
|
| 4175 | - case "hidden": |
|
| 4176 | - ?> |
|
| 4174 | + break; |
|
| 4175 | + case "hidden": |
|
| 4176 | + ?> |
|
| 4177 | 4177 | <input id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
| 4178 | 4178 | name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="hidden" |
| 4179 | 4179 | value="<?php echo esc_attr( $value ); ?>"> |
| 4180 | 4180 | <?php |
| 4181 | - break; |
|
| 4182 | - default: |
|
| 4183 | - echo "No input type found!"; // @todo we need to add more input types. |
|
| 4184 | - } |
|
| 4181 | + break; |
|
| 4182 | + default: |
|
| 4183 | + echo "No input type found!"; // @todo we need to add more input types. |
|
| 4184 | + } |
|
| 4185 | 4185 | |
| 4186 | - // after wrapper |
|
| 4187 | - ?> |
|
| 4186 | + // after wrapper |
|
| 4187 | + ?> |
|
| 4188 | 4188 | </p> |
| 4189 | 4189 | <?php |
| 4190 | 4190 | |
| 4191 | 4191 | |
| 4192 | - } |
|
| 4192 | + } |
|
| 4193 | 4193 | |
| 4194 | - public function get_widget_icon($icon = 'box-top', $title = ''){ |
|
| 4195 | - if($icon=='box-top'){ |
|
| 4196 | - return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.048" height="9.017" fill="#555D66"></rect><rect x="16.265" y="5.498" width="1.023" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.186" width="8.964" height="2.482" fill="#272B2F"></rect><rect x="5.487" y="16.261" width="9.026" height="1.037" fill="#555D66"></rect></svg>'; |
|
| 4197 | - }elseif($icon=='box-right'){ |
|
| 4198 | - return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.046" height="9.017" fill="#555D66"></rect><rect x="15.244" y="5.498" width="2.518" height="9.003" fill="#272B2F"></rect><rect x="5.518" y="2.719" width="8.964" height="0.954" fill="#555D66"></rect><rect x="5.487" y="16.308" width="9.026" height="0.99" fill="#555D66"></rect></svg>'; |
|
| 4199 | - }elseif($icon=='box-bottom'){ |
|
| 4200 | - return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1" height="9.017" fill="#555D66"></rect><rect x="16.261" y="5.498" width="1.027" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.968" fill="#555D66"></rect><rect x="5.487" y="15.28" width="9.026" height="2.499" fill="#272B2F"></rect></svg>'; |
|
| 4201 | - }elseif($icon=='box-left'){ |
|
| 4202 | - return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.202" y="5.492" width="2.503" height="9.017" fill="#272B2F"></rect><rect x="16.276" y="5.498" width="1.012" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.966" fill="#555D66"></rect><rect x="5.487" y="16.303" width="9.026" height="0.995" fill="#555D66"></rect></svg>'; |
|
| 4203 | - } |
|
| 4204 | - } |
|
| 4194 | + public function get_widget_icon($icon = 'box-top', $title = ''){ |
|
| 4195 | + if($icon=='box-top'){ |
|
| 4196 | + return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.048" height="9.017" fill="#555D66"></rect><rect x="16.265" y="5.498" width="1.023" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.186" width="8.964" height="2.482" fill="#272B2F"></rect><rect x="5.487" y="16.261" width="9.026" height="1.037" fill="#555D66"></rect></svg>'; |
|
| 4197 | + }elseif($icon=='box-right'){ |
|
| 4198 | + return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.046" height="9.017" fill="#555D66"></rect><rect x="15.244" y="5.498" width="2.518" height="9.003" fill="#272B2F"></rect><rect x="5.518" y="2.719" width="8.964" height="0.954" fill="#555D66"></rect><rect x="5.487" y="16.308" width="9.026" height="0.99" fill="#555D66"></rect></svg>'; |
|
| 4199 | + }elseif($icon=='box-bottom'){ |
|
| 4200 | + return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1" height="9.017" fill="#555D66"></rect><rect x="16.261" y="5.498" width="1.027" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.968" fill="#555D66"></rect><rect x="5.487" y="15.28" width="9.026" height="2.499" fill="#272B2F"></rect></svg>'; |
|
| 4201 | + }elseif($icon=='box-left'){ |
|
| 4202 | + return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.202" y="5.492" width="2.503" height="9.017" fill="#272B2F"></rect><rect x="16.276" y="5.498" width="1.012" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.966" fill="#555D66"></rect><rect x="5.487" y="16.303" width="9.026" height="0.995" fill="#555D66"></rect></svg>'; |
|
| 4203 | + } |
|
| 4204 | + } |
|
| 4205 | 4205 | |
| 4206 | - /** |
|
| 4207 | - * Get the widget input description html. |
|
| 4208 | - * |
|
| 4209 | - * @param $args |
|
| 4210 | - * |
|
| 4211 | - * @return string |
|
| 4212 | - * @todo, need to make its own tooltip script |
|
| 4213 | - */ |
|
| 4214 | - public function widget_field_desc( $args ) { |
|
| 4215 | - |
|
| 4216 | - $description = ''; |
|
| 4217 | - if ( isset( $args['desc'] ) && $args['desc'] ) { |
|
| 4218 | - if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) { |
|
| 4219 | - $description = $this->desc_tip( $args['desc'] ); |
|
| 4220 | - } else { |
|
| 4221 | - $description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>'; |
|
| 4222 | - } |
|
| 4223 | - } |
|
| 4206 | + /** |
|
| 4207 | + * Get the widget input description html. |
|
| 4208 | + * |
|
| 4209 | + * @param $args |
|
| 4210 | + * |
|
| 4211 | + * @return string |
|
| 4212 | + * @todo, need to make its own tooltip script |
|
| 4213 | + */ |
|
| 4214 | + public function widget_field_desc( $args ) { |
|
| 4215 | + |
|
| 4216 | + $description = ''; |
|
| 4217 | + if ( isset( $args['desc'] ) && $args['desc'] ) { |
|
| 4218 | + if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) { |
|
| 4219 | + $description = $this->desc_tip( $args['desc'] ); |
|
| 4220 | + } else { |
|
| 4221 | + $description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>'; |
|
| 4222 | + } |
|
| 4223 | + } |
|
| 4224 | 4224 | |
| 4225 | - return $description; |
|
| 4226 | - } |
|
| 4225 | + return $description; |
|
| 4226 | + } |
|
| 4227 | 4227 | |
| 4228 | - /** |
|
| 4229 | - * Get the widget input title html. |
|
| 4230 | - * |
|
| 4231 | - * @param $args |
|
| 4232 | - * |
|
| 4233 | - * @return string |
|
| 4234 | - */ |
|
| 4235 | - public function widget_field_title( $args ) { |
|
| 4236 | - |
|
| 4237 | - $title = ''; |
|
| 4238 | - if ( isset( $args['title'] ) && $args['title'] ) { |
|
| 4239 | - if ( isset( $args['icon'] ) && $args['icon'] ) { |
|
| 4240 | - $title = self::get_widget_icon( $args['icon'], $args['title'] ); |
|
| 4241 | - } else { |
|
| 4242 | - $title = esc_attr($args['title']); |
|
| 4243 | - } |
|
| 4244 | - } |
|
| 4228 | + /** |
|
| 4229 | + * Get the widget input title html. |
|
| 4230 | + * |
|
| 4231 | + * @param $args |
|
| 4232 | + * |
|
| 4233 | + * @return string |
|
| 4234 | + */ |
|
| 4235 | + public function widget_field_title( $args ) { |
|
| 4236 | + |
|
| 4237 | + $title = ''; |
|
| 4238 | + if ( isset( $args['title'] ) && $args['title'] ) { |
|
| 4239 | + if ( isset( $args['icon'] ) && $args['icon'] ) { |
|
| 4240 | + $title = self::get_widget_icon( $args['icon'], $args['title'] ); |
|
| 4241 | + } else { |
|
| 4242 | + $title = esc_attr($args['title']); |
|
| 4243 | + } |
|
| 4244 | + } |
|
| 4245 | 4245 | |
| 4246 | - return $title; |
|
| 4247 | - } |
|
| 4246 | + return $title; |
|
| 4247 | + } |
|
| 4248 | 4248 | |
| 4249 | - /** |
|
| 4250 | - * Get the tool tip html. |
|
| 4251 | - * |
|
| 4252 | - * @param $tip |
|
| 4253 | - * @param bool $allow_html |
|
| 4254 | - * |
|
| 4255 | - * @return string |
|
| 4256 | - */ |
|
| 4257 | - function desc_tip( $tip, $allow_html = false ) { |
|
| 4258 | - if ( $allow_html ) { |
|
| 4259 | - $tip = $this->sanitize_tooltip( $tip ); |
|
| 4260 | - } else { |
|
| 4261 | - $tip = esc_attr( $tip ); |
|
| 4262 | - } |
|
| 4249 | + /** |
|
| 4250 | + * Get the tool tip html. |
|
| 4251 | + * |
|
| 4252 | + * @param $tip |
|
| 4253 | + * @param bool $allow_html |
|
| 4254 | + * |
|
| 4255 | + * @return string |
|
| 4256 | + */ |
|
| 4257 | + function desc_tip( $tip, $allow_html = false ) { |
|
| 4258 | + if ( $allow_html ) { |
|
| 4259 | + $tip = $this->sanitize_tooltip( $tip ); |
|
| 4260 | + } else { |
|
| 4261 | + $tip = esc_attr( $tip ); |
|
| 4262 | + } |
|
| 4263 | 4263 | |
| 4264 | - return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
|
| 4265 | - } |
|
| 4264 | + return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
|
| 4265 | + } |
|
| 4266 | 4266 | |
| 4267 | - /** |
|
| 4268 | - * Sanitize a string destined to be a tooltip. |
|
| 4269 | - * |
|
| 4270 | - * @param string $var |
|
| 4271 | - * |
|
| 4272 | - * @return string |
|
| 4273 | - */ |
|
| 4274 | - public function sanitize_tooltip( $var ) { |
|
| 4275 | - return htmlspecialchars( wp_kses( html_entity_decode( $var ), array( |
|
| 4276 | - 'br' => array(), |
|
| 4277 | - 'em' => array(), |
|
| 4278 | - 'strong' => array(), |
|
| 4279 | - 'small' => array(), |
|
| 4280 | - 'span' => array(), |
|
| 4281 | - 'ul' => array(), |
|
| 4282 | - 'li' => array(), |
|
| 4283 | - 'ol' => array(), |
|
| 4284 | - 'p' => array(), |
|
| 4285 | - ) ) ); |
|
| 4286 | - } |
|
| 4267 | + /** |
|
| 4268 | + * Sanitize a string destined to be a tooltip. |
|
| 4269 | + * |
|
| 4270 | + * @param string $var |
|
| 4271 | + * |
|
| 4272 | + * @return string |
|
| 4273 | + */ |
|
| 4274 | + public function sanitize_tooltip( $var ) { |
|
| 4275 | + return htmlspecialchars( wp_kses( html_entity_decode( $var ), array( |
|
| 4276 | + 'br' => array(), |
|
| 4277 | + 'em' => array(), |
|
| 4278 | + 'strong' => array(), |
|
| 4279 | + 'small' => array(), |
|
| 4280 | + 'span' => array(), |
|
| 4281 | + 'ul' => array(), |
|
| 4282 | + 'li' => array(), |
|
| 4283 | + 'ol' => array(), |
|
| 4284 | + 'p' => array(), |
|
| 4285 | + ) ) ); |
|
| 4286 | + } |
|
| 4287 | 4287 | |
| 4288 | - /** |
|
| 4289 | - * Processing widget options on save |
|
| 4290 | - * |
|
| 4291 | - * @param array $new_instance The new options |
|
| 4292 | - * @param array $old_instance The previous options |
|
| 4293 | - * |
|
| 4294 | - * @return array |
|
| 4295 | - * @todo we should add some sanitation here. |
|
| 4296 | - */ |
|
| 4297 | - public function update( $new_instance, $old_instance ) { |
|
| 4298 | - |
|
| 4299 | - //save the widget |
|
| 4300 | - $instance = array_merge( (array) $old_instance, (array) $new_instance ); |
|
| 4301 | - |
|
| 4302 | - // set widget instance |
|
| 4303 | - $this->instance = $instance; |
|
| 4304 | - |
|
| 4305 | - if ( empty( $this->arguments ) ) { |
|
| 4306 | - $this->get_arguments(); |
|
| 4307 | - } |
|
| 4288 | + /** |
|
| 4289 | + * Processing widget options on save |
|
| 4290 | + * |
|
| 4291 | + * @param array $new_instance The new options |
|
| 4292 | + * @param array $old_instance The previous options |
|
| 4293 | + * |
|
| 4294 | + * @return array |
|
| 4295 | + * @todo we should add some sanitation here. |
|
| 4296 | + */ |
|
| 4297 | + public function update( $new_instance, $old_instance ) { |
|
| 4308 | 4298 | |
| 4309 | - // check for checkboxes |
|
| 4310 | - if ( ! empty( $this->arguments ) ) { |
|
| 4311 | - foreach ( $this->arguments as $argument ) { |
|
| 4312 | - if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) { |
|
| 4313 | - $instance[ $argument['name'] ] = '0'; |
|
| 4314 | - } |
|
| 4315 | - } |
|
| 4316 | - } |
|
| 4299 | + //save the widget |
|
| 4300 | + $instance = array_merge( (array) $old_instance, (array) $new_instance ); |
|
| 4317 | 4301 | |
| 4318 | - return $instance; |
|
| 4319 | - } |
|
| 4302 | + // set widget instance |
|
| 4303 | + $this->instance = $instance; |
|
| 4320 | 4304 | |
| 4321 | - /** |
|
| 4322 | - * Checks if the current call is a ajax call to get the block content. |
|
| 4323 | - * |
|
| 4324 | - * This can be used in your widget to return different content as the block content. |
|
| 4325 | - * |
|
| 4326 | - * @return bool |
|
| 4327 | - *@since 1.0.3 |
|
| 4328 | - */ |
|
| 4329 | - public function is_block_content_call() { |
|
| 4330 | - $result = false; |
|
| 4331 | - if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) { |
|
| 4332 | - $result = true; |
|
| 4333 | - } |
|
| 4305 | + if ( empty( $this->arguments ) ) { |
|
| 4306 | + $this->get_arguments(); |
|
| 4307 | + } |
|
| 4334 | 4308 | |
| 4335 | - return $result; |
|
| 4336 | - } |
|
| 4309 | + // check for checkboxes |
|
| 4310 | + if ( ! empty( $this->arguments ) ) { |
|
| 4311 | + foreach ( $this->arguments as $argument ) { |
|
| 4312 | + if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) { |
|
| 4313 | + $instance[ $argument['name'] ] = '0'; |
|
| 4314 | + } |
|
| 4315 | + } |
|
| 4316 | + } |
|
| 4337 | 4317 | |
| 4338 | - /** |
|
| 4339 | - * Get an instance hash that will be unique to the type and settings. |
|
| 4340 | - * |
|
| 4341 | - * @return string |
|
| 4342 | - *@since 1.0.20 |
|
| 4343 | - */ |
|
| 4344 | - public function get_instance_hash(){ |
|
| 4345 | - $instance_string = $this->base_id.serialize($this->instance); |
|
| 4346 | - return hash('crc32b',$instance_string); |
|
| 4347 | - } |
|
| 4318 | + return $instance; |
|
| 4319 | + } |
|
| 4348 | 4320 | |
| 4349 | - /** |
|
| 4350 | - * Generate and return inline styles from CSS rules that will match the unique class of the instance. |
|
| 4351 | - * |
|
| 4352 | - * @param array $rules |
|
| 4353 | - * |
|
| 4354 | - * @return string |
|
| 4355 | - *@since 1.0.20 |
|
| 4356 | - */ |
|
| 4357 | - public function get_instance_style($rules = array()){ |
|
| 4358 | - $css = ''; |
|
| 4359 | - |
|
| 4360 | - if(!empty($rules)){ |
|
| 4361 | - $rules = array_unique($rules); |
|
| 4362 | - $instance_hash = $this->get_instance_hash(); |
|
| 4363 | - $css .= "<style>"; |
|
| 4364 | - foreach($rules as $rule){ |
|
| 4365 | - $css .= ".sdel-$instance_hash $rule"; |
|
| 4366 | - } |
|
| 4367 | - $css .= "</style>"; |
|
| 4368 | - } |
|
| 4321 | + /** |
|
| 4322 | + * Checks if the current call is a ajax call to get the block content. |
|
| 4323 | + * |
|
| 4324 | + * This can be used in your widget to return different content as the block content. |
|
| 4325 | + * |
|
| 4326 | + * @return bool |
|
| 4327 | + *@since 1.0.3 |
|
| 4328 | + */ |
|
| 4329 | + public function is_block_content_call() { |
|
| 4330 | + $result = false; |
|
| 4331 | + if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) { |
|
| 4332 | + $result = true; |
|
| 4333 | + } |
|
| 4369 | 4334 | |
| 4370 | - return $css; |
|
| 4371 | - } |
|
| 4335 | + return $result; |
|
| 4336 | + } |
|
| 4337 | + |
|
| 4338 | + /** |
|
| 4339 | + * Get an instance hash that will be unique to the type and settings. |
|
| 4340 | + * |
|
| 4341 | + * @return string |
|
| 4342 | + *@since 1.0.20 |
|
| 4343 | + */ |
|
| 4344 | + public function get_instance_hash(){ |
|
| 4345 | + $instance_string = $this->base_id.serialize($this->instance); |
|
| 4346 | + return hash('crc32b',$instance_string); |
|
| 4347 | + } |
|
| 4348 | + |
|
| 4349 | + /** |
|
| 4350 | + * Generate and return inline styles from CSS rules that will match the unique class of the instance. |
|
| 4351 | + * |
|
| 4352 | + * @param array $rules |
|
| 4353 | + * |
|
| 4354 | + * @return string |
|
| 4355 | + *@since 1.0.20 |
|
| 4356 | + */ |
|
| 4357 | + public function get_instance_style($rules = array()){ |
|
| 4358 | + $css = ''; |
|
| 4359 | + |
|
| 4360 | + if(!empty($rules)){ |
|
| 4361 | + $rules = array_unique($rules); |
|
| 4362 | + $instance_hash = $this->get_instance_hash(); |
|
| 4363 | + $css .= "<style>"; |
|
| 4364 | + foreach($rules as $rule){ |
|
| 4365 | + $css .= ".sdel-$instance_hash $rule"; |
|
| 4366 | + } |
|
| 4367 | + $css .= "</style>"; |
|
| 4368 | + } |
|
| 4369 | + |
|
| 4370 | + return $css; |
|
| 4371 | + } |
|
| 4372 | 4372 | |
| 4373 | - /** |
|
| 4374 | - * Encode shortcodes tags. |
|
| 4375 | - * |
|
| 4376 | - * @param string $content Content to search for shortcode tags. |
|
| 4377 | - * |
|
| 4373 | + /** |
|
| 4374 | + * Encode shortcodes tags. |
|
| 4375 | + * |
|
| 4376 | + * @param string $content Content to search for shortcode tags. |
|
| 4377 | + * |
|
| 4378 | 4378 | *@return string Content with shortcode tags removed. |
| 4379 | - *@since 1.0.28 |
|
| 4380 | - * |
|
| 4381 | - */ |
|
| 4382 | - public function encode_shortcodes( $content ) { |
|
| 4383 | - // Avoids existing encoded tags. |
|
| 4384 | - $trans = array( |
|
| 4385 | - '[' => '[', |
|
| 4386 | - ']' => ']', |
|
| 4387 | - '&#91;' => '[', |
|
| 4388 | - '&#93;' => ']', |
|
| 4389 | - '<' => '&0lt;', |
|
| 4390 | - '>' => '&0gt;', |
|
| 4391 | - '&lt;' => '&0lt;', |
|
| 4392 | - '&gt;' => '&0gt;', |
|
| 4393 | - ); |
|
| 4394 | - |
|
| 4395 | - $content = strtr( $content, $trans ); |
|
| 4396 | - |
|
| 4397 | - $trans = array( |
|
| 4398 | - '[' => '[', |
|
| 4399 | - ']' => ']', |
|
| 4400 | - '<' => '<', |
|
| 4401 | - '>' => '>', |
|
| 4402 | - '"' => '"', |
|
| 4403 | - "'" => ''', |
|
| 4404 | - ); |
|
| 4405 | - |
|
| 4406 | - $content = strtr( $content, $trans ); |
|
| 4407 | - |
|
| 4408 | - return $content; |
|
| 4409 | - } |
|
| 4379 | + *@since 1.0.28 |
|
| 4380 | + * |
|
| 4381 | + */ |
|
| 4382 | + public function encode_shortcodes( $content ) { |
|
| 4383 | + // Avoids existing encoded tags. |
|
| 4384 | + $trans = array( |
|
| 4385 | + '[' => '[', |
|
| 4386 | + ']' => ']', |
|
| 4387 | + '&#91;' => '[', |
|
| 4388 | + '&#93;' => ']', |
|
| 4389 | + '<' => '&0lt;', |
|
| 4390 | + '>' => '&0gt;', |
|
| 4391 | + '&lt;' => '&0lt;', |
|
| 4392 | + '&gt;' => '&0gt;', |
|
| 4393 | + ); |
|
| 4394 | + |
|
| 4395 | + $content = strtr( $content, $trans ); |
|
| 4396 | + |
|
| 4397 | + $trans = array( |
|
| 4398 | + '[' => '[', |
|
| 4399 | + ']' => ']', |
|
| 4400 | + '<' => '<', |
|
| 4401 | + '>' => '>', |
|
| 4402 | + '"' => '"', |
|
| 4403 | + "'" => ''', |
|
| 4404 | + ); |
|
| 4405 | + |
|
| 4406 | + $content = strtr( $content, $trans ); |
|
| 4407 | + |
|
| 4408 | + return $content; |
|
| 4409 | + } |
|
| 4410 | 4410 | |
| 4411 | - /** |
|
| 4412 | - * Remove encoded shortcod tags. |
|
| 4413 | - * |
|
| 4414 | - * @param string $content Content to search for shortcode tags. |
|
| 4415 | - * |
|
| 4411 | + /** |
|
| 4412 | + * Remove encoded shortcod tags. |
|
| 4413 | + * |
|
| 4414 | + * @param string $content Content to search for shortcode tags. |
|
| 4415 | + * |
|
| 4416 | 4416 | *@return string Content with decoded shortcode tags. |
| 4417 | - *@since 1.0.28 |
|
| 4418 | - * |
|
| 4419 | - */ |
|
| 4420 | - public function decode_shortcodes( $content ) { |
|
| 4421 | - $trans = array( |
|
| 4422 | - '[' => '[', |
|
| 4423 | - ']' => ']', |
|
| 4424 | - '&#91;' => '[', |
|
| 4425 | - '&#93;' => ']', |
|
| 4426 | - '<' => '<', |
|
| 4427 | - '>' => '>', |
|
| 4428 | - '&lt;' => '<', |
|
| 4429 | - '&gt;' => '>', |
|
| 4430 | - '"' => '"', |
|
| 4431 | - ''' => "'", |
|
| 4432 | - ); |
|
| 4433 | - |
|
| 4434 | - $content = strtr( $content, $trans ); |
|
| 4435 | - |
|
| 4436 | - $trans = array( |
|
| 4437 | - '[' => '[', |
|
| 4438 | - ']' => ']', |
|
| 4439 | - '&#091;' => '[', |
|
| 4440 | - '&#093;' => ']', |
|
| 4441 | - '&0lt;' => '<', |
|
| 4442 | - '&0gt;' => '>', |
|
| 4443 | - '&0lt;' => '<', |
|
| 4444 | - '&0gt;' => '>', |
|
| 4445 | - ); |
|
| 4446 | - |
|
| 4447 | - $content = strtr( $content, $trans ); |
|
| 4448 | - |
|
| 4449 | - return $content; |
|
| 4450 | - } |
|
| 4451 | - } |
|
| 4417 | + *@since 1.0.28 |
|
| 4418 | + * |
|
| 4419 | + */ |
|
| 4420 | + public function decode_shortcodes( $content ) { |
|
| 4421 | + $trans = array( |
|
| 4422 | + '[' => '[', |
|
| 4423 | + ']' => ']', |
|
| 4424 | + '&#91;' => '[', |
|
| 4425 | + '&#93;' => ']', |
|
| 4426 | + '<' => '<', |
|
| 4427 | + '>' => '>', |
|
| 4428 | + '&lt;' => '<', |
|
| 4429 | + '&gt;' => '>', |
|
| 4430 | + '"' => '"', |
|
| 4431 | + ''' => "'", |
|
| 4432 | + ); |
|
| 4433 | + |
|
| 4434 | + $content = strtr( $content, $trans ); |
|
| 4435 | + |
|
| 4436 | + $trans = array( |
|
| 4437 | + '[' => '[', |
|
| 4438 | + ']' => ']', |
|
| 4439 | + '&#091;' => '[', |
|
| 4440 | + '&#093;' => ']', |
|
| 4441 | + '&0lt;' => '<', |
|
| 4442 | + '&0gt;' => '>', |
|
| 4443 | + '&0lt;' => '<', |
|
| 4444 | + '&0gt;' => '>', |
|
| 4445 | + ); |
|
| 4446 | + |
|
| 4447 | + $content = strtr( $content, $trans ); |
|
| 4448 | + |
|
| 4449 | + return $content; |
|
| 4450 | + } |
|
| 4451 | + } |
|
| 4452 | 4452 | } |
@@ -1,9 +1,9 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | +if (!defined('ABSPATH')) { |
|
| 3 | 3 | exit; |
| 4 | 4 | } |
| 5 | 5 | |
| 6 | -if ( ! class_exists( 'WP_Super_Duper' ) ) { |
|
| 6 | +if (!class_exists('WP_Super_Duper')) { |
|
| 7 | 7 | |
| 8 | 8 | |
| 9 | 9 | /** |
@@ -37,40 +37,40 @@ discard block |
||
| 37 | 37 | /** |
| 38 | 38 | * Take the array options and use them to build. |
| 39 | 39 | */ |
| 40 | - public function __construct( $options ) { |
|
| 40 | + public function __construct($options) { |
|
| 41 | 41 | global $sd_widgets; |
| 42 | 42 | |
| 43 | - $sd_widgets[ $options['base_id'] ] = array( |
|
| 43 | + $sd_widgets[$options['base_id']] = array( |
|
| 44 | 44 | 'name' => $options['name'], |
| 45 | 45 | 'class_name' => $options['class_name'], |
| 46 | 46 | 'output_types' => !empty($options['output_types']) ? $options['output_types'] : array() |
| 47 | 47 | ); |
| 48 | - $this->base_id = $options['base_id']; |
|
| 48 | + $this->base_id = $options['base_id']; |
|
| 49 | 49 | // lets filter the options before we do anything |
| 50 | - $options = apply_filters( "wp_super_duper_options", $options ); |
|
| 51 | - $options = apply_filters( "wp_super_duper_options_{$this->base_id}", $options ); |
|
| 52 | - $options = $this->add_name_from_key( $options ); |
|
| 50 | + $options = apply_filters("wp_super_duper_options", $options); |
|
| 51 | + $options = apply_filters("wp_super_duper_options_{$this->base_id}", $options); |
|
| 52 | + $options = $this->add_name_from_key($options); |
|
| 53 | 53 | $this->options = $options; |
| 54 | 54 | |
| 55 | 55 | $this->base_id = $options['base_id']; |
| 56 | - $this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array(); |
|
| 56 | + $this->arguments = isset($options['arguments']) ? $options['arguments'] : array(); |
|
| 57 | 57 | |
| 58 | 58 | // nested blocks can't work as a widget |
| 59 | - if(!empty($this->options['nested-block'])){ |
|
| 60 | - if(empty($this->options['output_types'])){ |
|
| 61 | - $this->options['output_types'] = array('shortcode','block'); |
|
| 59 | + if (!empty($this->options['nested-block'])) { |
|
| 60 | + if (empty($this->options['output_types'])) { |
|
| 61 | + $this->options['output_types'] = array('shortcode', 'block'); |
|
| 62 | 62 | }elseif (($key = array_search('widget', $this->options['output_types'])) !== false) { |
| 63 | 63 | unset($this->options['output_types'][$key]); |
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | // init parent |
| 68 | - if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){ |
|
| 69 | - parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] ); |
|
| 68 | + if (empty($this->options['output_types']) || in_array('widget', $this->options['output_types'])) { |
|
| 69 | + parent::__construct($options['base_id'], $options['name'], $options['widget_ops']); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | |
| 73 | - if ( isset( $options['class_name'] ) ) { |
|
| 73 | + if (isset($options['class_name'])) { |
|
| 74 | 74 | // register widget |
| 75 | 75 | $this->class_name = $options['class_name']; |
| 76 | 76 | |
@@ -79,60 +79,60 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | |
| 81 | 81 | // Fusion Builder (avada) support |
| 82 | - if ( function_exists( 'fusion_builder_map' ) ) { |
|
| 83 | - add_action( 'init', array( $this, 'register_fusion_element' ) ); |
|
| 82 | + if (function_exists('fusion_builder_map')) { |
|
| 83 | + add_action('init', array($this, 'register_fusion_element')); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | // register block |
| 87 | - if(empty($this->options['output_types']) || in_array('block',$this->options['output_types'])){ |
|
| 88 | - add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) ); |
|
| 87 | + if (empty($this->options['output_types']) || in_array('block', $this->options['output_types'])) { |
|
| 88 | + add_action('admin_enqueue_scripts', array($this, 'register_block')); |
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | // add the CSS and JS we need ONCE |
| 93 | 93 | global $sd_widget_scripts; |
| 94 | 94 | |
| 95 | - if ( ! $sd_widget_scripts ) { |
|
| 96 | - wp_add_inline_script( 'admin-widgets', $this->widget_js() ); |
|
| 97 | - wp_add_inline_script( 'customize-controls', $this->widget_js() ); |
|
| 98 | - wp_add_inline_style( 'widgets', $this->widget_css() ); |
|
| 95 | + if (!$sd_widget_scripts) { |
|
| 96 | + wp_add_inline_script('admin-widgets', $this->widget_js()); |
|
| 97 | + wp_add_inline_script('customize-controls', $this->widget_js()); |
|
| 98 | + wp_add_inline_style('widgets', $this->widget_css()); |
|
| 99 | 99 | |
| 100 | 100 | // maybe add elementor editor styles |
| 101 | - add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'elementor_editor_styles' ) ); |
|
| 101 | + add_action('elementor/editor/after_enqueue_styles', array($this, 'elementor_editor_styles')); |
|
| 102 | 102 | |
| 103 | 103 | $sd_widget_scripts = true; |
| 104 | 104 | |
| 105 | 105 | // add shortcode insert button once |
| 106 | - add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) ); |
|
| 106 | + add_action('media_buttons', array($this, 'shortcode_insert_button')); |
|
| 107 | 107 | // generatepress theme sections compatibility |
| 108 | - if ( function_exists( 'generate_sections_sections_metabox' ) ) { |
|
| 109 | - add_action( 'generate_sections_metabox', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 108 | + if (function_exists('generate_sections_sections_metabox')) { |
|
| 109 | + add_action('generate_sections_metabox', array($this, 'shortcode_insert_button_script')); |
|
| 110 | 110 | } |
| 111 | 111 | /* Load script on Divi theme builder page */ |
| 112 | - if ( function_exists( 'et_builder_is_tb_admin_screen' ) && et_builder_is_tb_admin_screen() ) { |
|
| 112 | + if (function_exists('et_builder_is_tb_admin_screen') && et_builder_is_tb_admin_screen()) { |
|
| 113 | 113 | add_thickbox(); |
| 114 | - add_action( 'admin_footer', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 114 | + add_action('admin_footer', array($this, 'shortcode_insert_button_script')); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - if ( $this->is_preview() ) { |
|
| 118 | - add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 117 | + if ($this->is_preview()) { |
|
| 118 | + add_action('wp_footer', array($this, 'shortcode_insert_button_script')); |
|
| 119 | 119 | // this makes the insert button work for elementor |
| 120 | - add_action( 'elementor/editor/after_enqueue_scripts', array( |
|
| 120 | + add_action('elementor/editor/after_enqueue_scripts', array( |
|
| 121 | 121 | $this, |
| 122 | 122 | 'shortcode_insert_button_script' |
| 123 | - ) ); // for elementor |
|
| 123 | + )); // for elementor |
|
| 124 | 124 | } |
| 125 | 125 | // this makes the insert button work for cornerstone |
| 126 | - add_action( 'wp_print_footer_scripts', array( __CLASS__, 'maybe_cornerstone_builder' ) ); |
|
| 126 | + add_action('wp_print_footer_scripts', array(__CLASS__, 'maybe_cornerstone_builder')); |
|
| 127 | 127 | |
| 128 | - add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) ); |
|
| 129 | - add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) ); |
|
| 128 | + add_action('wp_ajax_super_duper_get_widget_settings', array(__CLASS__, 'get_widget_settings')); |
|
| 129 | + add_action('wp_ajax_super_duper_get_picker', array(__CLASS__, 'get_picker')); |
|
| 130 | 130 | |
| 131 | 131 | // add generator text to admin head |
| 132 | - add_action( 'admin_head', array( $this, 'generator' ) ); |
|
| 132 | + add_action('admin_head', array($this, 'generator')); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - do_action( 'wp_super_duper_widget_init', $options, $this ); |
|
| 135 | + do_action('wp_super_duper_widget_init', $options, $this); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /** |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | * @return void |
| 141 | 141 | */ |
| 142 | 142 | public function _register() { |
| 143 | - if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){ |
|
| 143 | + if (empty($this->options['output_types']) || in_array('widget', $this->options['output_types'])) { |
|
| 144 | 144 | parent::_register(); |
| 145 | 145 | } |
| 146 | 146 | } |
@@ -149,14 +149,14 @@ discard block |
||
| 149 | 149 | * Add our widget CSS to elementor editor. |
| 150 | 150 | */ |
| 151 | 151 | public function elementor_editor_styles() { |
| 152 | - wp_add_inline_style( 'elementor-editor', $this->widget_css( false ) ); |
|
| 152 | + wp_add_inline_style('elementor-editor', $this->widget_css(false)); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | public function register_fusion_element() { |
| 156 | 156 | |
| 157 | 157 | $options = $this->options; |
| 158 | 158 | |
| 159 | - if ( $this->base_id ) { |
|
| 159 | + if ($this->base_id) { |
|
| 160 | 160 | |
| 161 | 161 | $params = $this->get_fusion_params(); |
| 162 | 162 | |
@@ -167,11 +167,11 @@ discard block |
||
| 167 | 167 | 'allow_generator' => true, |
| 168 | 168 | ); |
| 169 | 169 | |
| 170 | - if ( ! empty( $params ) ) { |
|
| 170 | + if (!empty($params)) { |
|
| 171 | 171 | $args['params'] = $params; |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - fusion_builder_map( $args ); |
|
| 174 | + fusion_builder_map($args); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | } |
@@ -180,8 +180,8 @@ discard block |
||
| 180 | 180 | $params = array(); |
| 181 | 181 | $arguments = $this->get_arguments(); |
| 182 | 182 | |
| 183 | - if ( ! empty( $arguments ) ) { |
|
| 184 | - foreach ( $arguments as $key => $val ) { |
|
| 183 | + if (!empty($arguments)) { |
|
| 184 | + foreach ($arguments as $key => $val) { |
|
| 185 | 185 | $param = array(); |
| 186 | 186 | // type |
| 187 | 187 | $param['type'] = str_replace( |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | $val['type'] ); |
| 204 | 204 | |
| 205 | 205 | // multiselect |
| 206 | - if ( $val['type'] == 'multiselect' || ( ( $param['type'] == 'select' || $val['type'] == 'select' ) && ! empty( $val['multiple'] ) ) ) { |
|
| 206 | + if ($val['type'] == 'multiselect' || (($param['type'] == 'select' || $val['type'] == 'select') && !empty($val['multiple']))) { |
|
| 207 | 207 | $param['type'] = 'multiple_select'; |
| 208 | 208 | $param['multiple'] = true; |
| 209 | 209 | } |
@@ -212,29 +212,29 @@ discard block |
||
| 212 | 212 | $param['heading'] = $val['title']; |
| 213 | 213 | |
| 214 | 214 | // description |
| 215 | - $param['description'] = isset( $val['desc'] ) ? $val['desc'] : ''; |
|
| 215 | + $param['description'] = isset($val['desc']) ? $val['desc'] : ''; |
|
| 216 | 216 | |
| 217 | 217 | // param_name |
| 218 | 218 | $param['param_name'] = $key; |
| 219 | 219 | |
| 220 | 220 | // Default |
| 221 | - $param['default'] = isset( $val['default'] ) ? $val['default'] : ''; |
|
| 221 | + $param['default'] = isset($val['default']) ? $val['default'] : ''; |
|
| 222 | 222 | |
| 223 | 223 | // Group |
| 224 | - if ( isset( $val['group'] ) ) { |
|
| 224 | + if (isset($val['group'])) { |
|
| 225 | 225 | $param['group'] = $val['group']; |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | // value |
| 229 | - if ( $val['type'] == 'checkbox' ) { |
|
| 230 | - if ( isset( $val['default'] ) && $val['default'] == '0' ) { |
|
| 231 | - unset( $param['default'] ); |
|
| 229 | + if ($val['type'] == 'checkbox') { |
|
| 230 | + if (isset($val['default']) && $val['default'] == '0') { |
|
| 231 | + unset($param['default']); |
|
| 232 | 232 | } |
| 233 | - $param['value'] = array( '' => __( "No" ), '1' => __( "Yes" ) ); |
|
| 234 | - } elseif ( $param['type'] == 'select' || $param['type'] == 'multiple_select' ) { |
|
| 235 | - $param['value'] = isset( $val['options'] ) ? $val['options'] : array(); |
|
| 233 | + $param['value'] = array('' => __("No"), '1' => __("Yes")); |
|
| 234 | + } elseif ($param['type'] == 'select' || $param['type'] == 'multiple_select') { |
|
| 235 | + $param['value'] = isset($val['options']) ? $val['options'] : array(); |
|
| 236 | 236 | } else { |
| 237 | - $param['value'] = isset( $val['default'] ) ? $val['default'] : ''; |
|
| 237 | + $param['value'] = isset($val['default']) ? $val['default'] : ''; |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | // setup the param |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | * Maybe insert the shortcode inserter button in the footer if we are in the cornerstone builder |
| 252 | 252 | */ |
| 253 | 253 | public static function maybe_cornerstone_builder() { |
| 254 | - if ( did_action( 'cornerstone_before_boot_app' ) ) { |
|
| 254 | + if (did_action('cornerstone_before_boot_app')) { |
|
| 255 | 255 | self::shortcode_insert_button_script(); |
| 256 | 256 | } |
| 257 | 257 | } |
@@ -263,12 +263,12 @@ discard block |
||
| 263 | 263 | * |
| 264 | 264 | * @return string |
| 265 | 265 | */ |
| 266 | - public static function get_picker( $editor_id = '' ) { |
|
| 266 | + public static function get_picker($editor_id = '') { |
|
| 267 | 267 | |
| 268 | 268 | ob_start(); |
| 269 | - if ( isset( $_POST['editor_id'] ) ) { |
|
| 270 | - $editor_id = esc_attr( $_POST['editor_id'] ); |
|
| 271 | - } elseif ( isset( $_REQUEST['et_fb'] ) ) { |
|
| 269 | + if (isset($_POST['editor_id'])) { |
|
| 270 | + $editor_id = esc_attr($_POST['editor_id']); |
|
| 271 | + } elseif (isset($_REQUEST['et_fb'])) { |
|
| 272 | 272 | $editor_id = 'main_content_content_vb_tiny_mce'; |
| 273 | 273 | } |
| 274 | 274 | |
@@ -279,14 +279,14 @@ discard block |
||
| 279 | 279 | |
| 280 | 280 | <div class="sd-shortcode-left-wrap"> |
| 281 | 281 | <?php |
| 282 | - ksort( $sd_widgets ); |
|
| 282 | + ksort($sd_widgets); |
|
| 283 | 283 | // print_r($sd_widgets);exit; |
| 284 | - if ( ! empty( $sd_widgets ) ) { |
|
| 284 | + if (!empty($sd_widgets)) { |
|
| 285 | 285 | echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">'; |
| 286 | - echo "<option>" . __( 'Select shortcode' ) . "</option>"; |
|
| 287 | - foreach ( $sd_widgets as $shortcode => $class ) { |
|
| 288 | - if(!empty($class['output_types']) && !in_array('shortcode', $class['output_types'])){ continue; } |
|
| 289 | - echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>"; |
|
| 286 | + echo "<option>" . __('Select shortcode') . "</option>"; |
|
| 287 | + foreach ($sd_widgets as $shortcode => $class) { |
|
| 288 | + if (!empty($class['output_types']) && !in_array('shortcode', $class['output_types'])) { continue; } |
|
| 289 | + echo "<option value='" . esc_attr($shortcode) . "'>" . esc_attr($shortcode) . " (" . esc_attr($class['name']) . ")</option>"; |
|
| 290 | 290 | } |
| 291 | 291 | echo "</select>"; |
| 292 | 292 | |
@@ -299,37 +299,37 @@ discard block |
||
| 299 | 299 | <div class="sd-shortcode-right-wrap"> |
| 300 | 300 | <textarea id='sd-shortcode-output' disabled></textarea> |
| 301 | 301 | <div id='sd-shortcode-output-actions'> |
| 302 | - <?php if ( $editor_id != '' ) { ?> |
|
| 302 | + <?php if ($editor_id != '') { ?> |
|
| 303 | 303 | <button class="button sd-insert-shortcode-button" |
| 304 | - onclick="sd_insert_shortcode(<?php if ( ! empty( $editor_id ) ) { |
|
| 304 | + onclick="sd_insert_shortcode(<?php if (!empty($editor_id)) { |
|
| 305 | 305 | echo "'" . $editor_id . "'"; |
| 306 | - } ?>)"><?php _e( 'Insert shortcode' ); ?></button> |
|
| 306 | + } ?>)"><?php _e('Insert shortcode'); ?></button> |
|
| 307 | 307 | <?php } ?> |
| 308 | 308 | <button class="button" |
| 309 | - onclick="sd_copy_to_clipboard()"><?php _e( 'Copy shortcode' ); ?></button> |
|
| 309 | + onclick="sd_copy_to_clipboard()"><?php _e('Copy shortcode'); ?></button> |
|
| 310 | 310 | </div> |
| 311 | 311 | </div> |
| 312 | 312 | <?php |
| 313 | 313 | |
| 314 | 314 | $html = ob_get_clean(); |
| 315 | 315 | |
| 316 | - if ( wp_doing_ajax() ) { |
|
| 316 | + if (wp_doing_ajax()) { |
|
| 317 | 317 | echo $html; |
| 318 | 318 | $should_die = true; |
| 319 | 319 | |
| 320 | 320 | // some builder get the editor via ajax so we should not die on those occasions |
| 321 | 321 | $dont_die = array( |
| 322 | - 'parent_tag',// WP Bakery |
|
| 322 | + 'parent_tag', // WP Bakery |
|
| 323 | 323 | 'avia_request' // enfold |
| 324 | 324 | ); |
| 325 | 325 | |
| 326 | - foreach ( $dont_die as $request ) { |
|
| 327 | - if ( isset( $_REQUEST[ $request ] ) ) { |
|
| 326 | + foreach ($dont_die as $request) { |
|
| 327 | + if (isset($_REQUEST[$request])) { |
|
| 328 | 328 | $should_die = false; |
| 329 | 329 | } |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | - if ( $should_die ) { |
|
| 332 | + if ($should_die) { |
|
| 333 | 333 | wp_die(); |
| 334 | 334 | } |
| 335 | 335 | |
@@ -356,16 +356,16 @@ discard block |
||
| 356 | 356 | public static function get_widget_settings() { |
| 357 | 357 | global $sd_widgets; |
| 358 | 358 | |
| 359 | - $shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : ''; |
|
| 360 | - if ( ! $shortcode ) { |
|
| 359 | + $shortcode = isset($_REQUEST['shortcode']) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes($_REQUEST['shortcode']) : ''; |
|
| 360 | + if (!$shortcode) { |
|
| 361 | 361 | wp_die(); |
| 362 | 362 | } |
| 363 | - $widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : ''; |
|
| 364 | - if ( ! $widget_args ) { |
|
| 363 | + $widget_args = isset($sd_widgets[$shortcode]) ? $sd_widgets[$shortcode] : ''; |
|
| 364 | + if (!$widget_args) { |
|
| 365 | 365 | wp_die(); |
| 366 | 366 | } |
| 367 | - $class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : ''; |
|
| 368 | - if ( ! $class_name ) { |
|
| 367 | + $class_name = isset($widget_args['class_name']) && $widget_args['class_name'] ? $widget_args['class_name'] : ''; |
|
| 368 | + if (!$class_name) { |
|
| 369 | 369 | wp_die(); |
| 370 | 370 | } |
| 371 | 371 | |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | $widget = new $class_name; |
| 374 | 374 | |
| 375 | 375 | ob_start(); |
| 376 | - $widget->form( array() ); |
|
| 376 | + $widget->form(array()); |
|
| 377 | 377 | $form = ob_get_clean(); |
| 378 | 378 | echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>"; |
| 379 | 379 | echo "<style>" . $widget->widget_css() . "</style>"; |
@@ -392,9 +392,9 @@ discard block |
||
| 392 | 392 | *@since 1.0.0 |
| 393 | 393 | * |
| 394 | 394 | */ |
| 395 | - public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) { |
|
| 395 | + public static function shortcode_insert_button($editor_id = '', $insert_shortcode_function = '') { |
|
| 396 | 396 | global $sd_widgets, $shortcode_insert_button_once; |
| 397 | - if ( $shortcode_insert_button_once ) { |
|
| 397 | + if ($shortcode_insert_button_once) { |
|
| 398 | 398 | return; |
| 399 | 399 | } |
| 400 | 400 | add_thickbox(); |
@@ -404,21 +404,21 @@ discard block |
||
| 404 | 404 | * Cornerstone makes us play dirty tricks :/ |
| 405 | 405 | * All media_buttons are removed via JS unless they are two specific id's so we wrap our content in this ID so it is not removed. |
| 406 | 406 | */ |
| 407 | - if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) { |
|
| 407 | + if (function_exists('cornerstone_plugin_init') && !is_admin()) { |
|
| 408 | 408 | echo '<span id="insert-media-button">'; |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | - echo self::shortcode_button( 'this', 'true' ); |
|
| 411 | + echo self::shortcode_button('this', 'true'); |
|
| 412 | 412 | |
| 413 | 413 | // see opening note |
| 414 | - if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) { |
|
| 414 | + if (function_exists('cornerstone_plugin_init') && !is_admin()) { |
|
| 415 | 415 | echo '</span>'; // end #insert-media-button |
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | // Add separate script for generatepress theme sections |
| 419 | - if ( function_exists( 'generate_sections_sections_metabox' ) && did_action( 'generate_sections_metabox' ) ) { |
|
| 419 | + if (function_exists('generate_sections_sections_metabox') && did_action('generate_sections_metabox')) { |
|
| 420 | 420 | } else { |
| 421 | - self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function ); |
|
| 421 | + self::shortcode_insert_button_script($editor_id, $insert_shortcode_function); |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | $shortcode_insert_button_once = true; |
@@ -432,12 +432,12 @@ discard block |
||
| 432 | 432 | * |
| 433 | 433 | * @return mixed |
| 434 | 434 | */ |
| 435 | - public static function shortcode_button( $id = '', $search_for_id = '' ) { |
|
| 435 | + public static function shortcode_button($id = '', $search_for_id = '') { |
|
| 436 | 436 | ob_start(); |
| 437 | 437 | ?> |
| 438 | 438 | <span class="sd-lable-shortcode-inserter"> |
| 439 | 439 | <a onclick="sd_ajax_get_picker(<?php echo $id; |
| 440 | - if ( $search_for_id ) { |
|
| 440 | + if ($search_for_id) { |
|
| 441 | 441 | echo "," . $search_for_id; |
| 442 | 442 | } ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed" |
| 443 | 443 | class="thickbox button super-duper-content-open" title="Add Shortcode"> |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | $html = ob_get_clean(); |
| 454 | 454 | |
| 455 | 455 | // remove line breaks so we can use it in js |
| 456 | - return preg_replace( "/\r|\n/", "", trim( $html ) ); |
|
| 456 | + return preg_replace("/\r|\n/", "", trim($html)); |
|
| 457 | 457 | } |
| 458 | 458 | |
| 459 | 459 | /** |
@@ -511,7 +511,7 @@ discard block |
||
| 511 | 511 | jQuery($this).data('sd-widget-enabled', true); |
| 512 | 512 | } |
| 513 | 513 | |
| 514 | - var $button = '<button title="<?php _e( 'Advanced Settings' );?>" class="button button-primary right sd-advanced-button" onclick="sd_so_toggle_advanced(this);return false;"><i class="fas fa-sliders-h" aria-hidden="true"></i></button>'; |
|
| 514 | + var $button = '<button title="<?php _e('Advanced Settings'); ?>" class="button button-primary right sd-advanced-button" onclick="sd_so_toggle_advanced(this);return false;"><i class="fas fa-sliders-h" aria-hidden="true"></i></button>'; |
|
| 515 | 515 | var form = jQuery($this).parents('' + $selector + ''); |
| 516 | 516 | |
| 517 | 517 | if (jQuery($this).val() == '1' && jQuery(form).find('.sd-advanced-button').length == 0) { |
@@ -546,10 +546,10 @@ discard block |
||
| 546 | 546 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 547 | 547 | */ |
| 548 | 548 | |
| 549 | - return str_replace( array( |
|
| 549 | + return str_replace(array( |
|
| 550 | 550 | '<script>', |
| 551 | 551 | '</script>' |
| 552 | - ), '', $output ); |
|
| 552 | + ), '', $output); |
|
| 553 | 553 | } |
| 554 | 554 | |
| 555 | 555 | /** |
@@ -561,7 +561,7 @@ discard block |
||
| 561 | 561 | *@since 1.0.6 |
| 562 | 562 | * |
| 563 | 563 | */ |
| 564 | - public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) { |
|
| 564 | + public static function shortcode_insert_button_script($editor_id = '', $insert_shortcode_function = '') { |
|
| 565 | 565 | ?> |
| 566 | 566 | <style> |
| 567 | 567 | .sd-shortcode-left-wrap { |
@@ -680,25 +680,25 @@ discard block |
||
| 680 | 680 | width: 100%; |
| 681 | 681 | } |
| 682 | 682 | |
| 683 | - <?php if ( function_exists( 'generate_sections_sections_metabox' ) ) { ?> |
|
| 683 | + <?php if (function_exists('generate_sections_sections_metabox')) { ?> |
|
| 684 | 684 | .generate-sections-modal #custom-media-buttons > .sd-lable-shortcode-inserter { |
| 685 | 685 | display: inline; |
| 686 | 686 | } |
| 687 | 687 | <?php } ?> |
| 688 | - <?php if ( function_exists( 'et_builder_is_tb_admin_screen' ) && et_builder_is_tb_admin_screen() ) { ?> |
|
| 688 | + <?php if (function_exists('et_builder_is_tb_admin_screen') && et_builder_is_tb_admin_screen()) { ?> |
|
| 689 | 689 | body.divi_page_et_theme_builder div#TB_window.gd-tb-window{z-index:9999999} |
| 690 | 690 | <?php } ?> |
| 691 | 691 | </style> |
| 692 | 692 | <?php |
| 693 | - if ( class_exists( 'SiteOrigin_Panels' ) ) { |
|
| 693 | + if (class_exists('SiteOrigin_Panels')) { |
|
| 694 | 694 | echo "<script>" . self::siteorigin_js() . "</script>"; |
| 695 | 695 | } |
| 696 | 696 | ?> |
| 697 | 697 | <script> |
| 698 | 698 | <?php |
| 699 | - if(! empty( $insert_shortcode_function )){ |
|
| 699 | + if (!empty($insert_shortcode_function)) { |
|
| 700 | 700 | echo $insert_shortcode_function; |
| 701 | - }else{ |
|
| 701 | + } else { |
|
| 702 | 702 | |
| 703 | 703 | /** |
| 704 | 704 | * Function for super duper insert shortcode. |
@@ -711,9 +711,9 @@ discard block |
||
| 711 | 711 | if ($shortcode) { |
| 712 | 712 | if (!$editor_id) { |
| 713 | 713 | <?php |
| 714 | - if ( isset( $_REQUEST['et_fb'] ) ) { |
|
| 714 | + if (isset($_REQUEST['et_fb'])) { |
|
| 715 | 715 | echo '$editor_id = "#main_content_content_vb_tiny_mce";'; |
| 716 | - } elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) { |
|
| 716 | + } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor') { |
|
| 717 | 717 | echo '$editor_id = "#elementor-controls .wp-editor-container textarea";'; |
| 718 | 718 | } else { |
| 719 | 719 | echo '$editor_id = "#wp-content-editor-container textarea";'; |
@@ -798,11 +798,11 @@ discard block |
||
| 798 | 798 | 'shortcode': $short_code, |
| 799 | 799 | 'attributes': 123, |
| 800 | 800 | 'post_id': 321, |
| 801 | - '_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>' |
|
| 801 | + '_ajax_nonce': '<?php echo wp_create_nonce('super_duper_output_shortcode'); ?>' |
|
| 802 | 802 | }; |
| 803 | 803 | |
| 804 | 804 | if (typeof ajaxurl === 'undefined') { |
| 805 | - var ajaxurl = "<?php echo admin_url( 'admin-ajax.php' );?>"; |
|
| 805 | + var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>"; |
|
| 806 | 806 | } |
| 807 | 807 | |
| 808 | 808 | jQuery.post(ajaxurl, data, function (response) { |
@@ -1011,11 +1011,11 @@ discard block |
||
| 1011 | 1011 | var data = { |
| 1012 | 1012 | 'action': 'super_duper_get_picker', |
| 1013 | 1013 | 'editor_id': $id, |
| 1014 | - '_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_picker' );?>' |
|
| 1014 | + '_ajax_nonce': '<?php echo wp_create_nonce('super_duper_picker'); ?>' |
|
| 1015 | 1015 | }; |
| 1016 | 1016 | |
| 1017 | 1017 | if (!ajaxurl) { |
| 1018 | - var ajaxurl = "<?php echo admin_url( 'admin-ajax.php' ); ?>"; |
|
| 1018 | + var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>"; |
|
| 1019 | 1019 | } |
| 1020 | 1020 | |
| 1021 | 1021 | jQuery.post(ajaxurl, data, function (response) { |
@@ -1037,9 +1037,9 @@ discard block |
||
| 1037 | 1037 | */ |
| 1038 | 1038 | function sd_shortcode_button($id) { |
| 1039 | 1039 | if ($id) { |
| 1040 | - return '<?php echo self::shortcode_button( "\\''+\$id+'\\'" );?>'; |
|
| 1040 | + return '<?php echo self::shortcode_button("\\''+\$id+'\\'"); ?>'; |
|
| 1041 | 1041 | } else { |
| 1042 | - return '<?php echo self::shortcode_button();?>'; |
|
| 1042 | + return '<?php echo self::shortcode_button(); ?>'; |
|
| 1043 | 1043 | } |
| 1044 | 1044 | } |
| 1045 | 1045 | |
@@ -1054,11 +1054,11 @@ discard block |
||
| 1054 | 1054 | * |
| 1055 | 1055 | * @return mixed |
| 1056 | 1056 | */ |
| 1057 | - public function widget_css( $advanced = true ) { |
|
| 1057 | + public function widget_css($advanced = true) { |
|
| 1058 | 1058 | ob_start(); |
| 1059 | 1059 | ?> |
| 1060 | 1060 | <style> |
| 1061 | - <?php if( $advanced ){ ?> |
|
| 1061 | + <?php if ($advanced) { ?> |
|
| 1062 | 1062 | .sd-advanced-setting { |
| 1063 | 1063 | display: none; |
| 1064 | 1064 | } |
@@ -1100,10 +1100,10 @@ discard block |
||
| 1100 | 1100 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1101 | 1101 | */ |
| 1102 | 1102 | |
| 1103 | - return str_replace( array( |
|
| 1103 | + return str_replace(array( |
|
| 1104 | 1104 | '<style>', |
| 1105 | 1105 | '</style>' |
| 1106 | - ), '', $output ); |
|
| 1106 | + ), '', $output); |
|
| 1107 | 1107 | } |
| 1108 | 1108 | |
| 1109 | 1109 | /** |
@@ -1170,7 +1170,7 @@ discard block |
||
| 1170 | 1170 | jQuery($this).data('sd-widget-enabled', true); |
| 1171 | 1171 | } |
| 1172 | 1172 | |
| 1173 | - var $button = '<button title="<?php _e( 'Advanced Settings' );?>" style="line-height: 28px;" class="button button-primary right sd-advanced-button" onclick="sd_toggle_advanced(this);return false;"><span class="dashicons dashicons-admin-settings" style="width: 28px;font-size: 28px;"></span></button>'; |
|
| 1173 | + var $button = '<button title="<?php _e('Advanced Settings'); ?>" style="line-height: 28px;" class="button button-primary right sd-advanced-button" onclick="sd_toggle_advanced(this);return false;"><span class="dashicons dashicons-admin-settings" style="width: 28px;font-size: 28px;"></span></button>'; |
|
| 1174 | 1174 | var form = jQuery($this).parents('' + $selector + ''); |
| 1175 | 1175 | |
| 1176 | 1176 | if (jQuery($this).val() == '1' && jQuery(form).find('.sd-advanced-button').length == 0) { |
@@ -1265,7 +1265,7 @@ discard block |
||
| 1265 | 1265 | }); |
| 1266 | 1266 | |
| 1267 | 1267 | } |
| 1268 | - <?php do_action( 'wp_super_duper_widget_js', $this ); ?> |
|
| 1268 | + <?php do_action('wp_super_duper_widget_js', $this); ?> |
|
| 1269 | 1269 | </script> |
| 1270 | 1270 | <?php |
| 1271 | 1271 | $output = ob_get_clean(); |
@@ -1274,10 +1274,10 @@ discard block |
||
| 1274 | 1274 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1275 | 1275 | */ |
| 1276 | 1276 | |
| 1277 | - return str_replace( array( |
|
| 1277 | + return str_replace(array( |
|
| 1278 | 1278 | '<script>', |
| 1279 | 1279 | '</script>' |
| 1280 | - ), '', $output ); |
|
| 1280 | + ), '', $output); |
|
| 1281 | 1281 | } |
| 1282 | 1282 | |
| 1283 | 1283 | |
@@ -1288,14 +1288,14 @@ discard block |
||
| 1288 | 1288 | * |
| 1289 | 1289 | * @return mixed |
| 1290 | 1290 | */ |
| 1291 | - private function add_name_from_key( $options, $arguments = false ) { |
|
| 1292 | - if ( ! empty( $options['arguments'] ) ) { |
|
| 1293 | - foreach ( $options['arguments'] as $key => $val ) { |
|
| 1294 | - $options['arguments'][ $key ]['name'] = $key; |
|
| 1291 | + private function add_name_from_key($options, $arguments = false) { |
|
| 1292 | + if (!empty($options['arguments'])) { |
|
| 1293 | + foreach ($options['arguments'] as $key => $val) { |
|
| 1294 | + $options['arguments'][$key]['name'] = $key; |
|
| 1295 | 1295 | } |
| 1296 | - } elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) { |
|
| 1297 | - foreach ( $options as $key => $val ) { |
|
| 1298 | - $options[ $key ]['name'] = $key; |
|
| 1296 | + } elseif ($arguments && is_array($options) && !empty($options)) { |
|
| 1297 | + foreach ($options as $key => $val) { |
|
| 1298 | + $options[$key]['name'] = $key; |
|
| 1299 | 1299 | } |
| 1300 | 1300 | } |
| 1301 | 1301 | |
@@ -1308,8 +1308,8 @@ discard block |
||
| 1308 | 1308 | * @since 1.0.0 |
| 1309 | 1309 | */ |
| 1310 | 1310 | public function register_shortcode() { |
| 1311 | - add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) ); |
|
| 1312 | - add_action( 'wp_ajax_super_duper_output_shortcode', array( $this, 'render_shortcode' ) ); |
|
| 1311 | + add_shortcode($this->base_id, array($this, 'shortcode_output')); |
|
| 1312 | + add_action('wp_ajax_super_duper_output_shortcode', array($this, 'render_shortcode')); |
|
| 1313 | 1313 | } |
| 1314 | 1314 | |
| 1315 | 1315 | /** |
@@ -1318,50 +1318,50 @@ discard block |
||
| 1318 | 1318 | * @since 1.0.0 |
| 1319 | 1319 | */ |
| 1320 | 1320 | public function render_shortcode() { |
| 1321 | - check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true ); |
|
| 1322 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 1321 | + check_ajax_referer('super_duper_output_shortcode', '_ajax_nonce', true); |
|
| 1322 | + if (!current_user_can('manage_options')) { |
|
| 1323 | 1323 | wp_die(); |
| 1324 | 1324 | } |
| 1325 | 1325 | |
| 1326 | 1326 | // we might need the $post value here so lets set it. |
| 1327 | - if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) { |
|
| 1328 | - $post_obj = get_post( absint( $_POST['post_id'] ) ); |
|
| 1329 | - if ( ! empty( $post_obj ) && empty( $post ) ) { |
|
| 1327 | + if (isset($_POST['post_id']) && $_POST['post_id']) { |
|
| 1328 | + $post_obj = get_post(absint($_POST['post_id'])); |
|
| 1329 | + if (!empty($post_obj) && empty($post)) { |
|
| 1330 | 1330 | global $post; |
| 1331 | 1331 | $post = $post_obj; |
| 1332 | 1332 | } |
| 1333 | 1333 | } |
| 1334 | 1334 | |
| 1335 | - if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) { |
|
| 1335 | + if (isset($_POST['shortcode']) && $_POST['shortcode']) { |
|
| 1336 | 1336 | $is_preview = $this->is_preview(); |
| 1337 | - $shortcode_name = sanitize_title_with_dashes( $_POST['shortcode'] ); |
|
| 1338 | - $attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array(); |
|
| 1337 | + $shortcode_name = sanitize_title_with_dashes($_POST['shortcode']); |
|
| 1338 | + $attributes_array = isset($_POST['attributes']) && $_POST['attributes'] ? $_POST['attributes'] : array(); |
|
| 1339 | 1339 | $attributes = ''; |
| 1340 | - if ( ! empty( $attributes_array ) ) { |
|
| 1341 | - foreach ( $attributes_array as $key => $value ) { |
|
| 1342 | - if ( is_array( $value ) ) { |
|
| 1343 | - $value = implode( ",", $value ); |
|
| 1340 | + if (!empty($attributes_array)) { |
|
| 1341 | + foreach ($attributes_array as $key => $value) { |
|
| 1342 | + if (is_array($value)) { |
|
| 1343 | + $value = implode(",", $value); |
|
| 1344 | 1344 | } |
| 1345 | 1345 | |
| 1346 | - if ( ! empty( $value ) ) { |
|
| 1347 | - $value = wp_unslash( $value ); |
|
| 1346 | + if (!empty($value)) { |
|
| 1347 | + $value = wp_unslash($value); |
|
| 1348 | 1348 | |
| 1349 | 1349 | // Encode [ and ]. |
| 1350 | - if ( $is_preview ) { |
|
| 1351 | - $value = $this->encode_shortcodes( $value ); |
|
| 1350 | + if ($is_preview) { |
|
| 1351 | + $value = $this->encode_shortcodes($value); |
|
| 1352 | 1352 | } |
| 1353 | 1353 | } |
| 1354 | - $attributes .= " " . sanitize_title_with_dashes( $key ) . "='" . esc_attr( $value ) . "' "; |
|
| 1354 | + $attributes .= " " . sanitize_title_with_dashes($key) . "='" . esc_attr($value) . "' "; |
|
| 1355 | 1355 | } |
| 1356 | 1356 | } |
| 1357 | 1357 | |
| 1358 | 1358 | $shortcode = "[" . $shortcode_name . " " . $attributes . "]"; |
| 1359 | 1359 | |
| 1360 | - $content = do_shortcode( $shortcode ); |
|
| 1360 | + $content = do_shortcode($shortcode); |
|
| 1361 | 1361 | |
| 1362 | 1362 | // Decode [ and ]. |
| 1363 | - if ( ! empty( $content ) && $is_preview ) { |
|
| 1364 | - $content = $this->decode_shortcodes( $content ); |
|
| 1363 | + if (!empty($content) && $is_preview) { |
|
| 1364 | + $content = $this->decode_shortcodes($content); |
|
| 1365 | 1365 | } |
| 1366 | 1366 | |
| 1367 | 1367 | echo $content; |
@@ -1377,21 +1377,21 @@ discard block |
||
| 1377 | 1377 | * |
| 1378 | 1378 | * @return string |
| 1379 | 1379 | */ |
| 1380 | - public function shortcode_output( $args = array(), $content = '' ) { |
|
| 1380 | + public function shortcode_output($args = array(), $content = '') { |
|
| 1381 | 1381 | $_instance = $args; |
| 1382 | 1382 | |
| 1383 | - $args = $this->argument_values( $args ); |
|
| 1383 | + $args = $this->argument_values($args); |
|
| 1384 | 1384 | |
| 1385 | 1385 | // add extra argument so we know its a output to gutenberg |
| 1386 | 1386 | //$args |
| 1387 | - $args = $this->string_to_bool( $args ); |
|
| 1387 | + $args = $this->string_to_bool($args); |
|
| 1388 | 1388 | |
| 1389 | 1389 | // if we have a enclosed shortcode we add it to the special `html` argument |
| 1390 | - if ( ! empty( $content ) ) { |
|
| 1390 | + if (!empty($content)) { |
|
| 1391 | 1391 | $args['html'] = $content; |
| 1392 | 1392 | } |
| 1393 | 1393 | |
| 1394 | - if ( ! $this->is_preview() ) { |
|
| 1394 | + if (!$this->is_preview()) { |
|
| 1395 | 1395 | /** |
| 1396 | 1396 | * Filters the settings for a particular widget args. |
| 1397 | 1397 | * |
@@ -1402,40 +1402,40 @@ discard block |
||
| 1402 | 1402 | *@since 1.0.28 |
| 1403 | 1403 | * |
| 1404 | 1404 | */ |
| 1405 | - $args = apply_filters( 'wp_super_duper_widget_display_callback', $args, $this, $_instance ); |
|
| 1405 | + $args = apply_filters('wp_super_duper_widget_display_callback', $args, $this, $_instance); |
|
| 1406 | 1406 | |
| 1407 | - if ( ! is_array( $args ) ) { |
|
| 1407 | + if (!is_array($args)) { |
|
| 1408 | 1408 | return $args; |
| 1409 | 1409 | } |
| 1410 | 1410 | } |
| 1411 | 1411 | |
| 1412 | - $class = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : ''; |
|
| 1413 | - $class .= " sdel-".$this->get_instance_hash(); |
|
| 1412 | + $class = isset($this->options['widget_ops']['classname']) ? esc_attr($this->options['widget_ops']['classname']) : ''; |
|
| 1413 | + $class .= " sdel-" . $this->get_instance_hash(); |
|
| 1414 | 1414 | |
| 1415 | - $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this ); |
|
| 1416 | - $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this ); |
|
| 1415 | + $class = apply_filters('wp_super_duper_div_classname', $class, $args, $this); |
|
| 1416 | + $class = apply_filters('wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this); |
|
| 1417 | 1417 | |
| 1418 | - $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this ); |
|
| 1419 | - $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this ); |
|
| 1418 | + $attrs = apply_filters('wp_super_duper_div_attrs', '', $args, $this); |
|
| 1419 | + $attrs = apply_filters('wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this); |
|
| 1420 | 1420 | |
| 1421 | 1421 | $shortcode_args = array(); |
| 1422 | 1422 | $output = ''; |
| 1423 | - $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false; |
|
| 1424 | - if ( isset( $args['no_wrap'] ) && $args['no_wrap'] ) { |
|
| 1423 | + $no_wrap = isset($this->options['no_wrap']) && $this->options['no_wrap'] ? true : false; |
|
| 1424 | + if (isset($args['no_wrap']) && $args['no_wrap']) { |
|
| 1425 | 1425 | $no_wrap = true; |
| 1426 | 1426 | } |
| 1427 | - $main_content = $this->output( $args, $shortcode_args, $content ); |
|
| 1428 | - if ( $main_content && ! $no_wrap ) { |
|
| 1427 | + $main_content = $this->output($args, $shortcode_args, $content); |
|
| 1428 | + if ($main_content && !$no_wrap) { |
|
| 1429 | 1429 | // wrap the shortcode in a div with the same class as the widget |
| 1430 | 1430 | $output .= '<div class="' . $class . '" ' . $attrs . '>'; |
| 1431 | - if ( ! empty( $args['title'] ) ) { |
|
| 1431 | + if (!empty($args['title'])) { |
|
| 1432 | 1432 | // if its a shortcode and there is a title try to grab the title wrappers |
| 1433 | - $shortcode_args = array( 'before_title' => '', 'after_title' => '' ); |
|
| 1434 | - if ( empty( $instance ) ) { |
|
| 1433 | + $shortcode_args = array('before_title' => '', 'after_title' => ''); |
|
| 1434 | + if (empty($instance)) { |
|
| 1435 | 1435 | global $wp_registered_sidebars; |
| 1436 | - if ( ! empty( $wp_registered_sidebars ) ) { |
|
| 1437 | - foreach ( $wp_registered_sidebars as $sidebar ) { |
|
| 1438 | - if ( ! empty( $sidebar['before_title'] ) ) { |
|
| 1436 | + if (!empty($wp_registered_sidebars)) { |
|
| 1437 | + foreach ($wp_registered_sidebars as $sidebar) { |
|
| 1438 | + if (!empty($sidebar['before_title'])) { |
|
| 1439 | 1439 | $shortcode_args['before_title'] = $sidebar['before_title']; |
| 1440 | 1440 | $shortcode_args['after_title'] = $sidebar['after_title']; |
| 1441 | 1441 | break; |
@@ -1443,20 +1443,20 @@ discard block |
||
| 1443 | 1443 | } |
| 1444 | 1444 | } |
| 1445 | 1445 | } |
| 1446 | - $output .= $this->output_title( $shortcode_args, $args ); |
|
| 1446 | + $output .= $this->output_title($shortcode_args, $args); |
|
| 1447 | 1447 | } |
| 1448 | 1448 | $output .= $main_content; |
| 1449 | 1449 | $output .= '</div>'; |
| 1450 | - } elseif ( $main_content && $no_wrap ) { |
|
| 1450 | + } elseif ($main_content && $no_wrap) { |
|
| 1451 | 1451 | $output .= $main_content; |
| 1452 | 1452 | } |
| 1453 | 1453 | |
| 1454 | 1454 | // if preview show a placeholder if empty |
| 1455 | - if ( $this->is_preview() && $output == '' ) { |
|
| 1456 | - $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" ); |
|
| 1455 | + if ($this->is_preview() && $output == '') { |
|
| 1456 | + $output = $this->preview_placeholder_text("{{" . $this->base_id . "}}"); |
|
| 1457 | 1457 | } |
| 1458 | 1458 | |
| 1459 | - return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this ); |
|
| 1459 | + return apply_filters('wp_super_duper_widget_output', $output, $args, $shortcode_args, $this); |
|
| 1460 | 1460 | } |
| 1461 | 1461 | |
| 1462 | 1462 | /** |
@@ -1466,8 +1466,8 @@ discard block |
||
| 1466 | 1466 | * |
| 1467 | 1467 | * @return string |
| 1468 | 1468 | */ |
| 1469 | - public function preview_placeholder_text( $name = '' ) { |
|
| 1470 | - return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf( __( 'Placeholder for: %s' ), $name ) . "</div>"; |
|
| 1469 | + public function preview_placeholder_text($name = '') { |
|
| 1470 | + return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf(__('Placeholder for: %s'), $name) . "</div>"; |
|
| 1471 | 1471 | } |
| 1472 | 1472 | |
| 1473 | 1473 | /** |
@@ -1477,13 +1477,13 @@ discard block |
||
| 1477 | 1477 | * |
| 1478 | 1478 | * @return mixed |
| 1479 | 1479 | */ |
| 1480 | - public function string_to_bool( $options ) { |
|
| 1480 | + public function string_to_bool($options) { |
|
| 1481 | 1481 | // convert bool strings to booleans |
| 1482 | - foreach ( $options as $key => $val ) { |
|
| 1483 | - if ( $val == 'false' ) { |
|
| 1484 | - $options[ $key ] = false; |
|
| 1485 | - } elseif ( $val == 'true' ) { |
|
| 1486 | - $options[ $key ] = true; |
|
| 1482 | + foreach ($options as $key => $val) { |
|
| 1483 | + if ($val == 'false') { |
|
| 1484 | + $options[$key] = false; |
|
| 1485 | + } elseif ($val == 'true') { |
|
| 1486 | + $options[$key] = true; |
|
| 1487 | 1487 | } |
| 1488 | 1488 | } |
| 1489 | 1489 | |
@@ -1499,26 +1499,26 @@ discard block |
||
| 1499 | 1499 | *@since 1.0.12 Don't set checkbox default value if the value is empty. |
| 1500 | 1500 | * |
| 1501 | 1501 | */ |
| 1502 | - public function argument_values( $instance ) { |
|
| 1502 | + public function argument_values($instance) { |
|
| 1503 | 1503 | $argument_values = array(); |
| 1504 | 1504 | |
| 1505 | 1505 | // set widget instance |
| 1506 | 1506 | $this->instance = $instance; |
| 1507 | 1507 | |
| 1508 | - if ( empty( $this->arguments ) ) { |
|
| 1508 | + if (empty($this->arguments)) { |
|
| 1509 | 1509 | $this->arguments = $this->get_arguments(); |
| 1510 | 1510 | } |
| 1511 | 1511 | |
| 1512 | - if ( ! empty( $this->arguments ) ) { |
|
| 1513 | - foreach ( $this->arguments as $key => $args ) { |
|
| 1512 | + if (!empty($this->arguments)) { |
|
| 1513 | + foreach ($this->arguments as $key => $args) { |
|
| 1514 | 1514 | // set the input name from the key |
| 1515 | 1515 | $args['name'] = $key; |
| 1516 | 1516 | // |
| 1517 | - $argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : ''; |
|
| 1518 | - if ( $args['type'] == 'checkbox' && $argument_values[ $key ] == '' ) { |
|
| 1517 | + $argument_values[$key] = isset($instance[$key]) ? $instance[$key] : ''; |
|
| 1518 | + if ($args['type'] == 'checkbox' && $argument_values[$key] == '') { |
|
| 1519 | 1519 | // don't set default for an empty checkbox |
| 1520 | - } elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) { |
|
| 1521 | - $argument_values[ $key ] = $args['default']; |
|
| 1520 | + } elseif ($argument_values[$key] == '' && isset($args['default'])) { |
|
| 1521 | + $argument_values[$key] = $args['default']; |
|
| 1522 | 1522 | } |
| 1523 | 1523 | } |
| 1524 | 1524 | } |
@@ -1545,12 +1545,12 @@ discard block |
||
| 1545 | 1545 | * |
| 1546 | 1546 | */ |
| 1547 | 1547 | public function get_arguments() { |
| 1548 | - if ( empty( $this->arguments ) ) { |
|
| 1548 | + if (empty($this->arguments)) { |
|
| 1549 | 1549 | $this->arguments = $this->set_arguments(); |
| 1550 | 1550 | } |
| 1551 | 1551 | |
| 1552 | - $this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance ); |
|
| 1553 | - $this->arguments = $this->add_name_from_key( $this->arguments, true ); |
|
| 1552 | + $this->arguments = apply_filters('wp_super_duper_arguments', $this->arguments, $this->options, $this->instance); |
|
| 1553 | + $this->arguments = $this->add_name_from_key($this->arguments, true); |
|
| 1554 | 1554 | |
| 1555 | 1555 | return $this->arguments; |
| 1556 | 1556 | } |
@@ -1562,7 +1562,7 @@ discard block |
||
| 1562 | 1562 | * @param array $widget_args |
| 1563 | 1563 | * @param string $content |
| 1564 | 1564 | */ |
| 1565 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 1565 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
| 1566 | 1566 | |
| 1567 | 1567 | } |
| 1568 | 1568 | |
@@ -1570,9 +1570,9 @@ discard block |
||
| 1570 | 1570 | * Add the dynamic block code inline when the wp-block in enqueued. |
| 1571 | 1571 | */ |
| 1572 | 1572 | public function register_block() { |
| 1573 | - wp_add_inline_script( 'wp-blocks', $this->block() ); |
|
| 1574 | - if ( class_exists( 'SiteOrigin_Panels' ) ) { |
|
| 1575 | - wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() ); |
|
| 1573 | + wp_add_inline_script('wp-blocks', $this->block()); |
|
| 1574 | + if (class_exists('SiteOrigin_Panels')) { |
|
| 1575 | + wp_add_inline_script('wp-blocks', $this->siteorigin_js()); |
|
| 1576 | 1576 | } |
| 1577 | 1577 | } |
| 1578 | 1578 | |
@@ -1586,9 +1586,9 @@ discard block |
||
| 1586 | 1586 | $show = false; |
| 1587 | 1587 | $arguments = $this->get_arguments(); |
| 1588 | 1588 | |
| 1589 | - if ( ! empty( $arguments ) ) { |
|
| 1590 | - foreach ( $arguments as $argument ) { |
|
| 1591 | - if ( isset( $argument['advanced'] ) && $argument['advanced'] ) { |
|
| 1589 | + if (!empty($arguments)) { |
|
| 1590 | + foreach ($arguments as $argument) { |
|
| 1591 | + if (isset($argument['advanced']) && $argument['advanced']) { |
|
| 1592 | 1592 | $show = true; |
| 1593 | 1593 | break; // no need to continue if we know we have it |
| 1594 | 1594 | } |
@@ -1606,19 +1606,19 @@ discard block |
||
| 1606 | 1606 | public function get_url() { |
| 1607 | 1607 | $url = $this->url; |
| 1608 | 1608 | |
| 1609 | - if ( ! $url ) { |
|
| 1610 | - $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) ); |
|
| 1611 | - $content_url = untrailingslashit( WP_CONTENT_URL ); |
|
| 1609 | + if (!$url) { |
|
| 1610 | + $content_dir = wp_normalize_path(untrailingslashit(WP_CONTENT_DIR)); |
|
| 1611 | + $content_url = untrailingslashit(WP_CONTENT_URL); |
|
| 1612 | 1612 | |
| 1613 | 1613 | // Replace http:// to https://. |
| 1614 | - if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) { |
|
| 1615 | - $content_url = str_replace( 'http://', 'https://', $content_url ); |
|
| 1614 | + if (strpos($content_url, 'http://') === 0 && strpos(plugins_url(), 'https://') === 0) { |
|
| 1615 | + $content_url = str_replace('http://', 'https://', $content_url); |
|
| 1616 | 1616 | } |
| 1617 | 1617 | |
| 1618 | 1618 | // Check if we are inside a plugin |
| 1619 | - $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
| 1620 | - $url = str_replace( $content_dir, $content_url, $file_dir ); |
|
| 1621 | - $url = trailingslashit( $url ); |
|
| 1619 | + $file_dir = str_replace("/includes", "", wp_normalize_path(dirname(__FILE__))); |
|
| 1620 | + $url = str_replace($content_dir, $content_url, $file_dir); |
|
| 1621 | + $url = trailingslashit($url); |
|
| 1622 | 1622 | $this->url = $url; |
| 1623 | 1623 | } |
| 1624 | 1624 | |
@@ -1634,15 +1634,15 @@ discard block |
||
| 1634 | 1634 | |
| 1635 | 1635 | $url = $this->url; |
| 1636 | 1636 | |
| 1637 | - if ( ! $url ) { |
|
| 1637 | + if (!$url) { |
|
| 1638 | 1638 | // check if we are inside a plugin |
| 1639 | - $file_dir = str_replace( "/includes", "", dirname( __FILE__ ) ); |
|
| 1639 | + $file_dir = str_replace("/includes", "", dirname(__FILE__)); |
|
| 1640 | 1640 | |
| 1641 | - $dir_parts = explode( "/wp-content/", $file_dir ); |
|
| 1642 | - $url_parts = explode( "/wp-content/", plugins_url() ); |
|
| 1641 | + $dir_parts = explode("/wp-content/", $file_dir); |
|
| 1642 | + $url_parts = explode("/wp-content/", plugins_url()); |
|
| 1643 | 1643 | |
| 1644 | - if ( ! empty( $url_parts[0] ) && ! empty( $dir_parts[1] ) ) { |
|
| 1645 | - $url = trailingslashit( $url_parts[0] . "/wp-content/" . $dir_parts[1] ); |
|
| 1644 | + if (!empty($url_parts[0]) && !empty($dir_parts[1])) { |
|
| 1645 | + $url = trailingslashit($url_parts[0] . "/wp-content/" . $dir_parts[1]); |
|
| 1646 | 1646 | $this->url = $url; |
| 1647 | 1647 | } |
| 1648 | 1648 | } |
@@ -1663,46 +1663,46 @@ discard block |
||
| 1663 | 1663 | * @return string |
| 1664 | 1664 | *@since 1.1.0 |
| 1665 | 1665 | */ |
| 1666 | - public function get_block_icon( $icon ) { |
|
| 1666 | + public function get_block_icon($icon) { |
|
| 1667 | 1667 | |
| 1668 | 1668 | // check if we have a Font Awesome icon |
| 1669 | 1669 | $fa_type = ''; |
| 1670 | - if ( substr( $icon, 0, 7 ) === "fas fa-" ) { |
|
| 1670 | + if (substr($icon, 0, 7) === "fas fa-") { |
|
| 1671 | 1671 | $fa_type = 'solid'; |
| 1672 | - } elseif ( substr( $icon, 0, 7 ) === "far fa-" ) { |
|
| 1672 | + } elseif (substr($icon, 0, 7) === "far fa-") { |
|
| 1673 | 1673 | $fa_type = 'regular'; |
| 1674 | - } elseif ( substr( $icon, 0, 7 ) === "fab fa-" ) { |
|
| 1674 | + } elseif (substr($icon, 0, 7) === "fab fa-") { |
|
| 1675 | 1675 | $fa_type = 'brands'; |
| 1676 | 1676 | } else { |
| 1677 | 1677 | $icon = "'" . $icon . "'"; |
| 1678 | 1678 | } |
| 1679 | 1679 | |
| 1680 | 1680 | // set the icon if we found one |
| 1681 | - if ( $fa_type ) { |
|
| 1682 | - $fa_icon = str_replace( array( "fas fa-", "far fa-", "fab fa-" ), "", $icon ); |
|
| 1681 | + if ($fa_type) { |
|
| 1682 | + $fa_icon = str_replace(array("fas fa-", "far fa-", "fab fa-"), "", $icon); |
|
| 1683 | 1683 | $icon = "el('svg',{width: 20, height: 20, viewBox: '0 0 20 20'},el('use', {'xlink:href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "','href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "'}))"; |
| 1684 | 1684 | } |
| 1685 | 1685 | |
| 1686 | 1686 | return $icon; |
| 1687 | 1687 | } |
| 1688 | 1688 | |
| 1689 | - public function group_arguments( $arguments ) { |
|
| 1689 | + public function group_arguments($arguments) { |
|
| 1690 | 1690 | // echo '###';print_r($arguments); |
| 1691 | - if ( ! empty( $arguments ) ) { |
|
| 1691 | + if (!empty($arguments)) { |
|
| 1692 | 1692 | $temp_arguments = array(); |
| 1693 | - $general = __( "General" ); |
|
| 1693 | + $general = __("General"); |
|
| 1694 | 1694 | $add_sections = false; |
| 1695 | - foreach ( $arguments as $key => $args ) { |
|
| 1696 | - if ( isset( $args['group'] ) ) { |
|
| 1697 | - $temp_arguments[ $args['group'] ][ $key ] = $args; |
|
| 1695 | + foreach ($arguments as $key => $args) { |
|
| 1696 | + if (isset($args['group'])) { |
|
| 1697 | + $temp_arguments[$args['group']][$key] = $args; |
|
| 1698 | 1698 | $add_sections = true; |
| 1699 | 1699 | } else { |
| 1700 | - $temp_arguments[ $general ][ $key ] = $args; |
|
| 1700 | + $temp_arguments[$general][$key] = $args; |
|
| 1701 | 1701 | } |
| 1702 | 1702 | } |
| 1703 | 1703 | |
| 1704 | 1704 | // only add sections if more than one |
| 1705 | - if ( $add_sections ) { |
|
| 1705 | + if ($add_sections) { |
|
| 1706 | 1706 | $arguments = $temp_arguments; |
| 1707 | 1707 | } |
| 1708 | 1708 | } |
@@ -1732,7 +1732,7 @@ discard block |
||
| 1732 | 1732 | <script> |
| 1733 | 1733 | |
| 1734 | 1734 | <?php |
| 1735 | - if(!$sd_is_js_functions_loaded){ |
|
| 1735 | + if (!$sd_is_js_functions_loaded) { |
|
| 1736 | 1736 | $sd_is_js_functions_loaded = true; |
| 1737 | 1737 | ?> |
| 1738 | 1738 | |
@@ -1904,7 +1904,7 @@ discard block |
||
| 1904 | 1904 | |
| 1905 | 1905 | // maybe use featured image. |
| 1906 | 1906 | if( $args['bg_image_use_featured'] !== undefined && $args['bg_image_use_featured'] ){ |
| 1907 | - $bg_image = '<?php echo $this->get_url();?>icons/placeholder.png'; |
|
| 1907 | + $bg_image = '<?php echo $this->get_url(); ?>icons/placeholder.png'; |
|
| 1908 | 1908 | } |
| 1909 | 1909 | |
| 1910 | 1910 | if( $bg_image !== undefined && $bg_image !== '' ){ |
@@ -2070,7 +2070,7 @@ discard block |
||
| 2070 | 2070 | } |
| 2071 | 2071 | |
| 2072 | 2072 | function sd_get_class_build_keys(){ |
| 2073 | - return <?php echo json_encode(sd_get_class_build_keys());?>; |
|
| 2073 | + return <?php echo json_encode(sd_get_class_build_keys()); ?>; |
|
| 2074 | 2074 | } |
| 2075 | 2075 | |
| 2076 | 2076 | <?php |
@@ -2078,7 +2078,7 @@ discard block |
||
| 2078 | 2078 | |
| 2079 | 2079 | } |
| 2080 | 2080 | |
| 2081 | - if(method_exists($this,'block_global_js')){ |
|
| 2081 | + if (method_exists($this, 'block_global_js')) { |
|
| 2082 | 2082 | echo $this->block_global_js(); |
| 2083 | 2083 | } |
| 2084 | 2084 | ?> |
@@ -2107,9 +2107,9 @@ discard block |
||
| 2107 | 2107 | var InnerBlocks = blockEditor.InnerBlocks; |
| 2108 | 2108 | |
| 2109 | 2109 | var term_query_type = ''; |
| 2110 | - var post_type_rest_slugs = <?php if(! empty( $this->arguments ) && isset($this->arguments['post_type']['onchange_rest']['values'])){echo "[".json_encode($this->arguments['post_type']['onchange_rest']['values'])."]";}else{echo "[]";} ?>; |
|
| 2111 | - const taxonomies_<?php echo str_replace("-","_", $this->id);?> = [{label: "Please wait", value: 0}]; |
|
| 2112 | - const sort_by_<?php echo str_replace("-","_", $this->id);?> = [{label: "Please wait", value: 0}]; |
|
| 2110 | + var post_type_rest_slugs = <?php if (!empty($this->arguments) && isset($this->arguments['post_type']['onchange_rest']['values'])) {echo "[" . json_encode($this->arguments['post_type']['onchange_rest']['values']) . "]"; } else {echo "[]"; } ?>; |
|
| 2111 | + const taxonomies_<?php echo str_replace("-", "_", $this->id); ?> = [{label: "Please wait", value: 0}]; |
|
| 2112 | + const sort_by_<?php echo str_replace("-", "_", $this->id); ?> = [{label: "Please wait", value: 0}]; |
|
| 2113 | 2113 | const MediaUpload = wp.blockEditor.MediaUpload; |
| 2114 | 2114 | |
| 2115 | 2115 | /** |
@@ -2124,20 +2124,20 @@ discard block |
||
| 2124 | 2124 | * @return {?WPBlock} The block, if it has been successfully |
| 2125 | 2125 | * registered; otherwise `undefined`. |
| 2126 | 2126 | */ |
| 2127 | - registerBlockType('<?php echo str_replace( "_", "-", sanitize_title_with_dashes( $this->options['textdomain'] ) . '/' . sanitize_title_with_dashes( $this->options['class_name'] ) ); ?>', { // Block name. Block names must be string that contains a namespace prefix. Example: my-plugin/my-custom-block. |
|
| 2127 | + registerBlockType('<?php echo str_replace("_", "-", sanitize_title_with_dashes($this->options['textdomain']) . '/' . sanitize_title_with_dashes($this->options['class_name'])); ?>', { // Block name. Block names must be string that contains a namespace prefix. Example: my-plugin/my-custom-block. |
|
| 2128 | 2128 | apiVersion: 2, |
| 2129 | - title: '<?php echo addslashes( $this->options['name'] ); ?>', // Block title. |
|
| 2130 | - description: '<?php echo addslashes( $this->options['widget_ops']['description'] )?>', // Block title. |
|
| 2131 | - icon: <?php echo $this->get_block_icon( $this->options['block-icon'] );?>,//'<?php echo isset( $this->options['block-icon'] ) ? esc_attr( $this->options['block-icon'] ) : 'shield-alt';?>', // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/. |
|
| 2129 | + title: '<?php echo addslashes($this->options['name']); ?>', // Block title. |
|
| 2130 | + description: '<?php echo addslashes($this->options['widget_ops']['description'])?>', // Block title. |
|
| 2131 | + icon: <?php echo $this->get_block_icon($this->options['block-icon']); ?>,//'<?php echo isset($this->options['block-icon']) ? esc_attr($this->options['block-icon']) : 'shield-alt'; ?>', // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/. |
|
| 2132 | 2132 | supports: { |
| 2133 | 2133 | <?php |
| 2134 | - if ( isset( $this->options['block-supports'] ) ) { |
|
| 2135 | - echo $this->array_to_attributes( $this->options['block-supports'] ); |
|
| 2134 | + if (isset($this->options['block-supports'])) { |
|
| 2135 | + echo $this->array_to_attributes($this->options['block-supports']); |
|
| 2136 | 2136 | } |
| 2137 | 2137 | ?> |
| 2138 | 2138 | }, |
| 2139 | 2139 | <?php |
| 2140 | - if ( isset( $this->options['block-label'] ) ) { |
|
| 2140 | + if (isset($this->options['block-label'])) { |
|
| 2141 | 2141 | ?> |
| 2142 | 2142 | __experimentalLabel( attributes, { context } ) { |
| 2143 | 2143 | return <?php echo $this->options['block-label']; ?>; |
@@ -2145,8 +2145,8 @@ discard block |
||
| 2145 | 2145 | <?php |
| 2146 | 2146 | } |
| 2147 | 2147 | ?> |
| 2148 | - category: '<?php echo isset( $this->options['block-category'] ) ? esc_attr( $this->options['block-category'] ) : 'common';?>', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed. |
|
| 2149 | - <?php if ( isset( $this->options['block-keywords'] ) ) { |
|
| 2148 | + category: '<?php echo isset($this->options['block-category']) ? esc_attr($this->options['block-category']) : 'common'; ?>', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed. |
|
| 2149 | + <?php if (isset($this->options['block-keywords'])) { |
|
| 2150 | 2150 | echo "keywords : " . $this->options['block-keywords'] . ","; |
| 2151 | 2151 | |
| 2152 | 2152 | // // block hover preview. |
@@ -2173,11 +2173,11 @@ discard block |
||
| 2173 | 2173 | } |
| 2174 | 2174 | |
| 2175 | 2175 | // maybe set no_wrap |
| 2176 | - $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false; |
|
| 2177 | - if ( isset( $this->arguments['no_wrap'] ) && $this->arguments['no_wrap'] ) { |
|
| 2176 | + $no_wrap = isset($this->options['no_wrap']) && $this->options['no_wrap'] ? true : false; |
|
| 2177 | + if (isset($this->arguments['no_wrap']) && $this->arguments['no_wrap']) { |
|
| 2178 | 2178 | $no_wrap = true; |
| 2179 | 2179 | } |
| 2180 | - if ( $no_wrap ) { |
|
| 2180 | + if ($no_wrap) { |
|
| 2181 | 2181 | $this->options['block-wrap'] = ''; |
| 2182 | 2182 | } |
| 2183 | 2183 | |
@@ -2191,10 +2191,10 @@ discard block |
||
| 2191 | 2191 | echo " html: false"; |
| 2192 | 2192 | echo "},";*/ |
| 2193 | 2193 | |
| 2194 | - if ( ! empty( $this->arguments ) ) { |
|
| 2194 | + if (!empty($this->arguments)) { |
|
| 2195 | 2195 | echo "attributes : {"; |
| 2196 | 2196 | |
| 2197 | - if ( $show_advanced ) { |
|
| 2197 | + if ($show_advanced) { |
|
| 2198 | 2198 | echo "show_advanced: {"; |
| 2199 | 2199 | echo " type: 'boolean',"; |
| 2200 | 2200 | echo " default: false,"; |
@@ -2202,56 +2202,56 @@ discard block |
||
| 2202 | 2202 | } |
| 2203 | 2203 | |
| 2204 | 2204 | // block wrap element |
| 2205 | - if ( ! empty( $this->options['block-wrap'] ) ) { //@todo we should validate this? |
|
| 2205 | + if (!empty($this->options['block-wrap'])) { //@todo we should validate this? |
|
| 2206 | 2206 | echo "block_wrap: {"; |
| 2207 | 2207 | echo " type: 'string',"; |
| 2208 | - echo " default: '" . esc_attr( $this->options['block-wrap'] ) . "',"; |
|
| 2208 | + echo " default: '" . esc_attr($this->options['block-wrap']) . "',"; |
|
| 2209 | 2209 | echo "},"; |
| 2210 | 2210 | } |
| 2211 | 2211 | |
| 2212 | 2212 | |
| 2213 | 2213 | |
| 2214 | - foreach ( $this->arguments as $key => $args ) { |
|
| 2214 | + foreach ($this->arguments as $key => $args) { |
|
| 2215 | 2215 | |
| 2216 | - if( $args['type'] == 'image' || $args['type'] == 'images' ){ |
|
| 2216 | + if ($args['type'] == 'image' || $args['type'] == 'images') { |
|
| 2217 | 2217 | $img_drag_drop = true; |
| 2218 | 2218 | } |
| 2219 | 2219 | |
| 2220 | 2220 | // set if we should show alignment |
| 2221 | - if ( $key == 'alignment' ) { |
|
| 2221 | + if ($key == 'alignment') { |
|
| 2222 | 2222 | $show_alignment = true; |
| 2223 | 2223 | } |
| 2224 | 2224 | |
| 2225 | 2225 | $extra = ''; |
| 2226 | 2226 | |
| 2227 | - if ( $args['type'] == 'notice' || $args['type'] == 'tab' ) { |
|
| 2227 | + if ($args['type'] == 'notice' || $args['type'] == 'tab') { |
|
| 2228 | 2228 | continue; |
| 2229 | 2229 | } |
| 2230 | - elseif ( $args['type'] == 'checkbox' ) { |
|
| 2230 | + elseif ($args['type'] == 'checkbox') { |
|
| 2231 | 2231 | $type = 'boolean'; |
| 2232 | - $default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false'; |
|
| 2233 | - } elseif ( $args['type'] == 'number' ) { |
|
| 2232 | + $default = isset($args['default']) && $args['default'] ? 'true' : 'false'; |
|
| 2233 | + } elseif ($args['type'] == 'number') { |
|
| 2234 | 2234 | $type = 'number'; |
| 2235 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2236 | - } elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) { |
|
| 2235 | + $default = isset($args['default']) ? "'" . $args['default'] . "'" : "''"; |
|
| 2236 | + } elseif ($args['type'] == 'select' && !empty($args['multiple'])) { |
|
| 2237 | 2237 | $type = 'array'; |
| 2238 | - if ( isset( $args['default'] ) && is_array( $args['default'] ) ) { |
|
| 2239 | - $default = ! empty( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]"; |
|
| 2238 | + if (isset($args['default']) && is_array($args['default'])) { |
|
| 2239 | + $default = !empty($args['default']) ? "['" . implode("','", $args['default']) . "']" : "[]"; |
|
| 2240 | 2240 | } else { |
| 2241 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2241 | + $default = isset($args['default']) ? "'" . $args['default'] . "'" : "''"; |
|
| 2242 | 2242 | } |
| 2243 | - } elseif ( $args['type'] == 'tagselect' ) { |
|
| 2243 | + } elseif ($args['type'] == 'tagselect') { |
|
| 2244 | 2244 | $type = 'array'; |
| 2245 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2246 | - } elseif ( $args['type'] == 'multiselect' ) { |
|
| 2245 | + $default = isset($args['default']) ? "'" . $args['default'] . "'" : "''"; |
|
| 2246 | + } elseif ($args['type'] == 'multiselect') { |
|
| 2247 | 2247 | $type = 'array'; |
| 2248 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2249 | - } elseif ( $args['type'] == 'image_xy' ) { |
|
| 2248 | + $default = isset($args['default']) ? "'" . $args['default'] . "'" : "''"; |
|
| 2249 | + } elseif ($args['type'] == 'image_xy') { |
|
| 2250 | 2250 | $type = 'object'; |
| 2251 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2252 | - } elseif ( $args['type'] == 'image' ) { |
|
| 2251 | + $default = isset($args['default']) ? "'" . $args['default'] . "'" : "''"; |
|
| 2252 | + } elseif ($args['type'] == 'image') { |
|
| 2253 | 2253 | $type = 'string'; |
| 2254 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2254 | + $default = isset($args['default']) ? "'" . $args['default'] . "'" : "''"; |
|
| 2255 | 2255 | |
| 2256 | 2256 | // add a field for ID |
| 2257 | 2257 | // echo $key . "_id : {"; |
@@ -2263,7 +2263,7 @@ discard block |
||
| 2263 | 2263 | |
| 2264 | 2264 | } else { |
| 2265 | 2265 | $type = !empty($args['hidden_type']) ? esc_attr($args['hidden_type']) : 'string'; |
| 2266 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 2266 | + $default = isset($args['default']) ? "'" . $args['default'] . "'" : "''"; |
|
| 2267 | 2267 | |
| 2268 | 2268 | } |
| 2269 | 2269 | echo $key . " : {"; |
@@ -2287,7 +2287,7 @@ discard block |
||
| 2287 | 2287 | |
| 2288 | 2288 | <?php |
| 2289 | 2289 | // only include the drag/drop functions if required. |
| 2290 | -if( $img_drag_drop ){ |
|
| 2290 | +if ($img_drag_drop) { |
|
| 2291 | 2291 | |
| 2292 | 2292 | ?> |
| 2293 | 2293 | |
@@ -2353,9 +2353,9 @@ discard block |
||
| 2353 | 2353 | } |
| 2354 | 2354 | |
| 2355 | 2355 | <?php |
| 2356 | - if(!empty($this->options['block-edit-raw'])) { |
|
| 2356 | + if (!empty($this->options['block-edit-raw'])) { |
|
| 2357 | 2357 | echo $this->options['block-edit-raw']; // strings have to be in single quotes, may cause issues |
| 2358 | - }else{ |
|
| 2358 | + } else { |
|
| 2359 | 2359 | ?> |
| 2360 | 2360 | |
| 2361 | 2361 | function hasSelectedInnerBlock(props) { |
@@ -2380,7 +2380,7 @@ discard block |
||
| 2380 | 2380 | var $value = ''; |
| 2381 | 2381 | <?php |
| 2382 | 2382 | // if we have a post_type and a category then link them |
| 2383 | - if( isset($this->arguments['post_type']) && isset($this->arguments['category']) && !empty($this->arguments['category']['post_type_linked']) ){ |
|
| 2383 | + if (isset($this->arguments['post_type']) && isset($this->arguments['category']) && !empty($this->arguments['category']['post_type_linked'])) { |
|
| 2384 | 2384 | ?> |
| 2385 | 2385 | if(typeof(prev_attributes[props.clientId]) != 'undefined' ){ |
| 2386 | 2386 | $pt = props.attributes.post_type; |
@@ -2396,13 +2396,13 @@ discard block |
||
| 2396 | 2396 | |
| 2397 | 2397 | // taxonomies |
| 2398 | 2398 | if( $value && 'post_type' in prev_attributes[props.clientId] && 'category' in prev_attributes[props.clientId] && run ){ |
| 2399 | - wp.apiFetch({path: "<?php if(isset($this->arguments['post_type']['onchange_rest']['path'])){echo $this->arguments['post_type']['onchange_rest']['path'];}else{'/wp/v2/"+$value+"/categories/?per_page=100';} ?>"}).then(terms => { |
|
| 2400 | - while (taxonomies_<?php echo str_replace("-","_", $this->id);?>.length) { |
|
| 2401 | - taxonomies_<?php echo str_replace("-","_", $this->id);?>.pop(); |
|
| 2399 | + wp.apiFetch({path: "<?php if (isset($this->arguments['post_type']['onchange_rest']['path'])) {echo $this->arguments['post_type']['onchange_rest']['path']; } else {'/wp/v2/"+$value+"/categories/?per_page=100'; } ?>"}).then(terms => { |
|
| 2400 | + while (taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.length) { |
|
| 2401 | + taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.pop(); |
|
| 2402 | 2402 | } |
| 2403 | - taxonomies_<?php echo str_replace("-","_", $this->id);?>.push({label: "All", value: 0}); |
|
| 2403 | + taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.push({label: "All", value: 0}); |
|
| 2404 | 2404 | jQuery.each( terms, function( key, val ) { |
| 2405 | - taxonomies_<?php echo str_replace("-","_", $this->id);?>.push({label: val.name, value: val.id}); |
|
| 2405 | + taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.push({label: val.name, value: val.id}); |
|
| 2406 | 2406 | }); |
| 2407 | 2407 | |
| 2408 | 2408 | // setting the value back and fourth fixes the no update issue that sometimes happens where it won't update the options. |
@@ -2410,7 +2410,7 @@ discard block |
||
| 2410 | 2410 | props.setAttributes({category: [0] }); |
| 2411 | 2411 | props.setAttributes({category: $old_cat_value }); |
| 2412 | 2412 | |
| 2413 | - return taxonomies_<?php echo str_replace("-","_", $this->id);?>; |
|
| 2413 | + return taxonomies_<?php echo str_replace("-", "_", $this->id); ?>; |
|
| 2414 | 2414 | }); |
| 2415 | 2415 | } |
| 2416 | 2416 | |
@@ -2422,12 +2422,12 @@ discard block |
||
| 2422 | 2422 | }; |
| 2423 | 2423 | jQuery.post(ajaxurl, data, function(response) { |
| 2424 | 2424 | response = JSON.parse(response); |
| 2425 | - while (sort_by_<?php echo str_replace("-","_", $this->id);?>.length) { |
|
| 2426 | - sort_by_<?php echo str_replace("-","_", $this->id);?>.pop(); |
|
| 2425 | + while (sort_by_<?php echo str_replace("-", "_", $this->id); ?>.length) { |
|
| 2426 | + sort_by_<?php echo str_replace("-", "_", $this->id); ?>.pop(); |
|
| 2427 | 2427 | } |
| 2428 | 2428 | |
| 2429 | 2429 | jQuery.each( response, function( key, val ) { |
| 2430 | - sort_by_<?php echo str_replace("-","_", $this->id);?>.push({label: val, value: key}); |
|
| 2430 | + sort_by_<?php echo str_replace("-", "_", $this->id); ?>.push({label: val, value: key}); |
|
| 2431 | 2431 | }); |
| 2432 | 2432 | |
| 2433 | 2433 | // setting the value back and fourth fixes the no update issue that sometimes happens where it won't update the options. |
@@ -2435,7 +2435,7 @@ discard block |
||
| 2435 | 2435 | props.setAttributes({sort_by: [0] }); |
| 2436 | 2436 | props.setAttributes({sort_by: $old_sort_by_value }); |
| 2437 | 2437 | |
| 2438 | - return sort_by_<?php echo str_replace("-","_", $this->id);?>; |
|
| 2438 | + return sort_by_<?php echo str_replace("-", "_", $this->id); ?>; |
|
| 2439 | 2439 | }); |
| 2440 | 2440 | |
| 2441 | 2441 | } |
@@ -2468,13 +2468,13 @@ discard block |
||
| 2468 | 2468 | |
| 2469 | 2469 | var data = { |
| 2470 | 2470 | 'action': 'super_duper_output_shortcode', |
| 2471 | - 'shortcode': '<?php echo $this->options['base_id'];?>', |
|
| 2471 | + 'shortcode': '<?php echo $this->options['base_id']; ?>', |
|
| 2472 | 2472 | 'attributes': props.attributes, |
| 2473 | 2473 | 'block_parent_name': parentBlocks.length ? parentBlocks[parentBlocks.length - 1].name : '', |
| 2474 | - 'post_id': <?php global $post; if ( isset( $post->ID ) ) { |
|
| 2474 | + 'post_id': <?php global $post; if (isset($post->ID)) { |
|
| 2475 | 2475 | echo $post->ID; |
| 2476 | - }else{echo '0';}?>, |
|
| 2477 | - '_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>' |
|
| 2476 | + } else {echo '0'; }?>, |
|
| 2477 | + '_ajax_nonce': '<?php echo wp_create_nonce('super_duper_output_shortcode'); ?>' |
|
| 2478 | 2478 | }; |
| 2479 | 2479 | |
| 2480 | 2480 | jQuery.post(ajaxurl, data, function (response) { |
@@ -2483,17 +2483,17 @@ discard block |
||
| 2483 | 2483 | |
| 2484 | 2484 | // if the content is empty then we place some placeholder text |
| 2485 | 2485 | if (env == '') { |
| 2486 | - env = "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" + "<?php _e( 'Placeholder for: ' );?>" + props.name + "</div>"; |
|
| 2486 | + env = "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" + "<?php _e('Placeholder for: '); ?>" + props.name + "</div>"; |
|
| 2487 | 2487 | } |
| 2488 | 2488 | |
| 2489 | 2489 | <?php |
| 2490 | - if(!empty($this->options['nested-block'])){ |
|
| 2490 | + if (!empty($this->options['nested-block'])) { |
|
| 2491 | 2491 | ?> |
| 2492 | 2492 | // props.setAttributes({content: env}); |
| 2493 | 2493 | is_fetching = false; |
| 2494 | 2494 | prev_attributes[props.clientId] = props.attributes; |
| 2495 | 2495 | <?php |
| 2496 | - }else{ |
|
| 2496 | + } else { |
|
| 2497 | 2497 | ?> |
| 2498 | 2498 | props.setAttributes({content: env}); |
| 2499 | 2499 | is_fetching = false; |
@@ -2518,8 +2518,8 @@ discard block |
||
| 2518 | 2518 | } |
| 2519 | 2519 | |
| 2520 | 2520 | <?php |
| 2521 | - if(!empty($this->options['block-edit-js'])) { |
|
| 2522 | - echo $this->options['block-edit-js'] ; // strings have to be in single quotes, may cause issues |
|
| 2521 | + if (!empty($this->options['block-edit-js'])) { |
|
| 2522 | + echo $this->options['block-edit-js']; // strings have to be in single quotes, may cause issues |
|
| 2523 | 2523 | } |
| 2524 | 2524 | |
| 2525 | 2525 | |
@@ -2532,7 +2532,7 @@ discard block |
||
| 2532 | 2532 | |
| 2533 | 2533 | el(wp.blockEditor.BlockControls, {key: 'controls'}, |
| 2534 | 2534 | |
| 2535 | - <?php if($show_alignment){?> |
|
| 2535 | + <?php if ($show_alignment) {?> |
|
| 2536 | 2536 | el( |
| 2537 | 2537 | wp.blockEditor.AlignmentToolbar, |
| 2538 | 2538 | { |
@@ -2550,9 +2550,9 @@ discard block |
||
| 2550 | 2550 | |
| 2551 | 2551 | <?php |
| 2552 | 2552 | |
| 2553 | - if(! empty( $this->arguments )){ |
|
| 2553 | + if (!empty($this->arguments)) { |
|
| 2554 | 2554 | |
| 2555 | - if ( $show_advanced ) { |
|
| 2555 | + if ($show_advanced) { |
|
| 2556 | 2556 | ?> |
| 2557 | 2557 | el('div', { |
| 2558 | 2558 | style: {'padding-left': '16px','padding-right': '16px'} |
@@ -2577,46 +2577,46 @@ discard block |
||
| 2577 | 2577 | |
| 2578 | 2578 | //echo '####'; |
| 2579 | 2579 | |
| 2580 | - $arguments = $this->group_arguments( $this->arguments ); |
|
| 2580 | + $arguments = $this->group_arguments($this->arguments); |
|
| 2581 | 2581 | //print_r($arguments ); exit; |
| 2582 | 2582 | // Do we have sections? |
| 2583 | 2583 | $has_sections = $arguments == $this->arguments ? false : true; |
| 2584 | 2584 | |
| 2585 | 2585 | |
| 2586 | - if($has_sections){ |
|
| 2586 | + if ($has_sections) { |
|
| 2587 | 2587 | $panel_count = 0; |
| 2588 | 2588 | $open_tab = ''; |
| 2589 | 2589 | |
| 2590 | 2590 | $open_tab_groups = array(); |
| 2591 | 2591 | $used_tabs = array(); |
| 2592 | - foreach($arguments as $key => $args){ |
|
| 2592 | + foreach ($arguments as $key => $args) { |
|
| 2593 | 2593 | |
| 2594 | 2594 | $close_tab = false; |
| 2595 | 2595 | $close_tabs = false; |
| 2596 | 2596 | |
| 2597 | - if(!empty($this->options['block_group_tabs'])) { |
|
| 2598 | - foreach($this->options['block_group_tabs'] as $tab_name => $tab_args){ |
|
| 2599 | - if(in_array($key,$tab_args['groups'])){ |
|
| 2597 | + if (!empty($this->options['block_group_tabs'])) { |
|
| 2598 | + foreach ($this->options['block_group_tabs'] as $tab_name => $tab_args) { |
|
| 2599 | + if (in_array($key, $tab_args['groups'])) { |
|
| 2600 | 2600 | |
| 2601 | 2601 | $open_tab_groups[] = $key; |
| 2602 | 2602 | |
| 2603 | - if($open_tab != $tab_name){ |
|
| 2603 | + if ($open_tab != $tab_name) { |
|
| 2604 | 2604 | $tab_args['tab']['tabs_open'] = $open_tab == '' ? true : false; |
| 2605 | 2605 | $tab_args['tab']['open'] = true; |
| 2606 | 2606 | |
| 2607 | - $this->block_tab_start( '', $tab_args ); |
|
| 2607 | + $this->block_tab_start('', $tab_args); |
|
| 2608 | 2608 | // echo '###open'.$tab_name;print_r($tab_args); |
| 2609 | 2609 | $open_tab = $tab_name; |
| 2610 | 2610 | $used_tabs[] = $tab_name; |
| 2611 | 2611 | } |
| 2612 | 2612 | |
| 2613 | - if($open_tab_groups == $tab_args['groups']){ |
|
| 2613 | + if ($open_tab_groups == $tab_args['groups']) { |
|
| 2614 | 2614 | //$open_tab = ''; |
| 2615 | 2615 | $close_tab = true; |
| 2616 | 2616 | $open_tab_groups = array(); |
| 2617 | 2617 | |
| 2618 | 2618 | // print_r(array_keys($this->options['block_group_tabs']));echo '####';print_r($used_tabs); |
| 2619 | - if($used_tabs == array_keys($this->options['block_group_tabs'])){ |
|
| 2619 | + if ($used_tabs == array_keys($this->options['block_group_tabs'])) { |
|
| 2620 | 2620 | // echo '@@@'; |
| 2621 | 2621 | $close_tabs = true; |
| 2622 | 2622 | } |
@@ -2632,8 +2632,8 @@ discard block |
||
| 2632 | 2632 | |
| 2633 | 2633 | ?> |
| 2634 | 2634 | el(wp.components.PanelBody, { |
| 2635 | - title: '<?php esc_attr_e( $key ); ?>', |
|
| 2636 | - initialOpen: <?php if ( $panel_count ) { |
|
| 2635 | + title: '<?php esc_attr_e($key); ?>', |
|
| 2636 | + initialOpen: <?php if ($panel_count) { |
|
| 2637 | 2637 | echo "false"; |
| 2638 | 2638 | } else { |
| 2639 | 2639 | echo "true"; |
@@ -2643,21 +2643,21 @@ discard block |
||
| 2643 | 2643 | |
| 2644 | 2644 | |
| 2645 | 2645 | |
| 2646 | - foreach ( $args as $k => $a ) { |
|
| 2646 | + foreach ($args as $k => $a) { |
|
| 2647 | 2647 | |
| 2648 | - $this->block_tab_start( $k, $a ); |
|
| 2649 | - $this->block_row_start( $k, $a ); |
|
| 2650 | - $this->build_block_arguments( $k, $a ); |
|
| 2651 | - $this->block_row_end( $k, $a ); |
|
| 2652 | - $this->block_tab_end( $k, $a ); |
|
| 2648 | + $this->block_tab_start($k, $a); |
|
| 2649 | + $this->block_row_start($k, $a); |
|
| 2650 | + $this->build_block_arguments($k, $a); |
|
| 2651 | + $this->block_row_end($k, $a); |
|
| 2652 | + $this->block_tab_end($k, $a); |
|
| 2653 | 2653 | } |
| 2654 | 2654 | ?> |
| 2655 | 2655 | ), |
| 2656 | 2656 | <?php |
| 2657 | - $panel_count ++; |
|
| 2657 | + $panel_count++; |
|
| 2658 | 2658 | |
| 2659 | 2659 | |
| 2660 | - if($close_tab || $close_tabs){ |
|
| 2660 | + if ($close_tab || $close_tabs) { |
|
| 2661 | 2661 | $tab_args = array( |
| 2662 | 2662 | 'tab' => array( |
| 2663 | 2663 | 'tabs_close' => $close_tabs, |
@@ -2665,24 +2665,24 @@ discard block |
||
| 2665 | 2665 | ) |
| 2666 | 2666 | |
| 2667 | 2667 | ); |
| 2668 | - $this->block_tab_end( '', $tab_args ); |
|
| 2668 | + $this->block_tab_end('', $tab_args); |
|
| 2669 | 2669 | // echo '###close'; print_r($tab_args); |
| 2670 | 2670 | $panel_count = 0; |
| 2671 | 2671 | } |
| 2672 | 2672 | // |
| 2673 | 2673 | |
| 2674 | 2674 | } |
| 2675 | - }else { |
|
| 2675 | + } else { |
|
| 2676 | 2676 | ?> |
| 2677 | 2677 | el(wp.components.PanelBody, { |
| 2678 | - title: '<?php esc_attr_e( "Settings" ); ?>', |
|
| 2678 | + title: '<?php esc_attr_e("Settings"); ?>', |
|
| 2679 | 2679 | initialOpen: true |
| 2680 | 2680 | }, |
| 2681 | 2681 | <?php |
| 2682 | - foreach ( $this->arguments as $key => $args ) { |
|
| 2683 | - $this->block_row_start( $key, $args ); |
|
| 2684 | - $this->build_block_arguments( $key, $args ); |
|
| 2685 | - $this->block_row_end( $key, $args ); |
|
| 2682 | + foreach ($this->arguments as $key => $args) { |
|
| 2683 | + $this->block_row_start($key, $args); |
|
| 2684 | + $this->build_block_arguments($key, $args); |
|
| 2685 | + $this->block_row_end($key, $args); |
|
| 2686 | 2686 | } |
| 2687 | 2687 | ?> |
| 2688 | 2688 | ), |
@@ -2696,11 +2696,11 @@ discard block |
||
| 2696 | 2696 | |
| 2697 | 2697 | <?php |
| 2698 | 2698 | // If the user sets block-output array then build it |
| 2699 | - if ( ! empty( $this->options['block-output'] ) ) { |
|
| 2700 | - $this->block_element( $this->options['block-output'] ); |
|
| 2701 | - }elseif(!empty($this->options['block-edit-return'])){ |
|
| 2699 | + if (!empty($this->options['block-output'])) { |
|
| 2700 | + $this->block_element($this->options['block-output']); |
|
| 2701 | + }elseif (!empty($this->options['block-edit-return'])) { |
|
| 2702 | 2702 | echo $this->options['block-edit-return']; |
| 2703 | - }else{ |
|
| 2703 | + } else { |
|
| 2704 | 2704 | // if no block-output is set then we try and get the shortcode html output via ajax. |
| 2705 | 2705 | ?> |
| 2706 | 2706 | el('div', wp.blockEditor.useBlockProps({ |
@@ -2725,22 +2725,22 @@ discard block |
||
| 2725 | 2725 | var align = ''; |
| 2726 | 2726 | |
| 2727 | 2727 | // build the shortcode. |
| 2728 | - var content = "[<?php echo $this->options['base_id'];?>"; |
|
| 2728 | + var content = "[<?php echo $this->options['base_id']; ?>"; |
|
| 2729 | 2729 | $html = ''; |
| 2730 | 2730 | <?php |
| 2731 | 2731 | |
| 2732 | - if(! empty( $this->arguments )){ |
|
| 2732 | + if (!empty($this->arguments)) { |
|
| 2733 | 2733 | |
| 2734 | - foreach($this->arguments as $key => $args){ |
|
| 2734 | + foreach ($this->arguments as $key => $args) { |
|
| 2735 | 2735 | // if($args['type']=='tabs'){continue;} |
| 2736 | 2736 | ?> |
| 2737 | - if (attr.hasOwnProperty("<?php echo esc_attr( $key );?>")) { |
|
| 2738 | - if ('<?php echo esc_attr( $key );?>' == 'html') { |
|
| 2739 | - $html = attr.<?php echo esc_attr( $key );?>; |
|
| 2740 | - } else if ('<?php echo esc_attr( $args['type'] );?>' == 'image_xy') { |
|
| 2741 | - content += " <?php echo esc_attr( $key );?>='{x:" + attr.<?php echo esc_attr( $key );?>.x + ",y:"+attr.<?php echo esc_attr( $key );?>.y +"}' "; |
|
| 2737 | + if (attr.hasOwnProperty("<?php echo esc_attr($key); ?>")) { |
|
| 2738 | + if ('<?php echo esc_attr($key); ?>' == 'html') { |
|
| 2739 | + $html = attr.<?php echo esc_attr($key); ?>; |
|
| 2740 | + } else if ('<?php echo esc_attr($args['type']); ?>' == 'image_xy') { |
|
| 2741 | + content += " <?php echo esc_attr($key); ?>='{x:" + attr.<?php echo esc_attr($key); ?>.x + ",y:"+attr.<?php echo esc_attr($key); ?>.y +"}' "; |
|
| 2742 | 2742 | } else { |
| 2743 | - content += " <?php echo esc_attr( $key );?>='" + attr.<?php echo esc_attr( $key );?>+ "' "; |
|
| 2743 | + content += " <?php echo esc_attr($key); ?>='" + attr.<?php echo esc_attr($key); ?>+ "' "; |
|
| 2744 | 2744 | } |
| 2745 | 2745 | } |
| 2746 | 2746 | <?php |
@@ -2759,7 +2759,7 @@ discard block |
||
| 2759 | 2759 | ?> |
| 2760 | 2760 | // if has html element |
| 2761 | 2761 | if ($html) { |
| 2762 | - content += $html + "[/<?php echo $this->options['base_id'];?>]"; |
|
| 2762 | + content += $html + "[/<?php echo $this->options['base_id']; ?>]"; |
|
| 2763 | 2763 | } |
| 2764 | 2764 | |
| 2765 | 2765 | // @todo should we add inline style here or just css classes? |
@@ -2789,7 +2789,7 @@ discard block |
||
| 2789 | 2789 | // <x?php |
| 2790 | 2790 | // }else |
| 2791 | 2791 | |
| 2792 | - if(!empty($this->options['block-output'])){ |
|
| 2792 | + if (!empty($this->options['block-output'])) { |
|
| 2793 | 2793 | // echo "return"; |
| 2794 | 2794 | // $this->block_element( $this->options['block-output'], true ); |
| 2795 | 2795 | // echo ";"; |
@@ -2799,30 +2799,30 @@ discard block |
||
| 2799 | 2799 | '', |
| 2800 | 2800 | {}, |
| 2801 | 2801 | el('', {dangerouslySetInnerHTML: {__html: content}}), |
| 2802 | - <?php $this->block_element( $this->options['block-output'], true ); ?> |
|
| 2803 | - el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id'];?>]"}}) |
|
| 2802 | + <?php $this->block_element($this->options['block-output'], true); ?> |
|
| 2803 | + el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id']; ?>]"}}) |
|
| 2804 | 2804 | ); |
| 2805 | 2805 | <?php |
| 2806 | 2806 | |
| 2807 | - }elseif(!empty($this->options['block-save-return'])){ |
|
| 2807 | + }elseif (!empty($this->options['block-save-return'])) { |
|
| 2808 | 2808 | echo 'return ' . $this->options['block-save-return']; |
| 2809 | - }elseif(!empty($this->options['nested-block'])){ |
|
| 2809 | + }elseif (!empty($this->options['nested-block'])) { |
|
| 2810 | 2810 | ?> |
| 2811 | 2811 | return el( |
| 2812 | 2812 | '', |
| 2813 | 2813 | {}, |
| 2814 | 2814 | el('', {dangerouslySetInnerHTML: {__html: content+"\n"}}), |
| 2815 | 2815 | InnerBlocks.Content ? el( InnerBlocks.Content ) : '', // @todo i think we need a comma here |
| 2816 | - el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id'];?>]"}}) |
|
| 2816 | + el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id']; ?>]"}}) |
|
| 2817 | 2817 | ); |
| 2818 | 2818 | <?php |
| 2819 | - }elseif(!empty( $this->options['block-save-return'] ) ){ |
|
| 2820 | - echo "return ". $this->options['block-edit-return'].";"; |
|
| 2821 | - }elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){ |
|
| 2819 | + }elseif (!empty($this->options['block-save-return'])) { |
|
| 2820 | + echo "return " . $this->options['block-edit-return'] . ";"; |
|
| 2821 | + }elseif (isset($this->options['block-wrap']) && $this->options['block-wrap'] == '') { |
|
| 2822 | 2822 | ?> |
| 2823 | 2823 | return content; |
| 2824 | 2824 | <?php |
| 2825 | - }else{ |
|
| 2825 | + } else { |
|
| 2826 | 2826 | ?> |
| 2827 | 2827 | var block_wrap = 'div'; |
| 2828 | 2828 | if (attr.hasOwnProperty("block_wrap")) { |
@@ -2851,48 +2851,48 @@ discard block |
||
| 2851 | 2851 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 2852 | 2852 | */ |
| 2853 | 2853 | |
| 2854 | - return str_replace( array( |
|
| 2854 | + return str_replace(array( |
|
| 2855 | 2855 | '<script>', |
| 2856 | 2856 | '</script>' |
| 2857 | - ), '', $output ); |
|
| 2857 | + ), '', $output); |
|
| 2858 | 2858 | } |
| 2859 | 2859 | |
| 2860 | 2860 | |
| 2861 | 2861 | |
| 2862 | - public function block_row_start($key, $args){ |
|
| 2862 | + public function block_row_start($key, $args) { |
|
| 2863 | 2863 | |
| 2864 | 2864 | // check for row |
| 2865 | - if(!empty($args['row'])){ |
|
| 2865 | + if (!empty($args['row'])) { |
|
| 2866 | 2866 | |
| 2867 | - if(!empty($args['row']['open'])){ |
|
| 2867 | + if (!empty($args['row']['open'])) { |
|
| 2868 | 2868 | |
| 2869 | 2869 | // element require |
| 2870 | - $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : ""; |
|
| 2871 | - $device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : ''; |
|
| 2872 | - $device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : ''; |
|
| 2870 | + $element_require = !empty($args['element_require']) ? $this->block_props_replace($args['element_require'], true) . " && " : ""; |
|
| 2871 | + $device_type = !empty($args['device_type']) ? esc_attr($args['device_type']) : ''; |
|
| 2872 | + $device_type_require = !empty($args['device_type']) ? " deviceType == '" . esc_attr($device_type) . "' && " : ''; |
|
| 2873 | 2873 | $device_type_icon = ''; |
| 2874 | - if($device_type=='Desktop'){ |
|
| 2874 | + if ($device_type == 'Desktop') { |
|
| 2875 | 2875 | $device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;"></span>'; |
| 2876 | - }elseif($device_type=='Tablet'){ |
|
| 2876 | + }elseif ($device_type == 'Tablet') { |
|
| 2877 | 2877 | $device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;"></span>'; |
| 2878 | - }elseif($device_type=='Mobile'){ |
|
| 2878 | + }elseif ($device_type == 'Mobile') { |
|
| 2879 | 2879 | $device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;"></span>'; |
| 2880 | 2880 | } |
| 2881 | 2881 | echo $element_require; |
| 2882 | 2882 | echo $device_type_require; |
| 2883 | 2883 | |
| 2884 | - if(false){?><script><?php }?> |
|
| 2884 | + if (false) {?><script><?php }?> |
|
| 2885 | 2885 | el('div', { |
| 2886 | 2886 | className: 'bsui components-base-control', |
| 2887 | 2887 | }, |
| 2888 | - <?php if(!empty($args['row']['title'])){ ?> |
|
| 2888 | + <?php if (!empty($args['row']['title'])) { ?> |
|
| 2889 | 2889 | el('label', { |
| 2890 | 2890 | className: 'components-base-control__label', |
| 2891 | 2891 | style: {width:"100%"} |
| 2892 | 2892 | }, |
| 2893 | - el('span',{dangerouslySetInnerHTML: {__html: '<?php echo addslashes( $args['row']['title'] ) ?>'}}), |
|
| 2894 | - <?php if($device_type_icon){ ?> |
|
| 2895 | - deviceType == '<?php echo $device_type;?>' && el('span',{dangerouslySetInnerHTML: {__html: '<?php echo $device_type_icon; ?>'},title: deviceType + ": Set preview mode to change",style: {float:"right",color:"var(--wp-admin-theme-color)"}}) |
|
| 2893 | + el('span',{dangerouslySetInnerHTML: {__html: '<?php echo addslashes($args['row']['title']) ?>'}}), |
|
| 2894 | + <?php if ($device_type_icon) { ?> |
|
| 2895 | + deviceType == '<?php echo $device_type; ?>' && el('span',{dangerouslySetInnerHTML: {__html: '<?php echo $device_type_icon; ?>'},title: deviceType + ": Set preview mode to change",style: {float:"right",color:"var(--wp-admin-theme-color)"}}) |
|
| 2896 | 2896 | <?php |
| 2897 | 2897 | } |
| 2898 | 2898 | ?> |
@@ -2900,17 +2900,17 @@ discard block |
||
| 2900 | 2900 | |
| 2901 | 2901 | ), |
| 2902 | 2902 | <?php }?> |
| 2903 | - <?php if(!empty($args['row']['desc'])){ ?> |
|
| 2903 | + <?php if (!empty($args['row']['desc'])) { ?> |
|
| 2904 | 2904 | el('p', { |
| 2905 | 2905 | className: 'components-base-control__help mb-0', |
| 2906 | 2906 | }, |
| 2907 | - '<?php echo addslashes( $args['row']['desc'] ); ?>' |
|
| 2907 | + '<?php echo addslashes($args['row']['desc']); ?>' |
|
| 2908 | 2908 | ), |
| 2909 | 2909 | <?php }?> |
| 2910 | 2910 | el( |
| 2911 | 2911 | 'div', |
| 2912 | 2912 | { |
| 2913 | - className: 'row mb-n2 <?php if(!empty($args['row']['class'])){ echo esc_attr($args['row']['class']);} ?>', |
|
| 2913 | + className: 'row mb-n2 <?php if (!empty($args['row']['class'])) { echo esc_attr($args['row']['class']); } ?>', |
|
| 2914 | 2914 | }, |
| 2915 | 2915 | el( |
| 2916 | 2916 | 'div', |
@@ -2919,36 +2919,36 @@ discard block |
||
| 2919 | 2919 | }, |
| 2920 | 2920 | |
| 2921 | 2921 | <?php |
| 2922 | - if(false){?></script><?php } |
|
| 2923 | - }elseif(!empty($args['row']['close'])){ |
|
| 2924 | - if(false){?><script><?php }?> |
|
| 2922 | + if (false) {?></script><?php } |
|
| 2923 | + }elseif (!empty($args['row']['close'])) { |
|
| 2924 | + if (false) {?><script><?php }?> |
|
| 2925 | 2925 | el( |
| 2926 | 2926 | 'div', |
| 2927 | 2927 | { |
| 2928 | 2928 | className: 'col pl-0', |
| 2929 | 2929 | }, |
| 2930 | 2930 | <?php |
| 2931 | - if(false){?></script><?php } |
|
| 2932 | - }else{ |
|
| 2933 | - if(false){?><script><?php }?> |
|
| 2931 | + if (false) {?></script><?php } |
|
| 2932 | + } else { |
|
| 2933 | + if (false) {?><script><?php }?> |
|
| 2934 | 2934 | el( |
| 2935 | 2935 | 'div', |
| 2936 | 2936 | { |
| 2937 | 2937 | className: 'col pl-0 pr-2', |
| 2938 | 2938 | }, |
| 2939 | 2939 | <?php |
| 2940 | - if(false){?></script><?php } |
|
| 2940 | + if (false) {?></script><?php } |
|
| 2941 | 2941 | } |
| 2942 | 2942 | |
| 2943 | 2943 | } |
| 2944 | 2944 | |
| 2945 | 2945 | } |
| 2946 | 2946 | |
| 2947 | - public function block_row_end($key, $args){ |
|
| 2947 | + public function block_row_end($key, $args) { |
|
| 2948 | 2948 | |
| 2949 | - if(!empty($args['row'])){ |
|
| 2949 | + if (!empty($args['row'])) { |
|
| 2950 | 2950 | // maybe close |
| 2951 | - if(!empty($args['row']['close'])){ |
|
| 2951 | + if (!empty($args['row']['close'])) { |
|
| 2952 | 2952 | echo "))"; |
| 2953 | 2953 | } |
| 2954 | 2954 | |
@@ -2956,14 +2956,14 @@ discard block |
||
| 2956 | 2956 | } |
| 2957 | 2957 | } |
| 2958 | 2958 | |
| 2959 | - public function block_tab_start($key, $args){ |
|
| 2959 | + public function block_tab_start($key, $args) { |
|
| 2960 | 2960 | |
| 2961 | 2961 | // check for row |
| 2962 | - if(!empty($args['tab'])){ |
|
| 2962 | + if (!empty($args['tab'])) { |
|
| 2963 | 2963 | |
| 2964 | - if(!empty($args['tab']['tabs_open'])){ |
|
| 2964 | + if (!empty($args['tab']['tabs_open'])) { |
|
| 2965 | 2965 | |
| 2966 | - if(false){?><script><?php }?> |
|
| 2966 | + if (false) {?><script><?php }?> |
|
| 2967 | 2967 | |
| 2968 | 2968 | el('div',{className: 'bsui'}, |
| 2969 | 2969 | |
@@ -2972,41 +2972,41 @@ discard block |
||
| 2972 | 2972 | { |
| 2973 | 2973 | activeClass: 'is-active', |
| 2974 | 2974 | className: 'btn-groupx', |
| 2975 | - initialTabName: '<?php echo addslashes( esc_attr( $args['tab']['key']) ); ?>', |
|
| 2975 | + initialTabName: '<?php echo addslashes(esc_attr($args['tab']['key'])); ?>', |
|
| 2976 | 2976 | tabs: [ |
| 2977 | 2977 | |
| 2978 | 2978 | <?php |
| 2979 | - if(false){?></script><?php } |
|
| 2979 | + if (false) {?></script><?php } |
|
| 2980 | 2980 | } |
| 2981 | 2981 | |
| 2982 | - if(!empty($args['tab']['open'])){ |
|
| 2982 | + if (!empty($args['tab']['open'])) { |
|
| 2983 | 2983 | |
| 2984 | - if(false){?><script><?php }?> |
|
| 2984 | + if (false) {?><script><?php }?> |
|
| 2985 | 2985 | { |
| 2986 | - name: '<?php echo addslashes( esc_attr( $args['tab']['key']) ); ?>', |
|
| 2987 | - title: el('div', {dangerouslySetInnerHTML: {__html: '<?php echo addslashes( esc_attr( $args['tab']['title']) ); ?>'}}), |
|
| 2988 | - className: '<?php echo addslashes( esc_attr( $args['tab']['class']) ); ?>', |
|
| 2989 | - content: el('div',{}, <?php if(!empty($args['tab']['desc'])){ ?>el('p', { |
|
| 2986 | + name: '<?php echo addslashes(esc_attr($args['tab']['key'])); ?>', |
|
| 2987 | + title: el('div', {dangerouslySetInnerHTML: {__html: '<?php echo addslashes(esc_attr($args['tab']['title'])); ?>'}}), |
|
| 2988 | + className: '<?php echo addslashes(esc_attr($args['tab']['class'])); ?>', |
|
| 2989 | + content: el('div',{}, <?php if (!empty($args['tab']['desc'])) { ?>el('p', { |
|
| 2990 | 2990 | className: 'components-base-control__help mb-0', |
| 2991 | - dangerouslySetInnerHTML: {__html:'<?php echo addslashes( $args['tab']['desc'] ); ?>'} |
|
| 2991 | + dangerouslySetInnerHTML: {__html:'<?php echo addslashes($args['tab']['desc']); ?>'} |
|
| 2992 | 2992 | }),<?php } |
| 2993 | - if(false){?></script><?php } |
|
| 2993 | + if (false) {?></script><?php } |
|
| 2994 | 2994 | } |
| 2995 | 2995 | |
| 2996 | 2996 | } |
| 2997 | 2997 | |
| 2998 | 2998 | } |
| 2999 | 2999 | |
| 3000 | - public function block_tab_end($key, $args){ |
|
| 3000 | + public function block_tab_end($key, $args) { |
|
| 3001 | 3001 | |
| 3002 | - if(!empty($args['tab'])){ |
|
| 3002 | + if (!empty($args['tab'])) { |
|
| 3003 | 3003 | // maybe close |
| 3004 | - if(!empty($args['tab']['close'])){ |
|
| 3004 | + if (!empty($args['tab']['close'])) { |
|
| 3005 | 3005 | echo ")}, /* tab close */"; |
| 3006 | 3006 | } |
| 3007 | 3007 | |
| 3008 | - if(!empty($args['tab']['tabs_close'])){ |
|
| 3009 | - if(false){?><script><?php }?> |
|
| 3008 | + if (!empty($args['tab']['tabs_close'])) { |
|
| 3009 | + if (false) {?><script><?php }?> |
|
| 3010 | 3010 | ], |
| 3011 | 3011 | }, |
| 3012 | 3012 | ( tab ) => { |
@@ -3015,41 +3015,41 @@ discard block |
||
| 3015 | 3015 | |
| 3016 | 3016 | } |
| 3017 | 3017 | )), /* tabs close */ |
| 3018 | - <?php if(false){ ?></script><?php } |
|
| 3018 | + <?php if (false) { ?></script><?php } |
|
| 3019 | 3019 | } |
| 3020 | 3020 | } |
| 3021 | 3021 | } |
| 3022 | 3022 | |
| 3023 | - public function build_block_arguments( $key, $args ) { |
|
| 3024 | - $custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : ''; |
|
| 3023 | + public function build_block_arguments($key, $args) { |
|
| 3024 | + $custom_attributes = !empty($args['custom_attributes']) ? $this->array_to_attributes($args['custom_attributes']) : ''; |
|
| 3025 | 3025 | $options = ''; |
| 3026 | 3026 | $extra = ''; |
| 3027 | 3027 | $require = ''; |
| 3028 | - $inside_elements = ''; |
|
| 3028 | + $inside_elements = ''; |
|
| 3029 | 3029 | |
| 3030 | 3030 | // `content` is a protected and special argument |
| 3031 | - if ( $key == 'content' ) { |
|
| 3031 | + if ($key == 'content') { |
|
| 3032 | 3032 | return; |
| 3033 | 3033 | } |
| 3034 | 3034 | |
| 3035 | - $device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : ''; |
|
| 3036 | - $device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : ''; |
|
| 3035 | + $device_type = !empty($args['device_type']) ? esc_attr($args['device_type']) : ''; |
|
| 3036 | + $device_type_require = !empty($args['device_type']) ? " deviceType == '" . esc_attr($device_type) . "' && " : ''; |
|
| 3037 | 3037 | $device_type_icon = ''; |
| 3038 | - if($device_type=='Desktop'){ |
|
| 3038 | + if ($device_type == 'Desktop') { |
|
| 3039 | 3039 | $device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>'; |
| 3040 | - }elseif($device_type=='Tablet'){ |
|
| 3040 | + }elseif ($device_type == 'Tablet') { |
|
| 3041 | 3041 | $device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>'; |
| 3042 | - }elseif($device_type=='Mobile'){ |
|
| 3042 | + }elseif ($device_type == 'Mobile') { |
|
| 3043 | 3043 | $device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>'; |
| 3044 | 3044 | } |
| 3045 | 3045 | |
| 3046 | 3046 | // icon |
| 3047 | 3047 | $icon = ''; |
| 3048 | - if( !empty( $args['icon'] ) ){ |
|
| 3048 | + if (!empty($args['icon'])) { |
|
| 3049 | 3049 | $icon .= "el('div', {"; |
| 3050 | - $icon .= "dangerouslySetInnerHTML: {__html: '".self::get_widget_icon( esc_attr($args['icon']))."'},"; |
|
| 3050 | + $icon .= "dangerouslySetInnerHTML: {__html: '" . self::get_widget_icon(esc_attr($args['icon'])) . "'},"; |
|
| 3051 | 3051 | $icon .= "className: 'text-center',"; |
| 3052 | - $icon .= "title: '".addslashes( $args['title'] )."',"; |
|
| 3052 | + $icon .= "title: '" . addslashes($args['title']) . "',"; |
|
| 3053 | 3053 | $icon .= "}),"; |
| 3054 | 3054 | |
| 3055 | 3055 | // blank title as its added to the icon. |
@@ -3057,28 +3057,28 @@ discard block |
||
| 3057 | 3057 | } |
| 3058 | 3058 | |
| 3059 | 3059 | // require advanced |
| 3060 | - $require_advanced = ! empty( $args['advanced'] ) ? "props.attributes.show_advanced && " : ""; |
|
| 3060 | + $require_advanced = !empty($args['advanced']) ? "props.attributes.show_advanced && " : ""; |
|
| 3061 | 3061 | |
| 3062 | 3062 | // element require |
| 3063 | - $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : ""; |
|
| 3063 | + $element_require = !empty($args['element_require']) ? $this->block_props_replace($args['element_require'], true) . " && " : ""; |
|
| 3064 | 3064 | |
| 3065 | 3065 | |
| 3066 | 3066 | $onchange = "props.setAttributes({ $key: $key } )"; |
| 3067 | - $onchangecomplete = ""; |
|
| 3067 | + $onchangecomplete = ""; |
|
| 3068 | 3068 | $value = "props.attributes.$key"; |
| 3069 | - $text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'colorx','range' ); |
|
| 3070 | - if ( in_array( $args['type'], $text_type ) ) { |
|
| 3069 | + $text_type = array('text', 'password', 'number', 'email', 'tel', 'url', 'colorx', 'range'); |
|
| 3070 | + if (in_array($args['type'], $text_type)) { |
|
| 3071 | 3071 | $type = 'TextControl'; |
| 3072 | 3072 | // Save numbers as numbers and not strings |
| 3073 | - if ( $args['type'] == 'number' ) { |
|
| 3073 | + if ($args['type'] == 'number') { |
|
| 3074 | 3074 | $onchange = "props.setAttributes({ $key: $key ? Number($key) : '' } )"; |
| 3075 | 3075 | } |
| 3076 | - }else if ( $args['type'] == 'styleid' ) { |
|
| 3076 | + } else if ($args['type'] == 'styleid') { |
|
| 3077 | 3077 | $type = 'TextControl'; |
| 3078 | 3078 | $args['type'] == 'text'; |
| 3079 | 3079 | // Save numbers as numbers and not strings |
| 3080 | - $value = "props.attributes.$key ? props.attributes.$key : 'aaabbbccc'"; |
|
| 3081 | - }else if ( $args['type'] == 'notice' ) { |
|
| 3080 | + $value = "props.attributes.$key ? props.attributes.$key : 'aaabbbccc'"; |
|
| 3081 | + } else if ($args['type'] == 'notice') { |
|
| 3082 | 3082 | |
| 3083 | 3083 | $notice_message = !empty($args['desc']) ? addslashes($args['desc']) : ''; |
| 3084 | 3084 | $notice_status = !empty($args['status']) ? esc_attr($args['status']) : 'info'; |
@@ -3140,11 +3140,11 @@ discard block |
||
| 3140 | 3140 | return; |
| 3141 | 3141 | } |
| 3142 | 3142 | */ |
| 3143 | - elseif ( $args['type'] == 'color' ) { |
|
| 3143 | + elseif ($args['type'] == 'color') { |
|
| 3144 | 3144 | $type = 'ColorPicker'; |
| 3145 | 3145 | $onchange = ""; |
| 3146 | 3146 | $extra = "color: $value,"; |
| 3147 | - if(!empty($args['disable_alpha'])){ |
|
| 3147 | + if (!empty($args['disable_alpha'])) { |
|
| 3148 | 3148 | $extra .= "disableAlpha: true,"; |
| 3149 | 3149 | } |
| 3150 | 3150 | $onchangecomplete = "onChangeComplete: function($key) { |
@@ -3153,14 +3153,14 @@ discard block |
||
| 3153 | 3153 | $key: value |
| 3154 | 3154 | }); |
| 3155 | 3155 | },"; |
| 3156 | - }elseif ( $args['type'] == 'gradient' ) { |
|
| 3156 | + }elseif ($args['type'] == 'gradient') { |
|
| 3157 | 3157 | $type = 'GradientPicker'; |
| 3158 | 3158 | |
| 3159 | - }elseif ( $args['type'] == 'image' ) { |
|
| 3159 | + }elseif ($args['type'] == 'image') { |
|
| 3160 | 3160 | // print_r($args); |
| 3161 | 3161 | |
| 3162 | 3162 | $img_preview = isset($args['focalpoint']) && !$args['focalpoint'] ? " props.attributes.$key && el('img', { src: props.attributes.$key,style: {maxWidth:'100%',background: '#ccc'}})," : " ( props.attributes.$key || props.attributes.{$key}_use_featured ) && el(wp.components.FocalPointPicker,{ |
| 3163 | - url: props.attributes.{$key}_use_featured === true ? '".$this->get_url()."icons/placeholder.png' : props.attributes.$key, |
|
| 3163 | + url: props.attributes.{$key}_use_featured === true ? '" . $this->get_url() . "icons/placeholder.png' : props.attributes.$key, |
|
| 3164 | 3164 | value: props.attributes.{$key}_xy.x !== undefined && props.attributes.{$key}_xy.x >= 0 ? props.attributes.{$key}_xy : {x: 0.5,y: 0.5,}, |
| 3165 | 3165 | // value: props.attributes.{$key}_xy, |
| 3166 | 3166 | onChange: function(focalPoint){ |
@@ -3218,7 +3218,7 @@ discard block |
||
| 3218 | 3218 | $onchange = ""; |
| 3219 | 3219 | |
| 3220 | 3220 | //$inside_elements = ",el('div',{},'file upload')"; |
| 3221 | - }elseif ( $args['type'] == 'images' ) { |
|
| 3221 | + }elseif ($args['type'] == 'images') { |
|
| 3222 | 3222 | // print_r($args); |
| 3223 | 3223 | |
| 3224 | 3224 | $img_preview = "props.attributes.$key && (function() { |
@@ -3230,7 +3230,7 @@ discard block |
||
| 3230 | 3230 | images.push( el('div',{className: 'col p-2',draggable: 'true','data-index': index}, el('img', { src: upload.sizes.thumbnail.url,style: {maxWidth:'100%',background: '#ccc',pointerEvents:'none'}}),el('i',{ |
| 3231 | 3231 | className: 'fas fa-times-circle text-danger position-absolute ml-n2 mt-n1 bg-white rounded-circle c-pointer', |
| 3232 | 3232 | onClick: function(){ |
| 3233 | - aui_confirm('".__('Are you sure?')."', '".__('Delete')."', '".__('Cancel')."', true).then(function(confirmed) { |
|
| 3233 | + aui_confirm('" . __('Are you sure?') . "', '" . __('Delete') . "', '" . __('Cancel') . "', true).then(function(confirmed) { |
|
| 3234 | 3234 | if (confirmed) { |
| 3235 | 3235 | let new_uploads = JSON.parse(props.attributes.$key); |
| 3236 | 3236 | new_uploads.splice(index, 1); //remove |
@@ -3304,33 +3304,33 @@ discard block |
||
| 3304 | 3304 | |
| 3305 | 3305 | //$inside_elements = ",el('div',{},'file upload')"; |
| 3306 | 3306 | } |
| 3307 | - elseif ( $args['type'] == 'checkbox' ) { |
|
| 3307 | + elseif ($args['type'] == 'checkbox') { |
|
| 3308 | 3308 | $type = 'CheckboxControl'; |
| 3309 | 3309 | $extra .= "checked: props.attributes.$key,"; |
| 3310 | 3310 | $onchange = "props.setAttributes({ $key: ! props.attributes.$key } )"; |
| 3311 | - } elseif ( $args['type'] == 'textarea' ) { |
|
| 3311 | + } elseif ($args['type'] == 'textarea') { |
|
| 3312 | 3312 | $type = 'TextareaControl'; |
| 3313 | - } elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) { |
|
| 3313 | + } elseif ($args['type'] == 'select' || $args['type'] == 'multiselect') { |
|
| 3314 | 3314 | $type = 'SelectControl'; |
| 3315 | 3315 | |
| 3316 | - if($args['name'] == 'category' && !empty($args['post_type_linked'])){ |
|
| 3317 | - $options .= "options: taxonomies_".str_replace("-","_", $this->id).","; |
|
| 3318 | - }elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){ |
|
| 3319 | - $options .= "options: sort_by_".str_replace("-","_", $this->id).","; |
|
| 3320 | - }else { |
|
| 3316 | + if ($args['name'] == 'category' && !empty($args['post_type_linked'])) { |
|
| 3317 | + $options .= "options: taxonomies_" . str_replace("-", "_", $this->id) . ","; |
|
| 3318 | + }elseif ($args['name'] == 'sort_by' && !empty($args['post_type_linked'])) { |
|
| 3319 | + $options .= "options: sort_by_" . str_replace("-", "_", $this->id) . ","; |
|
| 3320 | + } else { |
|
| 3321 | 3321 | |
| 3322 | - if ( ! empty( $args['options'] ) ) { |
|
| 3322 | + if (!empty($args['options'])) { |
|
| 3323 | 3323 | $options .= "options: ["; |
| 3324 | - foreach ( $args['options'] as $option_val => $option_label ) { |
|
| 3325 | - $options .= "{ value: '" . esc_attr( $option_val ) . "', label: '" . addslashes( $option_label ) . "' },"; |
|
| 3324 | + foreach ($args['options'] as $option_val => $option_label) { |
|
| 3325 | + $options .= "{ value: '" . esc_attr($option_val) . "', label: '" . addslashes($option_label) . "' },"; |
|
| 3326 | 3326 | } |
| 3327 | 3327 | $options .= "],"; |
| 3328 | 3328 | } |
| 3329 | 3329 | } |
| 3330 | - if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550 |
|
| 3330 | + if (isset($args['multiple']) && $args['multiple']) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550 |
|
| 3331 | 3331 | $extra .= ' multiple:true,style:{height:"auto",paddingRight:"8px"}, '; |
| 3332 | 3332 | } |
| 3333 | - } elseif ( $args['type'] == 'tagselect' ) { |
|
| 3333 | + } elseif ($args['type'] == 'tagselect') { |
|
| 3334 | 3334 | // $type = 'FormTokenField'; |
| 3335 | 3335 | // |
| 3336 | 3336 | // if ( ! empty( $args['options'] ) ) { |
@@ -3365,23 +3365,23 @@ discard block |
||
| 3365 | 3365 | // $value = "[]"; |
| 3366 | 3366 | // $extra .= ' __experimentalExpandOnFocus: true,'; |
| 3367 | 3367 | |
| 3368 | - } elseif ( $args['type'] == 'alignment' ) { |
|
| 3368 | + } elseif ($args['type'] == 'alignment') { |
|
| 3369 | 3369 | $type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example |
| 3370 | - }elseif ( $args['type'] == 'margins' ) { |
|
| 3370 | + }elseif ($args['type'] == 'margins') { |
|
| 3371 | 3371 | |
| 3372 | 3372 | } else { |
| 3373 | - return;// if we have not implemented the control then don't break the JS. |
|
| 3373 | + return; // if we have not implemented the control then don't break the JS. |
|
| 3374 | 3374 | } |
| 3375 | 3375 | |
| 3376 | 3376 | |
| 3377 | 3377 | |
| 3378 | 3378 | // color input does not show the labels so we add them |
| 3379 | - if($args['type']=='color'){ |
|
| 3379 | + if ($args['type'] == 'color') { |
|
| 3380 | 3380 | // add show only if advanced |
| 3381 | 3381 | echo $require_advanced; |
| 3382 | 3382 | // add setting require if defined |
| 3383 | 3383 | echo $element_require; |
| 3384 | - echo "el('div', {style: {'marginBottom': '8px'}}, '".addslashes( $args['title'] )."'),"; |
|
| 3384 | + echo "el('div', {style: {'marginBottom': '8px'}}, '" . addslashes($args['title']) . "'),"; |
|
| 3385 | 3385 | } |
| 3386 | 3386 | |
| 3387 | 3387 | // add show only if advanced |
@@ -3393,18 +3393,18 @@ discard block |
||
| 3393 | 3393 | // icon |
| 3394 | 3394 | echo $icon; |
| 3395 | 3395 | ?> |
| 3396 | - el( <?php echo $args['type'] == 'image' || $args['type'] == 'images' ? $type : "wp.components.".$type; ?>, { |
|
| 3396 | + el( <?php echo $args['type'] == 'image' || $args['type'] == 'images' ? $type : "wp.components." . $type; ?>, { |
|
| 3397 | 3397 | label: <?php |
| 3398 | - if(empty($args['title'])){ |
|
| 3398 | + if (empty($args['title'])) { |
|
| 3399 | 3399 | echo "''"; |
| 3400 | - }elseif(empty($args['row']) && !empty($args['device_type'])){ |
|
| 3400 | + }elseif (empty($args['row']) && !empty($args['device_type'])) { |
|
| 3401 | 3401 | ?>el('label', { |
| 3402 | 3402 | className: 'components-base-control__label', |
| 3403 | 3403 | style: {width:"100%"} |
| 3404 | 3404 | }, |
| 3405 | - el('span',{dangerouslySetInnerHTML: {__html: '<?php echo addslashes( $args['title'] ) ?>'}}), |
|
| 3406 | - <?php if($device_type_icon){ ?> |
|
| 3407 | - deviceType == '<?php echo $device_type;?>' && el('span',{dangerouslySetInnerHTML: {__html: '<?php echo $device_type_icon; ?>'},title: deviceType + ": Set preview mode to change",style: {right:"0",position:"absolute",color:"var(--wp-admin-theme-color)"}}) |
|
| 3405 | + el('span',{dangerouslySetInnerHTML: {__html: '<?php echo addslashes($args['title']) ?>'}}), |
|
| 3406 | + <?php if ($device_type_icon) { ?> |
|
| 3407 | + deviceType == '<?php echo $device_type; ?>' && el('span',{dangerouslySetInnerHTML: {__html: '<?php echo $device_type_icon; ?>'},title: deviceType + ": Set preview mode to change",style: {right:"0",position:"absolute",color:"var(--wp-admin-theme-color)"}}) |
|
| 3408 | 3408 | <?php |
| 3409 | 3409 | } |
| 3410 | 3410 | ?> |
@@ -3412,27 +3412,27 @@ discard block |
||
| 3412 | 3412 | |
| 3413 | 3413 | )<?php |
| 3414 | 3414 | |
| 3415 | - }else{ |
|
| 3416 | - ?>'<?php echo addslashes( $args['title'] ); ?>'<?php |
|
| 3415 | + } else { |
|
| 3416 | + ?>'<?php echo addslashes($args['title']); ?>'<?php |
|
| 3417 | 3417 | |
| 3418 | 3418 | } |
| 3419 | 3419 | |
| 3420 | 3420 | ?>, |
| 3421 | - help: <?php if ( isset( $args['desc'] ) ) { |
|
| 3422 | - echo "el('span',{dangerouslySetInnerHTML: {__html: '".wp_kses_post( addslashes($args['desc']) )."'}})"; |
|
| 3423 | - }else{ echo "''"; } ?>, |
|
| 3421 | + help: <?php if (isset($args['desc'])) { |
|
| 3422 | + echo "el('span',{dangerouslySetInnerHTML: {__html: '" . wp_kses_post(addslashes($args['desc'])) . "'}})"; |
|
| 3423 | + } else { echo "''"; } ?>, |
|
| 3424 | 3424 | value: <?php echo $value; ?>, |
| 3425 | - <?php if ( $type == 'TextControl' && $args['type'] != 'text' ) { |
|
| 3426 | - echo "type: '" . addslashes( $args['type'] ) . "',"; |
|
| 3425 | + <?php if ($type == 'TextControl' && $args['type'] != 'text') { |
|
| 3426 | + echo "type: '" . addslashes($args['type']) . "',"; |
|
| 3427 | 3427 | } ?> |
| 3428 | - <?php if ( ! empty( $args['placeholder'] ) ) { |
|
| 3429 | - echo "placeholder: '" . addslashes( $args['placeholder'] ) . "',"; |
|
| 3428 | + <?php if (!empty($args['placeholder'])) { |
|
| 3429 | + echo "placeholder: '" . addslashes($args['placeholder']) . "',"; |
|
| 3430 | 3430 | } ?> |
| 3431 | 3431 | <?php echo $options; ?> |
| 3432 | 3432 | <?php echo $extra; ?> |
| 3433 | 3433 | <?php echo $custom_attributes; ?> |
| 3434 | 3434 | <?php echo $onchangecomplete; |
| 3435 | - if($onchange){ |
|
| 3435 | + if ($onchange) { |
|
| 3436 | 3436 | ?> |
| 3437 | 3437 | onChange: function ( <?php echo $key; ?> ) { |
| 3438 | 3438 | <?php echo $onchange; ?> |
@@ -3453,15 +3453,15 @@ discard block |
||
| 3453 | 3453 | *@todo there is prob a faster way to do this, also we could add some validation here. |
| 3454 | 3454 | * |
| 3455 | 3455 | */ |
| 3456 | - public function array_to_attributes( $custom_attributes, $html = false ) { |
|
| 3456 | + public function array_to_attributes($custom_attributes, $html = false) { |
|
| 3457 | 3457 | $attributes = ''; |
| 3458 | - if ( ! empty( $custom_attributes ) ) { |
|
| 3458 | + if (!empty($custom_attributes)) { |
|
| 3459 | 3459 | |
| 3460 | - foreach ( $custom_attributes as $key => $val ) { |
|
| 3461 | - if(is_array($val)){ |
|
| 3462 | - $attributes .= $key.': {'.$this->array_to_attributes( $val, $html ).'},'; |
|
| 3463 | - }else{ |
|
| 3464 | - $attributes .= $html ? " $key='$val' " : "'$key': '$val',"; |
|
| 3460 | + foreach ($custom_attributes as $key => $val) { |
|
| 3461 | + if (is_array($val)) { |
|
| 3462 | + $attributes .= $key . ': {' . $this->array_to_attributes($val, $html) . '},'; |
|
| 3463 | + } else { |
|
| 3464 | + $attributes .= $html ? " $key='$val' " : "'$key': '$val',"; |
|
| 3465 | 3465 | } |
| 3466 | 3466 | } |
| 3467 | 3467 | |
@@ -3479,112 +3479,112 @@ discard block |
||
| 3479 | 3479 | * |
| 3480 | 3480 | * @param $args |
| 3481 | 3481 | */ |
| 3482 | - public function block_element( $args, $save = false ) { |
|
| 3482 | + public function block_element($args, $save = false) { |
|
| 3483 | 3483 | |
| 3484 | 3484 | |
| 3485 | - if ( ! empty( $args ) ) { |
|
| 3486 | - foreach ( $args as $element => $new_args ) { |
|
| 3485 | + if (!empty($args)) { |
|
| 3486 | + foreach ($args as $element => $new_args) { |
|
| 3487 | 3487 | |
| 3488 | - if ( is_array( $new_args ) ) { // its an element |
|
| 3488 | + if (is_array($new_args)) { // its an element |
|
| 3489 | 3489 | |
| 3490 | 3490 | |
| 3491 | - if ( isset( $new_args['element'] ) ) { |
|
| 3491 | + if (isset($new_args['element'])) { |
|
| 3492 | 3492 | |
| 3493 | - if ( isset( $new_args['element_require'] ) ) { |
|
| 3494 | - echo str_replace( array( |
|
| 3493 | + if (isset($new_args['element_require'])) { |
|
| 3494 | + echo str_replace(array( |
|
| 3495 | 3495 | "'+", |
| 3496 | 3496 | "+'" |
| 3497 | - ), '', $this->block_props_replace( $new_args['element_require'] ) ) . " && "; |
|
| 3498 | - unset( $new_args['element_require'] ); |
|
| 3497 | + ), '', $this->block_props_replace($new_args['element_require'])) . " && "; |
|
| 3498 | + unset($new_args['element_require']); |
|
| 3499 | 3499 | } |
| 3500 | 3500 | |
| 3501 | - if($new_args['element']=='InnerBlocks'){ |
|
| 3501 | + if ($new_args['element'] == 'InnerBlocks') { |
|
| 3502 | 3502 | echo "\n el( InnerBlocks, {"; |
| 3503 | - }elseif($new_args['element']=='innerBlocksProps'){ |
|
| 3503 | + }elseif ($new_args['element'] == 'innerBlocksProps') { |
|
| 3504 | 3504 | $element = isset($new_args['inner_element']) ? esc_attr($new_args['inner_element']) : 'div'; |
| 3505 | 3505 | // echo "\n el( 'section', wp.blockEditor.useInnerBlocksProps( blockProps, {"; |
| 3506 | 3506 | // echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( "; |
| 3507 | 3507 | echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( "; |
| 3508 | 3508 | echo $save ? "wp.blockEditor.useBlockProps.save( {" : "wp.blockEditor.useBlockProps( {"; |
| 3509 | - echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : ''; |
|
| 3509 | + echo !empty($new_args['blockProps']) ? $this->block_element($new_args['blockProps'], $save) : ''; |
|
| 3510 | 3510 | |
| 3511 | 3511 | echo "} ), {"; |
| 3512 | - echo !empty($new_args['innerBlocksProps']) && !$save ? $this->block_element( $new_args['innerBlocksProps'],$save ) : ''; |
|
| 3512 | + echo !empty($new_args['innerBlocksProps']) && !$save ? $this->block_element($new_args['innerBlocksProps'], $save) : ''; |
|
| 3513 | 3513 | // echo '###'; |
| 3514 | 3514 | |
| 3515 | 3515 | // echo '###'; |
| 3516 | - }elseif($new_args['element']=='BlocksProps'){ |
|
| 3516 | + }elseif ($new_args['element'] == 'BlocksProps') { |
|
| 3517 | 3517 | |
| 3518 | - if ( isset($new_args['if_inner_element']) ) { |
|
| 3518 | + if (isset($new_args['if_inner_element'])) { |
|
| 3519 | 3519 | $element = $new_args['if_inner_element']; |
| 3520 | - }else { |
|
| 3521 | - $element = isset($new_args['inner_element']) ? "'".esc_attr($new_args['inner_element'])."'" : "'div'"; |
|
| 3520 | + } else { |
|
| 3521 | + $element = isset($new_args['inner_element']) ? "'" . esc_attr($new_args['inner_element']) . "'" : "'div'"; |
|
| 3522 | 3522 | } |
| 3523 | 3523 | |
| 3524 | 3524 | unset($new_args['inner_element']); |
| 3525 | 3525 | echo $save ? "\n el( $element, wp.blockEditor.useBlockProps.save( {" : "\n el( $element, wp.blockEditor.useBlockProps( {"; |
| 3526 | - echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : ''; |
|
| 3526 | + echo !empty($new_args['blockProps']) ? $this->block_element($new_args['blockProps'], $save) : ''; |
|
| 3527 | 3527 | |
| 3528 | 3528 | |
| 3529 | 3529 | // echo "} ),"; |
| 3530 | 3530 | |
| 3531 | - }else{ |
|
| 3531 | + } else { |
|
| 3532 | 3532 | echo "\n el( '" . $new_args['element'] . "', {"; |
| 3533 | 3533 | } |
| 3534 | 3534 | |
| 3535 | 3535 | |
| 3536 | 3536 | // get the attributes |
| 3537 | - foreach ( $new_args as $new_key => $new_value ) { |
|
| 3537 | + foreach ($new_args as $new_key => $new_value) { |
|
| 3538 | 3538 | |
| 3539 | 3539 | |
| 3540 | - if ( $new_key == 'element' || $new_key == 'content'|| $new_key == 'if_content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) { |
|
| 3540 | + if ($new_key == 'element' || $new_key == 'content' || $new_key == 'if_content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array($new_value)) { |
|
| 3541 | 3541 | // do nothing |
| 3542 | 3542 | } else { |
| 3543 | - echo $this->block_element( array( $new_key => $new_value ),$save ); |
|
| 3543 | + echo $this->block_element(array($new_key => $new_value), $save); |
|
| 3544 | 3544 | } |
| 3545 | 3545 | } |
| 3546 | 3546 | |
| 3547 | - echo $new_args['element']=='BlocksProps' ? '} ),' : "},";// end attributes |
|
| 3547 | + echo $new_args['element'] == 'BlocksProps' ? '} ),' : "},"; // end attributes |
|
| 3548 | 3548 | |
| 3549 | 3549 | // get the content |
| 3550 | 3550 | $first_item = 0; |
| 3551 | - foreach ( $new_args as $new_key => $new_value ) { |
|
| 3552 | - if ( $new_key === 'content' || $new_key === 'if_content' || is_array( $new_value ) ) { |
|
| 3551 | + foreach ($new_args as $new_key => $new_value) { |
|
| 3552 | + if ($new_key === 'content' || $new_key === 'if_content' || is_array($new_value)) { |
|
| 3553 | 3553 | |
| 3554 | - if ( $new_key === 'content' ) { |
|
| 3555 | - echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'"; |
|
| 3556 | - }else if ( $new_key === 'if_content' ) { |
|
| 3557 | - echo $this->block_props_replace( $new_value ); |
|
| 3554 | + if ($new_key === 'content') { |
|
| 3555 | + echo "'" . $this->block_props_replace(wp_slash($new_value)) . "'"; |
|
| 3556 | + } else if ($new_key === 'if_content') { |
|
| 3557 | + echo $this->block_props_replace($new_value); |
|
| 3558 | 3558 | } |
| 3559 | 3559 | |
| 3560 | - if ( is_array( $new_value ) ) { |
|
| 3560 | + if (is_array($new_value)) { |
|
| 3561 | 3561 | |
| 3562 | - if ( isset( $new_value['element_require'] ) ) { |
|
| 3563 | - echo str_replace( array( |
|
| 3562 | + if (isset($new_value['element_require'])) { |
|
| 3563 | + echo str_replace(array( |
|
| 3564 | 3564 | "'+", |
| 3565 | 3565 | "+'" |
| 3566 | - ), '', $this->block_props_replace( $new_value['element_require'] ) ) . " && "; |
|
| 3567 | - unset( $new_value['element_require'] ); |
|
| 3566 | + ), '', $this->block_props_replace($new_value['element_require'])) . " && "; |
|
| 3567 | + unset($new_value['element_require']); |
|
| 3568 | 3568 | } |
| 3569 | 3569 | |
| 3570 | - if ( isset( $new_value['element_repeat'] ) ) { |
|
| 3570 | + if (isset($new_value['element_repeat'])) { |
|
| 3571 | 3571 | $x = 1; |
| 3572 | - while ( $x <= absint( $new_value['element_repeat'] ) ) { |
|
| 3573 | - $this->block_element( array( '' => $new_value ),$save ); |
|
| 3574 | - $x ++; |
|
| 3572 | + while ($x <= absint($new_value['element_repeat'])) { |
|
| 3573 | + $this->block_element(array('' => $new_value), $save); |
|
| 3574 | + $x++; |
|
| 3575 | 3575 | } |
| 3576 | 3576 | } else { |
| 3577 | - $this->block_element( array( '' => $new_value ),$save ); |
|
| 3577 | + $this->block_element(array('' => $new_value), $save); |
|
| 3578 | 3578 | } |
| 3579 | 3579 | } |
| 3580 | - $first_item ++; |
|
| 3580 | + $first_item++; |
|
| 3581 | 3581 | } |
| 3582 | 3582 | } |
| 3583 | 3583 | |
| 3584 | - if($new_args['element']=='innerBlocksProps' || $new_args['element']=='xBlocksProps'){ |
|
| 3585 | - echo "))";// end content |
|
| 3586 | - }else{ |
|
| 3587 | - echo ")";// end content |
|
| 3584 | + if ($new_args['element'] == 'innerBlocksProps' || $new_args['element'] == 'xBlocksProps') { |
|
| 3585 | + echo "))"; // end content |
|
| 3586 | + } else { |
|
| 3587 | + echo ")"; // end content |
|
| 3588 | 3588 | } |
| 3589 | 3589 | |
| 3590 | 3590 | |
@@ -3593,26 +3593,26 @@ discard block |
||
| 3593 | 3593 | } |
| 3594 | 3594 | } else { |
| 3595 | 3595 | |
| 3596 | - if ( substr( $element, 0, 3 ) === "if_" ) { |
|
| 3596 | + if (substr($element, 0, 3) === "if_") { |
|
| 3597 | 3597 | $extra = ''; |
| 3598 | - if( strpos($new_args, '[%WrapClass%]') !== false ){ |
|
| 3599 | - $new_args = str_replace('[%WrapClass%]"','" + sd_build_aui_class(props.attributes)',$new_args); |
|
| 3600 | - $new_args = str_replace('[%WrapClass%]','+ sd_build_aui_class(props.attributes)',$new_args); |
|
| 3598 | + if (strpos($new_args, '[%WrapClass%]') !== false) { |
|
| 3599 | + $new_args = str_replace('[%WrapClass%]"', '" + sd_build_aui_class(props.attributes)', $new_args); |
|
| 3600 | + $new_args = str_replace('[%WrapClass%]', '+ sd_build_aui_class(props.attributes)', $new_args); |
|
| 3601 | 3601 | } |
| 3602 | - echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ","; |
|
| 3603 | - } elseif ( $element == 'style' && strpos($new_args, '[%WrapStyle%]') !== false ) { |
|
| 3604 | - $new_args = str_replace('[%WrapStyle%]','',$new_args); |
|
| 3605 | - echo $element . ": {..." . $this->block_props_replace( $new_args ) . " , ...sd_build_aui_styles(props.attributes) },"; |
|
| 3602 | + echo str_replace("if_", "", $element) . ": " . $this->block_props_replace($new_args, true) . ","; |
|
| 3603 | + } elseif ($element == 'style' && strpos($new_args, '[%WrapStyle%]') !== false) { |
|
| 3604 | + $new_args = str_replace('[%WrapStyle%]', '', $new_args); |
|
| 3605 | + echo $element . ": {..." . $this->block_props_replace($new_args) . " , ...sd_build_aui_styles(props.attributes) },"; |
|
| 3606 | 3606 | // echo $element . ": " . $this->block_props_replace( $new_args ) . ","; |
| 3607 | - } elseif ( $element == 'style' ) { |
|
| 3608 | - echo $element . ": " . $this->block_props_replace( $new_args ) . ","; |
|
| 3609 | - } elseif ( ( $element == 'class' || $element == 'className' ) && strpos($new_args, '[%WrapClass%]') !== false ) { |
|
| 3610 | - $new_args = str_replace('[%WrapClass%]','',$new_args); |
|
| 3611 | - echo $element . ": '" . $this->block_props_replace( $new_args ) . "' + sd_build_aui_class(props.attributes),"; |
|
| 3612 | - } elseif ( $element == 'template' && $new_args ) { |
|
| 3607 | + } elseif ($element == 'style') { |
|
| 3608 | + echo $element . ": " . $this->block_props_replace($new_args) . ","; |
|
| 3609 | + } elseif (($element == 'class' || $element == 'className') && strpos($new_args, '[%WrapClass%]') !== false) { |
|
| 3610 | + $new_args = str_replace('[%WrapClass%]', '', $new_args); |
|
| 3611 | + echo $element . ": '" . $this->block_props_replace($new_args) . "' + sd_build_aui_class(props.attributes),"; |
|
| 3612 | + } elseif ($element == 'template' && $new_args) { |
|
| 3613 | 3613 | echo $element . ": $new_args,"; |
| 3614 | 3614 | } else { |
| 3615 | - echo $element . ": '" . $this->block_props_replace( $new_args ) . "',"; |
|
| 3615 | + echo $element . ": '" . $this->block_props_replace($new_args) . "',"; |
|
| 3616 | 3616 | } |
| 3617 | 3617 | |
| 3618 | 3618 | } |
@@ -3627,12 +3627,12 @@ discard block |
||
| 3627 | 3627 | * |
| 3628 | 3628 | * @return mixed |
| 3629 | 3629 | */ |
| 3630 | - public function block_props_replace( $string, $no_wrap = false ) { |
|
| 3630 | + public function block_props_replace($string, $no_wrap = false) { |
|
| 3631 | 3631 | |
| 3632 | - if ( $no_wrap ) { |
|
| 3633 | - $string = str_replace( array( "[%", "%]" ), array( "props.attributes.", "" ), $string ); |
|
| 3632 | + if ($no_wrap) { |
|
| 3633 | + $string = str_replace(array("[%", "%]"), array("props.attributes.", ""), $string); |
|
| 3634 | 3634 | } else { |
| 3635 | - $string = str_replace( array( "[%", "%]" ), array( "'+props.attributes.", "+'" ), $string ); |
|
| 3635 | + $string = str_replace(array("[%", "%]"), array("'+props.attributes.", "+'"), $string); |
|
| 3636 | 3636 | } |
| 3637 | 3637 | |
| 3638 | 3638 | return $string; |
@@ -3644,62 +3644,62 @@ discard block |
||
| 3644 | 3644 | * @param array $args |
| 3645 | 3645 | * @param array $instance |
| 3646 | 3646 | */ |
| 3647 | - public function widget( $args, $instance ) { |
|
| 3647 | + public function widget($args, $instance) { |
|
| 3648 | 3648 | |
| 3649 | 3649 | // get the filtered values |
| 3650 | - $argument_values = $this->argument_values( $instance ); |
|
| 3651 | - $argument_values = $this->string_to_bool( $argument_values ); |
|
| 3652 | - $output = $this->output( $argument_values, $args ); |
|
| 3650 | + $argument_values = $this->argument_values($instance); |
|
| 3651 | + $argument_values = $this->string_to_bool($argument_values); |
|
| 3652 | + $output = $this->output($argument_values, $args); |
|
| 3653 | 3653 | |
| 3654 | 3654 | $no_wrap = false; |
| 3655 | - if ( isset( $argument_values['no_wrap'] ) && $argument_values['no_wrap'] ) { |
|
| 3655 | + if (isset($argument_values['no_wrap']) && $argument_values['no_wrap']) { |
|
| 3656 | 3656 | $no_wrap = true; |
| 3657 | 3657 | } |
| 3658 | 3658 | |
| 3659 | 3659 | ob_start(); |
| 3660 | - if ( $output && ! $no_wrap ) { |
|
| 3660 | + if ($output && !$no_wrap) { |
|
| 3661 | 3661 | |
| 3662 | 3662 | $class_original = $this->options['widget_ops']['classname']; |
| 3663 | - $class = $this->options['widget_ops']['classname']." sdel-".$this->get_instance_hash(); |
|
| 3663 | + $class = $this->options['widget_ops']['classname'] . " sdel-" . $this->get_instance_hash(); |
|
| 3664 | 3664 | |
| 3665 | 3665 | // Before widget |
| 3666 | 3666 | $before_widget = $args['before_widget']; |
| 3667 | - $before_widget = str_replace($class_original,$class,$before_widget); |
|
| 3668 | - $before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this ); |
|
| 3669 | - $before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this ); |
|
| 3667 | + $before_widget = str_replace($class_original, $class, $before_widget); |
|
| 3668 | + $before_widget = apply_filters('wp_super_duper_before_widget', $before_widget, $args, $instance, $this); |
|
| 3669 | + $before_widget = apply_filters('wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this); |
|
| 3670 | 3670 | |
| 3671 | 3671 | // After widget |
| 3672 | 3672 | $after_widget = $args['after_widget']; |
| 3673 | - $after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this ); |
|
| 3674 | - $after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this ); |
|
| 3673 | + $after_widget = apply_filters('wp_super_duper_after_widget', $after_widget, $args, $instance, $this); |
|
| 3674 | + $after_widget = apply_filters('wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this); |
|
| 3675 | 3675 | |
| 3676 | 3676 | echo $before_widget; |
| 3677 | 3677 | // elementor strips the widget wrapping div so we check for and add it back if needed |
| 3678 | - if ( $this->is_elementor_widget_output() ) { |
|
| 3678 | + if ($this->is_elementor_widget_output()) { |
|
| 3679 | 3679 | // Filter class & attrs for elementor widget output. |
| 3680 | - $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this ); |
|
| 3681 | - $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this ); |
|
| 3680 | + $class = apply_filters('wp_super_duper_div_classname', $class, $args, $this); |
|
| 3681 | + $class = apply_filters('wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this); |
|
| 3682 | 3682 | |
| 3683 | - $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this ); |
|
| 3684 | - $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this ); |
|
| 3683 | + $attrs = apply_filters('wp_super_duper_div_attrs', '', $args, $this); |
|
| 3684 | + $attrs = apply_filters('wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this); |
|
| 3685 | 3685 | |
| 3686 | - echo "<span class='" . esc_attr( $class ) . "' " . $attrs . ">"; |
|
| 3686 | + echo "<span class='" . esc_attr($class) . "' " . $attrs . ">"; |
|
| 3687 | 3687 | } |
| 3688 | - echo $this->output_title( $args, $instance ); |
|
| 3688 | + echo $this->output_title($args, $instance); |
|
| 3689 | 3689 | echo $output; |
| 3690 | - if ( $this->is_elementor_widget_output() ) { |
|
| 3690 | + if ($this->is_elementor_widget_output()) { |
|
| 3691 | 3691 | echo "</span>"; |
| 3692 | 3692 | } |
| 3693 | 3693 | echo $after_widget; |
| 3694 | - } elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty |
|
| 3695 | - $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" ); |
|
| 3694 | + } elseif ($this->is_preview() && $output == '') {// if preview show a placeholder if empty |
|
| 3695 | + $output = $this->preview_placeholder_text("{{" . $this->base_id . "}}"); |
|
| 3696 | 3696 | echo $output; |
| 3697 | - } elseif ( $output && $no_wrap ) { |
|
| 3697 | + } elseif ($output && $no_wrap) { |
|
| 3698 | 3698 | echo $output; |
| 3699 | 3699 | } |
| 3700 | 3700 | $output = ob_get_clean(); |
| 3701 | 3701 | |
| 3702 | - $output = apply_filters( 'wp_super_duper_widget_output', $output, $instance, $args, $this ); |
|
| 3702 | + $output = apply_filters('wp_super_duper_widget_output', $output, $instance, $args, $this); |
|
| 3703 | 3703 | |
| 3704 | 3704 | echo $output; |
| 3705 | 3705 | } |
@@ -3712,7 +3712,7 @@ discard block |
||
| 3712 | 3712 | */ |
| 3713 | 3713 | public function is_elementor_widget_output() { |
| 3714 | 3714 | $result = false; |
| 3715 | - if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) { |
|
| 3715 | + if (defined('ELEMENTOR_VERSION') && isset($this->number) && $this->number == 'REPLACE_TO_ID') { |
|
| 3716 | 3716 | $result = true; |
| 3717 | 3717 | } |
| 3718 | 3718 | |
@@ -3727,7 +3727,7 @@ discard block |
||
| 3727 | 3727 | */ |
| 3728 | 3728 | public function is_elementor_preview() { |
| 3729 | 3729 | $result = false; |
| 3730 | - if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) { |
|
| 3730 | + if (isset($_REQUEST['elementor-preview']) || (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor') || (isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor_ajax')) { |
|
| 3731 | 3731 | $result = true; |
| 3732 | 3732 | } |
| 3733 | 3733 | |
@@ -3742,7 +3742,7 @@ discard block |
||
| 3742 | 3742 | */ |
| 3743 | 3743 | public function is_divi_preview() { |
| 3744 | 3744 | $result = false; |
| 3745 | - if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) { |
|
| 3745 | + if (isset($_REQUEST['et_fb']) || isset($_REQUEST['et_pb_preview']) || (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor')) { |
|
| 3746 | 3746 | $result = true; |
| 3747 | 3747 | } |
| 3748 | 3748 | |
@@ -3757,7 +3757,7 @@ discard block |
||
| 3757 | 3757 | */ |
| 3758 | 3758 | public function is_beaver_preview() { |
| 3759 | 3759 | $result = false; |
| 3760 | - if ( isset( $_REQUEST['fl_builder'] ) ) { |
|
| 3760 | + if (isset($_REQUEST['fl_builder'])) { |
|
| 3761 | 3761 | $result = true; |
| 3762 | 3762 | } |
| 3763 | 3763 | |
@@ -3772,7 +3772,7 @@ discard block |
||
| 3772 | 3772 | */ |
| 3773 | 3773 | public function is_siteorigin_preview() { |
| 3774 | 3774 | $result = false; |
| 3775 | - if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) { |
|
| 3775 | + if (!empty($_REQUEST['siteorigin_panels_live_editor'])) { |
|
| 3776 | 3776 | $result = true; |
| 3777 | 3777 | } |
| 3778 | 3778 | |
@@ -3787,7 +3787,7 @@ discard block |
||
| 3787 | 3787 | */ |
| 3788 | 3788 | public function is_cornerstone_preview() { |
| 3789 | 3789 | $result = false; |
| 3790 | - if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) { |
|
| 3790 | + if (!empty($_REQUEST['cornerstone_preview']) || basename($_SERVER['REQUEST_URI']) == 'cornerstone-endpoint') { |
|
| 3791 | 3791 | $result = true; |
| 3792 | 3792 | } |
| 3793 | 3793 | |
@@ -3802,7 +3802,7 @@ discard block |
||
| 3802 | 3802 | */ |
| 3803 | 3803 | public function is_fusion_preview() { |
| 3804 | 3804 | $result = false; |
| 3805 | - if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) { |
|
| 3805 | + if (!empty($_REQUEST['fb-edit']) || !empty($_REQUEST['fusion_load_nonce'])) { |
|
| 3806 | 3806 | $result = true; |
| 3807 | 3807 | } |
| 3808 | 3808 | |
@@ -3817,7 +3817,7 @@ discard block |
||
| 3817 | 3817 | */ |
| 3818 | 3818 | public function is_oxygen_preview() { |
| 3819 | 3819 | $result = false; |
| 3820 | - if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) { |
|
| 3820 | + if (!empty($_REQUEST['ct_builder']) || (!empty($_REQUEST['action']) && (substr($_REQUEST['action'], 0, 11) === "oxy_render_" || substr($_REQUEST['action'], 0, 10) === "ct_render_"))) { |
|
| 3821 | 3821 | $result = true; |
| 3822 | 3822 | } |
| 3823 | 3823 | |
@@ -3832,21 +3832,21 @@ discard block |
||
| 3832 | 3832 | */ |
| 3833 | 3833 | public function is_preview() { |
| 3834 | 3834 | $preview = false; |
| 3835 | - if ( $this->is_divi_preview() ) { |
|
| 3835 | + if ($this->is_divi_preview()) { |
|
| 3836 | 3836 | $preview = true; |
| 3837 | - } elseif ( $this->is_elementor_preview() ) { |
|
| 3837 | + } elseif ($this->is_elementor_preview()) { |
|
| 3838 | 3838 | $preview = true; |
| 3839 | - } elseif ( $this->is_beaver_preview() ) { |
|
| 3839 | + } elseif ($this->is_beaver_preview()) { |
|
| 3840 | 3840 | $preview = true; |
| 3841 | - } elseif ( $this->is_siteorigin_preview() ) { |
|
| 3841 | + } elseif ($this->is_siteorigin_preview()) { |
|
| 3842 | 3842 | $preview = true; |
| 3843 | - } elseif ( $this->is_cornerstone_preview() ) { |
|
| 3843 | + } elseif ($this->is_cornerstone_preview()) { |
|
| 3844 | 3844 | $preview = true; |
| 3845 | - } elseif ( $this->is_fusion_preview() ) { |
|
| 3845 | + } elseif ($this->is_fusion_preview()) { |
|
| 3846 | 3846 | $preview = true; |
| 3847 | - } elseif ( $this->is_oxygen_preview() ) { |
|
| 3847 | + } elseif ($this->is_oxygen_preview()) { |
|
| 3848 | 3848 | $preview = true; |
| 3849 | - } elseif( $this->is_block_content_call() ) { |
|
| 3849 | + } elseif ($this->is_block_content_call()) { |
|
| 3850 | 3850 | $preview = true; |
| 3851 | 3851 | } |
| 3852 | 3852 | |
@@ -3861,34 +3861,34 @@ discard block |
||
| 3861 | 3861 | * |
| 3862 | 3862 | * @return string |
| 3863 | 3863 | */ |
| 3864 | - public function output_title( $args, $instance = array() ) { |
|
| 3864 | + public function output_title($args, $instance = array()) { |
|
| 3865 | 3865 | $output = ''; |
| 3866 | - if ( ! empty( $instance['title'] ) ) { |
|
| 3866 | + if (!empty($instance['title'])) { |
|
| 3867 | 3867 | /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ |
| 3868 | - $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); |
|
| 3868 | + $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base); |
|
| 3869 | 3869 | |
| 3870 | - if(empty($instance['widget_title_tag'])){ |
|
| 3870 | + if (empty($instance['widget_title_tag'])) { |
|
| 3871 | 3871 | $output = $args['before_title'] . $title . $args['after_title']; |
| 3872 | - }else{ |
|
| 3873 | - $title_tag = esc_attr( $instance['widget_title_tag'] ); |
|
| 3872 | + } else { |
|
| 3873 | + $title_tag = esc_attr($instance['widget_title_tag']); |
|
| 3874 | 3874 | |
| 3875 | 3875 | // classes |
| 3876 | 3876 | $title_classes = array(); |
| 3877 | - $title_classes[] = !empty( $instance['widget_title_size_class'] ) ? sanitize_html_class( $instance['widget_title_size_class'] ) : ''; |
|
| 3878 | - $title_classes[] = !empty( $instance['widget_title_align_class'] ) ? sanitize_html_class( $instance['widget_title_align_class'] ) : ''; |
|
| 3879 | - $title_classes[] = !empty( $instance['widget_title_color_class'] ) ? "text-".sanitize_html_class( $instance['widget_title_color_class'] ) : ''; |
|
| 3880 | - $title_classes[] = !empty( $instance['widget_title_border_class'] ) ? sanitize_html_class( $instance['widget_title_border_class'] ) : ''; |
|
| 3881 | - $title_classes[] = !empty( $instance['widget_title_border_color_class'] ) ? "border-".sanitize_html_class( $instance['widget_title_border_color_class'] ) : ''; |
|
| 3882 | - $title_classes[] = !empty( $instance['widget_title_mt_class'] ) ? "mt-".absint( $instance['widget_title_mt_class'] ) : ''; |
|
| 3883 | - $title_classes[] = !empty( $instance['widget_title_mr_class'] ) ? "mr-".absint( $instance['widget_title_mr_class'] ) : ''; |
|
| 3884 | - $title_classes[] = !empty( $instance['widget_title_mb_class'] ) ? "mb-".absint( $instance['widget_title_mb_class'] ) : ''; |
|
| 3885 | - $title_classes[] = !empty( $instance['widget_title_ml_class'] ) ? "ml-".absint( $instance['widget_title_ml_class'] ) : ''; |
|
| 3886 | - $title_classes[] = !empty( $instance['widget_title_pt_class'] ) ? "pt-".absint( $instance['widget_title_pt_class'] ) : ''; |
|
| 3887 | - $title_classes[] = !empty( $instance['widget_title_pr_class'] ) ? "pr-".absint( $instance['widget_title_pr_class'] ) : ''; |
|
| 3888 | - $title_classes[] = !empty( $instance['widget_title_pb_class'] ) ? "pb-".absint( $instance['widget_title_pb_class'] ) : ''; |
|
| 3889 | - $title_classes[] = !empty( $instance['widget_title_pl_class'] ) ? "pl-".absint( $instance['widget_title_pl_class'] ) : ''; |
|
| 3890 | - |
|
| 3891 | - $class = !empty( $title_classes ) ? implode(" ",$title_classes) : ''; |
|
| 3877 | + $title_classes[] = !empty($instance['widget_title_size_class']) ? sanitize_html_class($instance['widget_title_size_class']) : ''; |
|
| 3878 | + $title_classes[] = !empty($instance['widget_title_align_class']) ? sanitize_html_class($instance['widget_title_align_class']) : ''; |
|
| 3879 | + $title_classes[] = !empty($instance['widget_title_color_class']) ? "text-" . sanitize_html_class($instance['widget_title_color_class']) : ''; |
|
| 3880 | + $title_classes[] = !empty($instance['widget_title_border_class']) ? sanitize_html_class($instance['widget_title_border_class']) : ''; |
|
| 3881 | + $title_classes[] = !empty($instance['widget_title_border_color_class']) ? "border-" . sanitize_html_class($instance['widget_title_border_color_class']) : ''; |
|
| 3882 | + $title_classes[] = !empty($instance['widget_title_mt_class']) ? "mt-" . absint($instance['widget_title_mt_class']) : ''; |
|
| 3883 | + $title_classes[] = !empty($instance['widget_title_mr_class']) ? "mr-" . absint($instance['widget_title_mr_class']) : ''; |
|
| 3884 | + $title_classes[] = !empty($instance['widget_title_mb_class']) ? "mb-" . absint($instance['widget_title_mb_class']) : ''; |
|
| 3885 | + $title_classes[] = !empty($instance['widget_title_ml_class']) ? "ml-" . absint($instance['widget_title_ml_class']) : ''; |
|
| 3886 | + $title_classes[] = !empty($instance['widget_title_pt_class']) ? "pt-" . absint($instance['widget_title_pt_class']) : ''; |
|
| 3887 | + $title_classes[] = !empty($instance['widget_title_pr_class']) ? "pr-" . absint($instance['widget_title_pr_class']) : ''; |
|
| 3888 | + $title_classes[] = !empty($instance['widget_title_pb_class']) ? "pb-" . absint($instance['widget_title_pb_class']) : ''; |
|
| 3889 | + $title_classes[] = !empty($instance['widget_title_pl_class']) ? "pl-" . absint($instance['widget_title_pl_class']) : ''; |
|
| 3890 | + |
|
| 3891 | + $class = !empty($title_classes) ? implode(" ", $title_classes) : ''; |
|
| 3892 | 3892 | $output = "<$title_tag class='$class' >$title</$title_tag>"; |
| 3893 | 3893 | } |
| 3894 | 3894 | |
@@ -3902,7 +3902,7 @@ discard block |
||
| 3902 | 3902 | * |
| 3903 | 3903 | * @param array $instance The widget options. |
| 3904 | 3904 | */ |
| 3905 | - public function form( $instance ) { |
|
| 3905 | + public function form($instance) { |
|
| 3906 | 3906 | |
| 3907 | 3907 | // set widget instance |
| 3908 | 3908 | $this->instance = $instance; |
@@ -3910,20 +3910,20 @@ discard block |
||
| 3910 | 3910 | // set it as a SD widget |
| 3911 | 3911 | echo $this->widget_advanced_toggle(); |
| 3912 | 3912 | |
| 3913 | - echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>"; |
|
| 3913 | + echo "<p>" . esc_attr($this->options['widget_ops']['description']) . "</p>"; |
|
| 3914 | 3914 | $arguments_raw = $this->get_arguments(); |
| 3915 | 3915 | |
| 3916 | - if ( is_array( $arguments_raw ) ) { |
|
| 3916 | + if (is_array($arguments_raw)) { |
|
| 3917 | 3917 | |
| 3918 | - $arguments = $this->group_arguments( $arguments_raw ); |
|
| 3918 | + $arguments = $this->group_arguments($arguments_raw); |
|
| 3919 | 3919 | |
| 3920 | 3920 | // Do we have sections? |
| 3921 | 3921 | $has_sections = $arguments == $arguments_raw ? false : true; |
| 3922 | 3922 | |
| 3923 | 3923 | |
| 3924 | - if ( $has_sections ) { |
|
| 3924 | + if ($has_sections) { |
|
| 3925 | 3925 | $panel_count = 0; |
| 3926 | - foreach ( $arguments as $key => $args ) { |
|
| 3926 | + foreach ($arguments as $key => $args) { |
|
| 3927 | 3927 | |
| 3928 | 3928 | ?> |
| 3929 | 3929 | <script> |
@@ -3933,26 +3933,26 @@ discard block |
||
| 3933 | 3933 | |
| 3934 | 3934 | $hide = $panel_count ? ' style="display:none;" ' : ''; |
| 3935 | 3935 | $icon_class = $panel_count ? 'fas fa-chevron-up' : 'fas fa-chevron-down'; |
| 3936 | - echo "<button onclick='jQuery(this).find(\"i\").toggleClass(\"fas fa-chevron-up fas fa-chevron-down\");jQuery(this).next().slideToggle();' type='button' class='sd-toggle-group-button sd-input-group-toggle" . sanitize_title_with_dashes( $key ) . "'>" . esc_attr( $key ) . " <i style='float:right;' class='" . $icon_class . "'></i></button>"; |
|
| 3937 | - echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes( $key ) . "' $hide>"; |
|
| 3936 | + echo "<button onclick='jQuery(this).find(\"i\").toggleClass(\"fas fa-chevron-up fas fa-chevron-down\");jQuery(this).next().slideToggle();' type='button' class='sd-toggle-group-button sd-input-group-toggle" . sanitize_title_with_dashes($key) . "'>" . esc_attr($key) . " <i style='float:right;' class='" . $icon_class . "'></i></button>"; |
|
| 3937 | + echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes($key) . "' $hide>"; |
|
| 3938 | 3938 | |
| 3939 | - foreach ( $args as $k => $a ) { |
|
| 3939 | + foreach ($args as $k => $a) { |
|
| 3940 | 3940 | |
| 3941 | 3941 | $this->widget_inputs_row_start($k, $a); |
| 3942 | - $this->widget_inputs( $a, $instance ); |
|
| 3942 | + $this->widget_inputs($a, $instance); |
|
| 3943 | 3943 | $this->widget_inputs_row_end($k, $a); |
| 3944 | 3944 | |
| 3945 | 3945 | } |
| 3946 | 3946 | |
| 3947 | 3947 | echo "</div>"; |
| 3948 | 3948 | |
| 3949 | - $panel_count ++; |
|
| 3949 | + $panel_count++; |
|
| 3950 | 3950 | |
| 3951 | 3951 | } |
| 3952 | 3952 | } else { |
| 3953 | - foreach ( $arguments as $key => $args ) { |
|
| 3953 | + foreach ($arguments as $key => $args) { |
|
| 3954 | 3954 | $this->widget_inputs_row_start($key, $args); |
| 3955 | - $this->widget_inputs( $args, $instance ); |
|
| 3955 | + $this->widget_inputs($args, $instance); |
|
| 3956 | 3956 | $this->widget_inputs_row_end($key, $args); |
| 3957 | 3957 | } |
| 3958 | 3958 | } |
@@ -3960,33 +3960,33 @@ discard block |
||
| 3960 | 3960 | } |
| 3961 | 3961 | } |
| 3962 | 3962 | |
| 3963 | - public function widget_inputs_row_start($key, $args){ |
|
| 3964 | - if(!empty($args['row'])){ |
|
| 3963 | + public function widget_inputs_row_start($key, $args) { |
|
| 3964 | + if (!empty($args['row'])) { |
|
| 3965 | 3965 | // maybe open |
| 3966 | - if(!empty($args['row']['open'])){ |
|
| 3966 | + if (!empty($args['row']['open'])) { |
|
| 3967 | 3967 | ?> |
| 3968 | - <div class='bsui sd-argument ' data-argument='<?php echo esc_attr( $args['row']['key'] ); ?>' data-element_require='<?php if ( !empty($args['row']['element_require'])) { |
|
| 3969 | - echo $this->convert_element_require( $args['row']['element_require'] ); |
|
| 3968 | + <div class='bsui sd-argument ' data-argument='<?php echo esc_attr($args['row']['key']); ?>' data-element_require='<?php if (!empty($args['row']['element_require'])) { |
|
| 3969 | + echo $this->convert_element_require($args['row']['element_require']); |
|
| 3970 | 3970 | } ?>'> |
| 3971 | - <?php if(!empty($args['row']['title'])){ ?> |
|
| 3972 | - <label class="mb-0 "><?php echo esc_attr( $args['row']['title'] ); ?><?php echo $this->widget_field_desc( $args['row'] ); ?></label> |
|
| 3971 | + <?php if (!empty($args['row']['title'])) { ?> |
|
| 3972 | + <label class="mb-0 "><?php echo esc_attr($args['row']['title']); ?><?php echo $this->widget_field_desc($args['row']); ?></label> |
|
| 3973 | 3973 | <?php }?> |
| 3974 | - <div class='row <?php if(!empty($args['row']['class'])){ echo esc_attr($args['row']['class']);} ?>'> |
|
| 3974 | + <div class='row <?php if (!empty($args['row']['class'])) { echo esc_attr($args['row']['class']); } ?>'> |
|
| 3975 | 3975 | <div class='col pr-2'> |
| 3976 | 3976 | <?php |
| 3977 | - }elseif(!empty($args['row']['close'])){ |
|
| 3977 | + }elseif (!empty($args['row']['close'])) { |
|
| 3978 | 3978 | echo "<div class='col pl-0'>"; |
| 3979 | - }else{ |
|
| 3979 | + } else { |
|
| 3980 | 3980 | echo "<div class='col pl-0 pr-2'>"; |
| 3981 | 3981 | } |
| 3982 | 3982 | } |
| 3983 | 3983 | } |
| 3984 | 3984 | |
| 3985 | - public function widget_inputs_row_end($key, $args){ |
|
| 3985 | + public function widget_inputs_row_end($key, $args) { |
|
| 3986 | 3986 | |
| 3987 | - if(!empty($args['row'])){ |
|
| 3987 | + if (!empty($args['row'])) { |
|
| 3988 | 3988 | // maybe close |
| 3989 | - if(!empty($args['row']['close'])){ |
|
| 3989 | + if (!empty($args['row']['close'])) { |
|
| 3990 | 3990 | echo "</div></div>"; |
| 3991 | 3991 | } |
| 3992 | 3992 | |
@@ -4002,7 +4002,7 @@ discard block |
||
| 4002 | 4002 | public function widget_advanced_toggle() { |
| 4003 | 4003 | |
| 4004 | 4004 | $output = ''; |
| 4005 | - if ( $this->block_show_advanced() ) { |
|
| 4005 | + if ($this->block_show_advanced()) { |
|
| 4006 | 4006 | $val = 1; |
| 4007 | 4007 | } else { |
| 4008 | 4008 | $val = 0; |
@@ -4022,14 +4022,14 @@ discard block |
||
| 4022 | 4022 | *@since 1.0.0 |
| 4023 | 4023 | * |
| 4024 | 4024 | */ |
| 4025 | - public function convert_element_require( $input ) { |
|
| 4025 | + public function convert_element_require($input) { |
|
| 4026 | 4026 | |
| 4027 | - $input = str_replace( "'", '"', $input );// we only want double quotes |
|
| 4027 | + $input = str_replace("'", '"', $input); // we only want double quotes |
|
| 4028 | 4028 | |
| 4029 | - $output = esc_attr( str_replace( array( "[%", "%]" ), array( |
|
| 4029 | + $output = esc_attr(str_replace(array("[%", "%]"), array( |
|
| 4030 | 4030 | "jQuery(form).find('[data-argument=\"", |
| 4031 | 4031 | "\"]').find('input,select,textarea').val()" |
| 4032 | - ), $input ) ); |
|
| 4032 | + ), $input)); |
|
| 4033 | 4033 | |
| 4034 | 4034 | return $output; |
| 4035 | 4035 | } |
@@ -4040,56 +4040,56 @@ discard block |
||
| 4040 | 4040 | * @param $args |
| 4041 | 4041 | * @param $instance |
| 4042 | 4042 | */ |
| 4043 | - public function widget_inputs( $args, $instance ) { |
|
| 4043 | + public function widget_inputs($args, $instance) { |
|
| 4044 | 4044 | |
| 4045 | 4045 | $class = ""; |
| 4046 | 4046 | $element_require = ""; |
| 4047 | 4047 | $custom_attributes = ""; |
| 4048 | 4048 | |
| 4049 | 4049 | // get value |
| 4050 | - if ( isset( $instance[ $args['name'] ] ) ) { |
|
| 4051 | - $value = $instance[ $args['name'] ]; |
|
| 4052 | - } elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) { |
|
| 4053 | - $value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] ); |
|
| 4050 | + if (isset($instance[$args['name']])) { |
|
| 4051 | + $value = $instance[$args['name']]; |
|
| 4052 | + } elseif (!isset($instance[$args['name']]) && !empty($args['default'])) { |
|
| 4053 | + $value = is_array($args['default']) ? array_map("esc_html", $args['default']) : esc_html($args['default']); |
|
| 4054 | 4054 | } else { |
| 4055 | 4055 | $value = ''; |
| 4056 | 4056 | } |
| 4057 | 4057 | |
| 4058 | 4058 | // get placeholder |
| 4059 | - if ( ! empty( $args['placeholder'] ) ) { |
|
| 4060 | - $placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'"; |
|
| 4059 | + if (!empty($args['placeholder'])) { |
|
| 4060 | + $placeholder = "placeholder='" . esc_html($args['placeholder']) . "'"; |
|
| 4061 | 4061 | } else { |
| 4062 | 4062 | $placeholder = ''; |
| 4063 | 4063 | } |
| 4064 | 4064 | |
| 4065 | 4065 | // get if advanced |
| 4066 | - if ( isset( $args['advanced'] ) && $args['advanced'] ) { |
|
| 4066 | + if (isset($args['advanced']) && $args['advanced']) { |
|
| 4067 | 4067 | $class .= " sd-advanced-setting "; |
| 4068 | 4068 | } |
| 4069 | 4069 | |
| 4070 | 4070 | // element_require |
| 4071 | - if ( isset( $args['element_require'] ) && $args['element_require'] ) { |
|
| 4071 | + if (isset($args['element_require']) && $args['element_require']) { |
|
| 4072 | 4072 | $element_require = $args['element_require']; |
| 4073 | 4073 | } |
| 4074 | 4074 | |
| 4075 | 4075 | // custom_attributes |
| 4076 | - if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) { |
|
| 4077 | - $custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true ); |
|
| 4076 | + if (isset($args['custom_attributes']) && $args['custom_attributes']) { |
|
| 4077 | + $custom_attributes = $this->array_to_attributes($args['custom_attributes'], true); |
|
| 4078 | 4078 | } |
| 4079 | 4079 | |
| 4080 | 4080 | |
| 4081 | 4081 | // before wrapper |
| 4082 | 4082 | ?> |
| 4083 | - <p class="sd-argument <?php echo esc_attr( $class ); ?>" |
|
| 4084 | - data-argument='<?php echo esc_attr( $args['name'] ); ?>' |
|
| 4085 | - data-element_require='<?php if ( $element_require ) { |
|
| 4086 | - echo $this->convert_element_require( $element_require ); |
|
| 4083 | + <p class="sd-argument <?php echo esc_attr($class); ?>" |
|
| 4084 | + data-argument='<?php echo esc_attr($args['name']); ?>' |
|
| 4085 | + data-element_require='<?php if ($element_require) { |
|
| 4086 | + echo $this->convert_element_require($element_require); |
|
| 4087 | 4087 | } ?>' |
| 4088 | 4088 | > |
| 4089 | 4089 | <?php |
| 4090 | 4090 | |
| 4091 | 4091 | |
| 4092 | - switch ( $args['type'] ) { |
|
| 4092 | + switch ($args['type']) { |
|
| 4093 | 4093 | //array('text','password','number','email','tel','url','color') |
| 4094 | 4094 | case "text": |
| 4095 | 4095 | case "password": |
@@ -4100,46 +4100,46 @@ discard block |
||
| 4100 | 4100 | case "color": |
| 4101 | 4101 | ?> |
| 4102 | 4102 | <label |
| 4103 | - for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args );?><?php echo $this->widget_field_desc( $args ); ?></label> |
|
| 4103 | + for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo $this->widget_field_title($args); ?><?php echo $this->widget_field_desc($args); ?></label> |
|
| 4104 | 4104 | <input <?php echo $placeholder; ?> class="widefat" |
| 4105 | 4105 | <?php echo $custom_attributes; ?> |
| 4106 | - id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
|
| 4107 | - name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" |
|
| 4108 | - type="<?php echo esc_attr( $args['type'] ); ?>" |
|
| 4109 | - value="<?php echo esc_attr( $value ); ?>"> |
|
| 4106 | + id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" |
|
| 4107 | + name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" |
|
| 4108 | + type="<?php echo esc_attr($args['type']); ?>" |
|
| 4109 | + value="<?php echo esc_attr($value); ?>"> |
|
| 4110 | 4110 | <?php |
| 4111 | 4111 | |
| 4112 | 4112 | break; |
| 4113 | 4113 | case "select": |
| 4114 | - $multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false; |
|
| 4115 | - if ( $multiple ) { |
|
| 4116 | - if ( empty( $value ) ) { |
|
| 4114 | + $multiple = isset($args['multiple']) && $args['multiple'] ? true : false; |
|
| 4115 | + if ($multiple) { |
|
| 4116 | + if (empty($value)) { |
|
| 4117 | 4117 | $value = array(); |
| 4118 | 4118 | } |
| 4119 | 4119 | } |
| 4120 | 4120 | ?> |
| 4121 | 4121 | <label |
| 4122 | - for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args ); ?><?php echo $this->widget_field_desc( $args ); ?></label> |
|
| 4122 | + for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo $this->widget_field_title($args); ?><?php echo $this->widget_field_desc($args); ?></label> |
|
| 4123 | 4123 | <select <?php echo $placeholder; ?> class="widefat" |
| 4124 | 4124 | <?php echo $custom_attributes; ?> |
| 4125 | - id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
|
| 4126 | - name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); |
|
| 4127 | - if ( $multiple ) { |
|
| 4125 | + id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" |
|
| 4126 | + name="<?php echo esc_attr($this->get_field_name($args['name'])); |
|
| 4127 | + if ($multiple) { |
|
| 4128 | 4128 | echo "[]"; |
| 4129 | 4129 | } ?>" |
| 4130 | - <?php if ( $multiple ) { |
|
| 4130 | + <?php if ($multiple) { |
|
| 4131 | 4131 | echo "multiple"; |
| 4132 | 4132 | } //@todo not implemented yet due to gutenberg not supporting it |
| 4133 | 4133 | ?> |
| 4134 | 4134 | > |
| 4135 | 4135 | <?php |
| 4136 | 4136 | |
| 4137 | - if ( ! empty( $args['options'] ) ) { |
|
| 4138 | - foreach ( $args['options'] as $val => $label ) { |
|
| 4139 | - if ( $multiple ) { |
|
| 4140 | - $selected = in_array( $val, $value ) ? 'selected="selected"' : ''; |
|
| 4137 | + if (!empty($args['options'])) { |
|
| 4138 | + foreach ($args['options'] as $val => $label) { |
|
| 4139 | + if ($multiple) { |
|
| 4140 | + $selected = in_array($val, $value) ? 'selected="selected"' : ''; |
|
| 4141 | 4141 | } else { |
| 4142 | - $selected = selected( $value, $val, false ); |
|
| 4142 | + $selected = selected($value, $val, false); |
|
| 4143 | 4143 | } |
| 4144 | 4144 | echo "<option value='$val' " . $selected . ">$label</option>"; |
| 4145 | 4145 | } |
@@ -4151,32 +4151,32 @@ discard block |
||
| 4151 | 4151 | case "checkbox": |
| 4152 | 4152 | ?> |
| 4153 | 4153 | <input <?php echo $placeholder; ?> |
| 4154 | - <?php checked( 1, $value, true ) ?> |
|
| 4154 | + <?php checked(1, $value, true) ?> |
|
| 4155 | 4155 | <?php echo $custom_attributes; ?> |
| 4156 | - class="widefat" id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
|
| 4157 | - name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="checkbox" |
|
| 4156 | + class="widefat" id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" |
|
| 4157 | + name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" type="checkbox" |
|
| 4158 | 4158 | value="1"> |
| 4159 | 4159 | <label |
| 4160 | - for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args );?><?php echo $this->widget_field_desc( $args ); ?></label> |
|
| 4160 | + for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo $this->widget_field_title($args); ?><?php echo $this->widget_field_desc($args); ?></label> |
|
| 4161 | 4161 | <?php |
| 4162 | 4162 | break; |
| 4163 | 4163 | case "textarea": |
| 4164 | 4164 | ?> |
| 4165 | 4165 | <label |
| 4166 | - for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args ); ?><?php echo $this->widget_field_desc( $args ); ?></label> |
|
| 4166 | + for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo $this->widget_field_title($args); ?><?php echo $this->widget_field_desc($args); ?></label> |
|
| 4167 | 4167 | <textarea <?php echo $placeholder; ?> class="widefat" |
| 4168 | 4168 | <?php echo $custom_attributes; ?> |
| 4169 | - id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
|
| 4170 | - name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" |
|
| 4171 | - ><?php echo esc_attr( $value ); ?></textarea> |
|
| 4169 | + id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" |
|
| 4170 | + name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" |
|
| 4171 | + ><?php echo esc_attr($value); ?></textarea> |
|
| 4172 | 4172 | <?php |
| 4173 | 4173 | |
| 4174 | 4174 | break; |
| 4175 | 4175 | case "hidden": |
| 4176 | 4176 | ?> |
| 4177 | - <input id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
|
| 4178 | - name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="hidden" |
|
| 4179 | - value="<?php echo esc_attr( $value ); ?>"> |
|
| 4177 | + <input id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" |
|
| 4178 | + name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" type="hidden" |
|
| 4179 | + value="<?php echo esc_attr($value); ?>"> |
|
| 4180 | 4180 | <?php |
| 4181 | 4181 | break; |
| 4182 | 4182 | default: |
@@ -4191,15 +4191,15 @@ discard block |
||
| 4191 | 4191 | |
| 4192 | 4192 | } |
| 4193 | 4193 | |
| 4194 | - public function get_widget_icon($icon = 'box-top', $title = ''){ |
|
| 4195 | - if($icon=='box-top'){ |
|
| 4196 | - return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.048" height="9.017" fill="#555D66"></rect><rect x="16.265" y="5.498" width="1.023" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.186" width="8.964" height="2.482" fill="#272B2F"></rect><rect x="5.487" y="16.261" width="9.026" height="1.037" fill="#555D66"></rect></svg>'; |
|
| 4197 | - }elseif($icon=='box-right'){ |
|
| 4198 | - return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.046" height="9.017" fill="#555D66"></rect><rect x="15.244" y="5.498" width="2.518" height="9.003" fill="#272B2F"></rect><rect x="5.518" y="2.719" width="8.964" height="0.954" fill="#555D66"></rect><rect x="5.487" y="16.308" width="9.026" height="0.99" fill="#555D66"></rect></svg>'; |
|
| 4199 | - }elseif($icon=='box-bottom'){ |
|
| 4200 | - return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1" height="9.017" fill="#555D66"></rect><rect x="16.261" y="5.498" width="1.027" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.968" fill="#555D66"></rect><rect x="5.487" y="15.28" width="9.026" height="2.499" fill="#272B2F"></rect></svg>'; |
|
| 4201 | - }elseif($icon=='box-left'){ |
|
| 4202 | - return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.202" y="5.492" width="2.503" height="9.017" fill="#272B2F"></rect><rect x="16.276" y="5.498" width="1.012" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.966" fill="#555D66"></rect><rect x="5.487" y="16.303" width="9.026" height="0.995" fill="#555D66"></rect></svg>'; |
|
| 4194 | + public function get_widget_icon($icon = 'box-top', $title = '') { |
|
| 4195 | + if ($icon == 'box-top') { |
|
| 4196 | + return '<svg title="' . esc_attr($title) . '" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.048" height="9.017" fill="#555D66"></rect><rect x="16.265" y="5.498" width="1.023" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.186" width="8.964" height="2.482" fill="#272B2F"></rect><rect x="5.487" y="16.261" width="9.026" height="1.037" fill="#555D66"></rect></svg>'; |
|
| 4197 | + }elseif ($icon == 'box-right') { |
|
| 4198 | + return '<svg title="' . esc_attr($title) . '" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.046" height="9.017" fill="#555D66"></rect><rect x="15.244" y="5.498" width="2.518" height="9.003" fill="#272B2F"></rect><rect x="5.518" y="2.719" width="8.964" height="0.954" fill="#555D66"></rect><rect x="5.487" y="16.308" width="9.026" height="0.99" fill="#555D66"></rect></svg>'; |
|
| 4199 | + }elseif ($icon == 'box-bottom') { |
|
| 4200 | + return '<svg title="' . esc_attr($title) . '" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1" height="9.017" fill="#555D66"></rect><rect x="16.261" y="5.498" width="1.027" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.968" fill="#555D66"></rect><rect x="5.487" y="15.28" width="9.026" height="2.499" fill="#272B2F"></rect></svg>'; |
|
| 4201 | + }elseif ($icon == 'box-left') { |
|
| 4202 | + return '<svg title="' . esc_attr($title) . '" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.202" y="5.492" width="2.503" height="9.017" fill="#272B2F"></rect><rect x="16.276" y="5.498" width="1.012" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.966" fill="#555D66"></rect><rect x="5.487" y="16.303" width="9.026" height="0.995" fill="#555D66"></rect></svg>'; |
|
| 4203 | 4203 | } |
| 4204 | 4204 | } |
| 4205 | 4205 | |
@@ -4211,14 +4211,14 @@ discard block |
||
| 4211 | 4211 | * @return string |
| 4212 | 4212 | * @todo, need to make its own tooltip script |
| 4213 | 4213 | */ |
| 4214 | - public function widget_field_desc( $args ) { |
|
| 4214 | + public function widget_field_desc($args) { |
|
| 4215 | 4215 | |
| 4216 | 4216 | $description = ''; |
| 4217 | - if ( isset( $args['desc'] ) && $args['desc'] ) { |
|
| 4218 | - if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) { |
|
| 4219 | - $description = $this->desc_tip( $args['desc'] ); |
|
| 4217 | + if (isset($args['desc']) && $args['desc']) { |
|
| 4218 | + if (isset($args['desc_tip']) && $args['desc_tip']) { |
|
| 4219 | + $description = $this->desc_tip($args['desc']); |
|
| 4220 | 4220 | } else { |
| 4221 | - $description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>'; |
|
| 4221 | + $description = '<span class="description">' . wp_kses_post($args['desc']) . '</span>'; |
|
| 4222 | 4222 | } |
| 4223 | 4223 | } |
| 4224 | 4224 | |
@@ -4232,12 +4232,12 @@ discard block |
||
| 4232 | 4232 | * |
| 4233 | 4233 | * @return string |
| 4234 | 4234 | */ |
| 4235 | - public function widget_field_title( $args ) { |
|
| 4235 | + public function widget_field_title($args) { |
|
| 4236 | 4236 | |
| 4237 | 4237 | $title = ''; |
| 4238 | - if ( isset( $args['title'] ) && $args['title'] ) { |
|
| 4239 | - if ( isset( $args['icon'] ) && $args['icon'] ) { |
|
| 4240 | - $title = self::get_widget_icon( $args['icon'], $args['title'] ); |
|
| 4238 | + if (isset($args['title']) && $args['title']) { |
|
| 4239 | + if (isset($args['icon']) && $args['icon']) { |
|
| 4240 | + $title = self::get_widget_icon($args['icon'], $args['title']); |
|
| 4241 | 4241 | } else { |
| 4242 | 4242 | $title = esc_attr($args['title']); |
| 4243 | 4243 | } |
@@ -4254,11 +4254,11 @@ discard block |
||
| 4254 | 4254 | * |
| 4255 | 4255 | * @return string |
| 4256 | 4256 | */ |
| 4257 | - function desc_tip( $tip, $allow_html = false ) { |
|
| 4258 | - if ( $allow_html ) { |
|
| 4259 | - $tip = $this->sanitize_tooltip( $tip ); |
|
| 4257 | + function desc_tip($tip, $allow_html = false) { |
|
| 4258 | + if ($allow_html) { |
|
| 4259 | + $tip = $this->sanitize_tooltip($tip); |
|
| 4260 | 4260 | } else { |
| 4261 | - $tip = esc_attr( $tip ); |
|
| 4261 | + $tip = esc_attr($tip); |
|
| 4262 | 4262 | } |
| 4263 | 4263 | |
| 4264 | 4264 | return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
@@ -4271,8 +4271,8 @@ discard block |
||
| 4271 | 4271 | * |
| 4272 | 4272 | * @return string |
| 4273 | 4273 | */ |
| 4274 | - public function sanitize_tooltip( $var ) { |
|
| 4275 | - return htmlspecialchars( wp_kses( html_entity_decode( $var ), array( |
|
| 4274 | + public function sanitize_tooltip($var) { |
|
| 4275 | + return htmlspecialchars(wp_kses(html_entity_decode($var), array( |
|
| 4276 | 4276 | 'br' => array(), |
| 4277 | 4277 | 'em' => array(), |
| 4278 | 4278 | 'strong' => array(), |
@@ -4282,7 +4282,7 @@ discard block |
||
| 4282 | 4282 | 'li' => array(), |
| 4283 | 4283 | 'ol' => array(), |
| 4284 | 4284 | 'p' => array(), |
| 4285 | - ) ) ); |
|
| 4285 | + ))); |
|
| 4286 | 4286 | } |
| 4287 | 4287 | |
| 4288 | 4288 | /** |
@@ -4294,23 +4294,23 @@ discard block |
||
| 4294 | 4294 | * @return array |
| 4295 | 4295 | * @todo we should add some sanitation here. |
| 4296 | 4296 | */ |
| 4297 | - public function update( $new_instance, $old_instance ) { |
|
| 4297 | + public function update($new_instance, $old_instance) { |
|
| 4298 | 4298 | |
| 4299 | 4299 | //save the widget |
| 4300 | - $instance = array_merge( (array) $old_instance, (array) $new_instance ); |
|
| 4300 | + $instance = array_merge((array) $old_instance, (array) $new_instance); |
|
| 4301 | 4301 | |
| 4302 | 4302 | // set widget instance |
| 4303 | 4303 | $this->instance = $instance; |
| 4304 | 4304 | |
| 4305 | - if ( empty( $this->arguments ) ) { |
|
| 4305 | + if (empty($this->arguments)) { |
|
| 4306 | 4306 | $this->get_arguments(); |
| 4307 | 4307 | } |
| 4308 | 4308 | |
| 4309 | 4309 | // check for checkboxes |
| 4310 | - if ( ! empty( $this->arguments ) ) { |
|
| 4311 | - foreach ( $this->arguments as $argument ) { |
|
| 4312 | - if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) { |
|
| 4313 | - $instance[ $argument['name'] ] = '0'; |
|
| 4310 | + if (!empty($this->arguments)) { |
|
| 4311 | + foreach ($this->arguments as $argument) { |
|
| 4312 | + if (isset($argument['type']) && $argument['type'] == 'checkbox' && !isset($new_instance[$argument['name']])) { |
|
| 4313 | + $instance[$argument['name']] = '0'; |
|
| 4314 | 4314 | } |
| 4315 | 4315 | } |
| 4316 | 4316 | } |
@@ -4328,7 +4328,7 @@ discard block |
||
| 4328 | 4328 | */ |
| 4329 | 4329 | public function is_block_content_call() { |
| 4330 | 4330 | $result = false; |
| 4331 | - if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) { |
|
| 4331 | + if (wp_doing_ajax() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'super_duper_output_shortcode') { |
|
| 4332 | 4332 | $result = true; |
| 4333 | 4333 | } |
| 4334 | 4334 | |
@@ -4341,9 +4341,9 @@ discard block |
||
| 4341 | 4341 | * @return string |
| 4342 | 4342 | *@since 1.0.20 |
| 4343 | 4343 | */ |
| 4344 | - public function get_instance_hash(){ |
|
| 4345 | - $instance_string = $this->base_id.serialize($this->instance); |
|
| 4346 | - return hash('crc32b',$instance_string); |
|
| 4344 | + public function get_instance_hash() { |
|
| 4345 | + $instance_string = $this->base_id . serialize($this->instance); |
|
| 4346 | + return hash('crc32b', $instance_string); |
|
| 4347 | 4347 | } |
| 4348 | 4348 | |
| 4349 | 4349 | /** |
@@ -4354,14 +4354,14 @@ discard block |
||
| 4354 | 4354 | * @return string |
| 4355 | 4355 | *@since 1.0.20 |
| 4356 | 4356 | */ |
| 4357 | - public function get_instance_style($rules = array()){ |
|
| 4357 | + public function get_instance_style($rules = array()) { |
|
| 4358 | 4358 | $css = ''; |
| 4359 | 4359 | |
| 4360 | - if(!empty($rules)){ |
|
| 4360 | + if (!empty($rules)) { |
|
| 4361 | 4361 | $rules = array_unique($rules); |
| 4362 | 4362 | $instance_hash = $this->get_instance_hash(); |
| 4363 | 4363 | $css .= "<style>"; |
| 4364 | - foreach($rules as $rule){ |
|
| 4364 | + foreach ($rules as $rule) { |
|
| 4365 | 4365 | $css .= ".sdel-$instance_hash $rule"; |
| 4366 | 4366 | } |
| 4367 | 4367 | $css .= "</style>"; |
@@ -4379,9 +4379,9 @@ discard block |
||
| 4379 | 4379 | *@since 1.0.28 |
| 4380 | 4380 | * |
| 4381 | 4381 | */ |
| 4382 | - public function encode_shortcodes( $content ) { |
|
| 4382 | + public function encode_shortcodes($content) { |
|
| 4383 | 4383 | // Avoids existing encoded tags. |
| 4384 | - $trans = array( |
|
| 4384 | + $trans = array( |
|
| 4385 | 4385 | '[' => '[', |
| 4386 | 4386 | ']' => ']', |
| 4387 | 4387 | '&#91;' => '[', |
@@ -4392,7 +4392,7 @@ discard block |
||
| 4392 | 4392 | '&gt;' => '&0gt;', |
| 4393 | 4393 | ); |
| 4394 | 4394 | |
| 4395 | - $content = strtr( $content, $trans ); |
|
| 4395 | + $content = strtr($content, $trans); |
|
| 4396 | 4396 | |
| 4397 | 4397 | $trans = array( |
| 4398 | 4398 | '[' => '[', |
@@ -4403,7 +4403,7 @@ discard block |
||
| 4403 | 4403 | "'" => ''', |
| 4404 | 4404 | ); |
| 4405 | 4405 | |
| 4406 | - $content = strtr( $content, $trans ); |
|
| 4406 | + $content = strtr($content, $trans); |
|
| 4407 | 4407 | |
| 4408 | 4408 | return $content; |
| 4409 | 4409 | } |
@@ -4417,8 +4417,8 @@ discard block |
||
| 4417 | 4417 | *@since 1.0.28 |
| 4418 | 4418 | * |
| 4419 | 4419 | */ |
| 4420 | - public function decode_shortcodes( $content ) { |
|
| 4421 | - $trans = array( |
|
| 4420 | + public function decode_shortcodes($content) { |
|
| 4421 | + $trans = array( |
|
| 4422 | 4422 | '[' => '[', |
| 4423 | 4423 | ']' => ']', |
| 4424 | 4424 | '&#91;' => '[', |
@@ -4431,7 +4431,7 @@ discard block |
||
| 4431 | 4431 | ''' => "'", |
| 4432 | 4432 | ); |
| 4433 | 4433 | |
| 4434 | - $content = strtr( $content, $trans ); |
|
| 4434 | + $content = strtr($content, $trans); |
|
| 4435 | 4435 | |
| 4436 | 4436 | $trans = array( |
| 4437 | 4437 | '[' => '[', |
@@ -4444,7 +4444,7 @@ discard block |
||
| 4444 | 4444 | '&0gt;' => '>', |
| 4445 | 4445 | ); |
| 4446 | 4446 | |
| 4447 | - $content = strtr( $content, $trans ); |
|
| 4447 | + $content = strtr($content, $trans); |
|
| 4448 | 4448 | |
| 4449 | 4449 | return $content; |
| 4450 | 4450 | } |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | if(!empty($this->options['nested-block'])){ |
| 60 | 60 | if(empty($this->options['output_types'])){ |
| 61 | 61 | $this->options['output_types'] = array('shortcode','block'); |
| 62 | - }elseif (($key = array_search('widget', $this->options['output_types'])) !== false) { |
|
| 62 | + } elseif (($key = array_search('widget', $this->options['output_types'])) !== false) { |
|
| 63 | 63 | unset($this->options['output_types'][$key]); |
| 64 | 64 | } |
| 65 | 65 | } |
@@ -698,7 +698,7 @@ discard block |
||
| 698 | 698 | <?php |
| 699 | 699 | if(! empty( $insert_shortcode_function )){ |
| 700 | 700 | echo $insert_shortcode_function; |
| 701 | - }else{ |
|
| 701 | + } else{ |
|
| 702 | 702 | |
| 703 | 703 | /** |
| 704 | 704 | * Function for super duper insert shortcode. |
@@ -2107,7 +2107,7 @@ discard block |
||
| 2107 | 2107 | var InnerBlocks = blockEditor.InnerBlocks; |
| 2108 | 2108 | |
| 2109 | 2109 | var term_query_type = ''; |
| 2110 | - var post_type_rest_slugs = <?php if(! empty( $this->arguments ) && isset($this->arguments['post_type']['onchange_rest']['values'])){echo "[".json_encode($this->arguments['post_type']['onchange_rest']['values'])."]";}else{echo "[]";} ?>; |
|
| 2110 | + var post_type_rest_slugs = <?php if(! empty( $this->arguments ) && isset($this->arguments['post_type']['onchange_rest']['values'])){echo "[".json_encode($this->arguments['post_type']['onchange_rest']['values'])."]";} else{echo "[]";} ?>; |
|
| 2111 | 2111 | const taxonomies_<?php echo str_replace("-","_", $this->id);?> = [{label: "Please wait", value: 0}]; |
| 2112 | 2112 | const sort_by_<?php echo str_replace("-","_", $this->id);?> = [{label: "Please wait", value: 0}]; |
| 2113 | 2113 | const MediaUpload = wp.blockEditor.MediaUpload; |
@@ -2226,8 +2226,7 @@ discard block |
||
| 2226 | 2226 | |
| 2227 | 2227 | if ( $args['type'] == 'notice' || $args['type'] == 'tab' ) { |
| 2228 | 2228 | continue; |
| 2229 | - } |
|
| 2230 | - elseif ( $args['type'] == 'checkbox' ) { |
|
| 2229 | + } elseif ( $args['type'] == 'checkbox' ) { |
|
| 2231 | 2230 | $type = 'boolean'; |
| 2232 | 2231 | $default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false'; |
| 2233 | 2232 | } elseif ( $args['type'] == 'number' ) { |
@@ -2355,7 +2354,7 @@ discard block |
||
| 2355 | 2354 | <?php |
| 2356 | 2355 | if(!empty($this->options['block-edit-raw'])) { |
| 2357 | 2356 | echo $this->options['block-edit-raw']; // strings have to be in single quotes, may cause issues |
| 2358 | - }else{ |
|
| 2357 | + } else{ |
|
| 2359 | 2358 | ?> |
| 2360 | 2359 | |
| 2361 | 2360 | function hasSelectedInnerBlock(props) { |
@@ -2396,7 +2395,7 @@ discard block |
||
| 2396 | 2395 | |
| 2397 | 2396 | // taxonomies |
| 2398 | 2397 | if( $value && 'post_type' in prev_attributes[props.clientId] && 'category' in prev_attributes[props.clientId] && run ){ |
| 2399 | - wp.apiFetch({path: "<?php if(isset($this->arguments['post_type']['onchange_rest']['path'])){echo $this->arguments['post_type']['onchange_rest']['path'];}else{'/wp/v2/"+$value+"/categories/?per_page=100';} ?>"}).then(terms => { |
|
| 2398 | + wp.apiFetch({path: "<?php if(isset($this->arguments['post_type']['onchange_rest']['path'])){echo $this->arguments['post_type']['onchange_rest']['path'];} else{'/wp/v2/"+$value+"/categories/?per_page=100';} ?>"}).then(terms => { |
|
| 2400 | 2399 | while (taxonomies_<?php echo str_replace("-","_", $this->id);?>.length) { |
| 2401 | 2400 | taxonomies_<?php echo str_replace("-","_", $this->id);?>.pop(); |
| 2402 | 2401 | } |
@@ -2473,7 +2472,7 @@ discard block |
||
| 2473 | 2472 | 'block_parent_name': parentBlocks.length ? parentBlocks[parentBlocks.length - 1].name : '', |
| 2474 | 2473 | 'post_id': <?php global $post; if ( isset( $post->ID ) ) { |
| 2475 | 2474 | echo $post->ID; |
| 2476 | - }else{echo '0';}?>, |
|
| 2475 | + } else{echo '0';}?>, |
|
| 2477 | 2476 | '_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>' |
| 2478 | 2477 | }; |
| 2479 | 2478 | |
@@ -2493,7 +2492,7 @@ discard block |
||
| 2493 | 2492 | is_fetching = false; |
| 2494 | 2493 | prev_attributes[props.clientId] = props.attributes; |
| 2495 | 2494 | <?php |
| 2496 | - }else{ |
|
| 2495 | + } else{ |
|
| 2497 | 2496 | ?> |
| 2498 | 2497 | props.setAttributes({content: env}); |
| 2499 | 2498 | is_fetching = false; |
@@ -2672,7 +2671,7 @@ discard block |
||
| 2672 | 2671 | // |
| 2673 | 2672 | |
| 2674 | 2673 | } |
| 2675 | - }else { |
|
| 2674 | + } else { |
|
| 2676 | 2675 | ?> |
| 2677 | 2676 | el(wp.components.PanelBody, { |
| 2678 | 2677 | title: '<?php esc_attr_e( "Settings" ); ?>', |
@@ -2698,9 +2697,9 @@ discard block |
||
| 2698 | 2697 | // If the user sets block-output array then build it |
| 2699 | 2698 | if ( ! empty( $this->options['block-output'] ) ) { |
| 2700 | 2699 | $this->block_element( $this->options['block-output'] ); |
| 2701 | - }elseif(!empty($this->options['block-edit-return'])){ |
|
| 2700 | + } elseif(!empty($this->options['block-edit-return'])){ |
|
| 2702 | 2701 | echo $this->options['block-edit-return']; |
| 2703 | - }else{ |
|
| 2702 | + } else{ |
|
| 2704 | 2703 | // if no block-output is set then we try and get the shortcode html output via ajax. |
| 2705 | 2704 | ?> |
| 2706 | 2705 | el('div', wp.blockEditor.useBlockProps({ |
@@ -2804,9 +2803,9 @@ discard block |
||
| 2804 | 2803 | ); |
| 2805 | 2804 | <?php |
| 2806 | 2805 | |
| 2807 | - }elseif(!empty($this->options['block-save-return'])){ |
|
| 2806 | + } elseif(!empty($this->options['block-save-return'])){ |
|
| 2808 | 2807 | echo 'return ' . $this->options['block-save-return']; |
| 2809 | - }elseif(!empty($this->options['nested-block'])){ |
|
| 2808 | + } elseif(!empty($this->options['nested-block'])){ |
|
| 2810 | 2809 | ?> |
| 2811 | 2810 | return el( |
| 2812 | 2811 | '', |
@@ -2816,13 +2815,13 @@ discard block |
||
| 2816 | 2815 | el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id'];?>]"}}) |
| 2817 | 2816 | ); |
| 2818 | 2817 | <?php |
| 2819 | - }elseif(!empty( $this->options['block-save-return'] ) ){ |
|
| 2818 | + } elseif(!empty( $this->options['block-save-return'] ) ){ |
|
| 2820 | 2819 | echo "return ". $this->options['block-edit-return'].";"; |
| 2821 | - }elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){ |
|
| 2820 | + } elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){ |
|
| 2822 | 2821 | ?> |
| 2823 | 2822 | return content; |
| 2824 | 2823 | <?php |
| 2825 | - }else{ |
|
| 2824 | + } else{ |
|
| 2826 | 2825 | ?> |
| 2827 | 2826 | var block_wrap = 'div'; |
| 2828 | 2827 | if (attr.hasOwnProperty("block_wrap")) { |
@@ -2873,9 +2872,9 @@ discard block |
||
| 2873 | 2872 | $device_type_icon = ''; |
| 2874 | 2873 | if($device_type=='Desktop'){ |
| 2875 | 2874 | $device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;"></span>'; |
| 2876 | - }elseif($device_type=='Tablet'){ |
|
| 2875 | + } elseif($device_type=='Tablet'){ |
|
| 2877 | 2876 | $device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;"></span>'; |
| 2878 | - }elseif($device_type=='Mobile'){ |
|
| 2877 | + } elseif($device_type=='Mobile'){ |
|
| 2879 | 2878 | $device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;"></span>'; |
| 2880 | 2879 | } |
| 2881 | 2880 | echo $element_require; |
@@ -2920,7 +2919,7 @@ discard block |
||
| 2920 | 2919 | |
| 2921 | 2920 | <?php |
| 2922 | 2921 | if(false){?></script><?php } |
| 2923 | - }elseif(!empty($args['row']['close'])){ |
|
| 2922 | + } elseif(!empty($args['row']['close'])){ |
|
| 2924 | 2923 | if(false){?><script><?php }?> |
| 2925 | 2924 | el( |
| 2926 | 2925 | 'div', |
@@ -2929,7 +2928,7 @@ discard block |
||
| 2929 | 2928 | }, |
| 2930 | 2929 | <?php |
| 2931 | 2930 | if(false){?></script><?php } |
| 2932 | - }else{ |
|
| 2931 | + } else{ |
|
| 2933 | 2932 | if(false){?><script><?php }?> |
| 2934 | 2933 | el( |
| 2935 | 2934 | 'div', |
@@ -3037,9 +3036,9 @@ discard block |
||
| 3037 | 3036 | $device_type_icon = ''; |
| 3038 | 3037 | if($device_type=='Desktop'){ |
| 3039 | 3038 | $device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>'; |
| 3040 | - }elseif($device_type=='Tablet'){ |
|
| 3039 | + } elseif($device_type=='Tablet'){ |
|
| 3041 | 3040 | $device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>'; |
| 3042 | - }elseif($device_type=='Mobile'){ |
|
| 3041 | + } elseif($device_type=='Mobile'){ |
|
| 3043 | 3042 | $device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>'; |
| 3044 | 3043 | } |
| 3045 | 3044 | |
@@ -3073,12 +3072,12 @@ discard block |
||
| 3073 | 3072 | if ( $args['type'] == 'number' ) { |
| 3074 | 3073 | $onchange = "props.setAttributes({ $key: $key ? Number($key) : '' } )"; |
| 3075 | 3074 | } |
| 3076 | - }else if ( $args['type'] == 'styleid' ) { |
|
| 3075 | + } else if ( $args['type'] == 'styleid' ) { |
|
| 3077 | 3076 | $type = 'TextControl'; |
| 3078 | 3077 | $args['type'] == 'text'; |
| 3079 | 3078 | // Save numbers as numbers and not strings |
| 3080 | 3079 | $value = "props.attributes.$key ? props.attributes.$key : 'aaabbbccc'"; |
| 3081 | - }else if ( $args['type'] == 'notice' ) { |
|
| 3080 | + } else if ( $args['type'] == 'notice' ) { |
|
| 3082 | 3081 | |
| 3083 | 3082 | $notice_message = !empty($args['desc']) ? addslashes($args['desc']) : ''; |
| 3084 | 3083 | $notice_status = !empty($args['status']) ? esc_attr($args['status']) : 'info'; |
@@ -3153,10 +3152,10 @@ discard block |
||
| 3153 | 3152 | $key: value |
| 3154 | 3153 | }); |
| 3155 | 3154 | },"; |
| 3156 | - }elseif ( $args['type'] == 'gradient' ) { |
|
| 3155 | + } elseif ( $args['type'] == 'gradient' ) { |
|
| 3157 | 3156 | $type = 'GradientPicker'; |
| 3158 | 3157 | |
| 3159 | - }elseif ( $args['type'] == 'image' ) { |
|
| 3158 | + } elseif ( $args['type'] == 'image' ) { |
|
| 3160 | 3159 | // print_r($args); |
| 3161 | 3160 | |
| 3162 | 3161 | $img_preview = isset($args['focalpoint']) && !$args['focalpoint'] ? " props.attributes.$key && el('img', { src: props.attributes.$key,style: {maxWidth:'100%',background: '#ccc'}})," : " ( props.attributes.$key || props.attributes.{$key}_use_featured ) && el(wp.components.FocalPointPicker,{ |
@@ -3218,7 +3217,7 @@ discard block |
||
| 3218 | 3217 | $onchange = ""; |
| 3219 | 3218 | |
| 3220 | 3219 | //$inside_elements = ",el('div',{},'file upload')"; |
| 3221 | - }elseif ( $args['type'] == 'images' ) { |
|
| 3220 | + } elseif ( $args['type'] == 'images' ) { |
|
| 3222 | 3221 | // print_r($args); |
| 3223 | 3222 | |
| 3224 | 3223 | $img_preview = "props.attributes.$key && (function() { |
@@ -3303,8 +3302,7 @@ discard block |
||
| 3303 | 3302 | $onchange = ""; |
| 3304 | 3303 | |
| 3305 | 3304 | //$inside_elements = ",el('div',{},'file upload')"; |
| 3306 | - } |
|
| 3307 | - elseif ( $args['type'] == 'checkbox' ) { |
|
| 3305 | + } elseif ( $args['type'] == 'checkbox' ) { |
|
| 3308 | 3306 | $type = 'CheckboxControl'; |
| 3309 | 3307 | $extra .= "checked: props.attributes.$key,"; |
| 3310 | 3308 | $onchange = "props.setAttributes({ $key: ! props.attributes.$key } )"; |
@@ -3315,9 +3313,9 @@ discard block |
||
| 3315 | 3313 | |
| 3316 | 3314 | if($args['name'] == 'category' && !empty($args['post_type_linked'])){ |
| 3317 | 3315 | $options .= "options: taxonomies_".str_replace("-","_", $this->id).","; |
| 3318 | - }elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){ |
|
| 3316 | + } elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){ |
|
| 3319 | 3317 | $options .= "options: sort_by_".str_replace("-","_", $this->id).","; |
| 3320 | - }else { |
|
| 3318 | + } else { |
|
| 3321 | 3319 | |
| 3322 | 3320 | if ( ! empty( $args['options'] ) ) { |
| 3323 | 3321 | $options .= "options: ["; |
@@ -3367,7 +3365,7 @@ discard block |
||
| 3367 | 3365 | |
| 3368 | 3366 | } elseif ( $args['type'] == 'alignment' ) { |
| 3369 | 3367 | $type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example |
| 3370 | - }elseif ( $args['type'] == 'margins' ) { |
|
| 3368 | + } elseif ( $args['type'] == 'margins' ) { |
|
| 3371 | 3369 | |
| 3372 | 3370 | } else { |
| 3373 | 3371 | return;// if we have not implemented the control then don't break the JS. |
@@ -3397,7 +3395,7 @@ discard block |
||
| 3397 | 3395 | label: <?php |
| 3398 | 3396 | if(empty($args['title'])){ |
| 3399 | 3397 | echo "''"; |
| 3400 | - }elseif(empty($args['row']) && !empty($args['device_type'])){ |
|
| 3398 | + } elseif(empty($args['row']) && !empty($args['device_type'])){ |
|
| 3401 | 3399 | ?>el('label', { |
| 3402 | 3400 | className: 'components-base-control__label', |
| 3403 | 3401 | style: {width:"100%"} |
@@ -3412,7 +3410,7 @@ discard block |
||
| 3412 | 3410 | |
| 3413 | 3411 | )<?php |
| 3414 | 3412 | |
| 3415 | - }else{ |
|
| 3413 | + } else{ |
|
| 3416 | 3414 | ?>'<?php echo addslashes( $args['title'] ); ?>'<?php |
| 3417 | 3415 | |
| 3418 | 3416 | } |
@@ -3420,7 +3418,7 @@ discard block |
||
| 3420 | 3418 | ?>, |
| 3421 | 3419 | help: <?php if ( isset( $args['desc'] ) ) { |
| 3422 | 3420 | echo "el('span',{dangerouslySetInnerHTML: {__html: '".wp_kses_post( addslashes($args['desc']) )."'}})"; |
| 3423 | - }else{ echo "''"; } ?>, |
|
| 3421 | + } else{ echo "''"; } ?>, |
|
| 3424 | 3422 | value: <?php echo $value; ?>, |
| 3425 | 3423 | <?php if ( $type == 'TextControl' && $args['type'] != 'text' ) { |
| 3426 | 3424 | echo "type: '" . addslashes( $args['type'] ) . "',"; |
@@ -3460,7 +3458,7 @@ discard block |
||
| 3460 | 3458 | foreach ( $custom_attributes as $key => $val ) { |
| 3461 | 3459 | if(is_array($val)){ |
| 3462 | 3460 | $attributes .= $key.': {'.$this->array_to_attributes( $val, $html ).'},'; |
| 3463 | - }else{ |
|
| 3461 | + } else{ |
|
| 3464 | 3462 | $attributes .= $html ? " $key='$val' " : "'$key': '$val',"; |
| 3465 | 3463 | } |
| 3466 | 3464 | } |
@@ -3500,7 +3498,7 @@ discard block |
||
| 3500 | 3498 | |
| 3501 | 3499 | if($new_args['element']=='InnerBlocks'){ |
| 3502 | 3500 | echo "\n el( InnerBlocks, {"; |
| 3503 | - }elseif($new_args['element']=='innerBlocksProps'){ |
|
| 3501 | + } elseif($new_args['element']=='innerBlocksProps'){ |
|
| 3504 | 3502 | $element = isset($new_args['inner_element']) ? esc_attr($new_args['inner_element']) : 'div'; |
| 3505 | 3503 | // echo "\n el( 'section', wp.blockEditor.useInnerBlocksProps( blockProps, {"; |
| 3506 | 3504 | // echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( "; |
@@ -3513,11 +3511,11 @@ discard block |
||
| 3513 | 3511 | // echo '###'; |
| 3514 | 3512 | |
| 3515 | 3513 | // echo '###'; |
| 3516 | - }elseif($new_args['element']=='BlocksProps'){ |
|
| 3514 | + } elseif($new_args['element']=='BlocksProps'){ |
|
| 3517 | 3515 | |
| 3518 | 3516 | if ( isset($new_args['if_inner_element']) ) { |
| 3519 | 3517 | $element = $new_args['if_inner_element']; |
| 3520 | - }else { |
|
| 3518 | + } else { |
|
| 3521 | 3519 | $element = isset($new_args['inner_element']) ? "'".esc_attr($new_args['inner_element'])."'" : "'div'"; |
| 3522 | 3520 | } |
| 3523 | 3521 | |
@@ -3528,7 +3526,7 @@ discard block |
||
| 3528 | 3526 | |
| 3529 | 3527 | // echo "} ),"; |
| 3530 | 3528 | |
| 3531 | - }else{ |
|
| 3529 | + } else{ |
|
| 3532 | 3530 | echo "\n el( '" . $new_args['element'] . "', {"; |
| 3533 | 3531 | } |
| 3534 | 3532 | |
@@ -3553,7 +3551,7 @@ discard block |
||
| 3553 | 3551 | |
| 3554 | 3552 | if ( $new_key === 'content' ) { |
| 3555 | 3553 | echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'"; |
| 3556 | - }else if ( $new_key === 'if_content' ) { |
|
| 3554 | + } else if ( $new_key === 'if_content' ) { |
|
| 3557 | 3555 | echo $this->block_props_replace( $new_value ); |
| 3558 | 3556 | } |
| 3559 | 3557 | |
@@ -3583,7 +3581,7 @@ discard block |
||
| 3583 | 3581 | |
| 3584 | 3582 | if($new_args['element']=='innerBlocksProps' || $new_args['element']=='xBlocksProps'){ |
| 3585 | 3583 | echo "))";// end content |
| 3586 | - }else{ |
|
| 3584 | + } else{ |
|
| 3587 | 3585 | echo ")";// end content |
| 3588 | 3586 | } |
| 3589 | 3587 | |
@@ -3869,7 +3867,7 @@ discard block |
||
| 3869 | 3867 | |
| 3870 | 3868 | if(empty($instance['widget_title_tag'])){ |
| 3871 | 3869 | $output = $args['before_title'] . $title . $args['after_title']; |
| 3872 | - }else{ |
|
| 3870 | + } else{ |
|
| 3873 | 3871 | $title_tag = esc_attr( $instance['widget_title_tag'] ); |
| 3874 | 3872 | |
| 3875 | 3873 | // classes |
@@ -3974,9 +3972,9 @@ discard block |
||
| 3974 | 3972 | <div class='row <?php if(!empty($args['row']['class'])){ echo esc_attr($args['row']['class']);} ?>'> |
| 3975 | 3973 | <div class='col pr-2'> |
| 3976 | 3974 | <?php |
| 3977 | - }elseif(!empty($args['row']['close'])){ |
|
| 3975 | + } elseif(!empty($args['row']['close'])){ |
|
| 3978 | 3976 | echo "<div class='col pl-0'>"; |
| 3979 | - }else{ |
|
| 3977 | + } else{ |
|
| 3980 | 3978 | echo "<div class='col pl-0 pr-2'>"; |
| 3981 | 3979 | } |
| 3982 | 3980 | } |
@@ -4194,11 +4192,11 @@ discard block |
||
| 4194 | 4192 | public function get_widget_icon($icon = 'box-top', $title = ''){ |
| 4195 | 4193 | if($icon=='box-top'){ |
| 4196 | 4194 | return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.048" height="9.017" fill="#555D66"></rect><rect x="16.265" y="5.498" width="1.023" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.186" width="8.964" height="2.482" fill="#272B2F"></rect><rect x="5.487" y="16.261" width="9.026" height="1.037" fill="#555D66"></rect></svg>'; |
| 4197 | - }elseif($icon=='box-right'){ |
|
| 4195 | + } elseif($icon=='box-right'){ |
|
| 4198 | 4196 | return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.046" height="9.017" fill="#555D66"></rect><rect x="15.244" y="5.498" width="2.518" height="9.003" fill="#272B2F"></rect><rect x="5.518" y="2.719" width="8.964" height="0.954" fill="#555D66"></rect><rect x="5.487" y="16.308" width="9.026" height="0.99" fill="#555D66"></rect></svg>'; |
| 4199 | - }elseif($icon=='box-bottom'){ |
|
| 4197 | + } elseif($icon=='box-bottom'){ |
|
| 4200 | 4198 | return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1" height="9.017" fill="#555D66"></rect><rect x="16.261" y="5.498" width="1.027" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.968" fill="#555D66"></rect><rect x="5.487" y="15.28" width="9.026" height="2.499" fill="#272B2F"></rect></svg>'; |
| 4201 | - }elseif($icon=='box-left'){ |
|
| 4199 | + } elseif($icon=='box-left'){ |
|
| 4202 | 4200 | return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.202" y="5.492" width="2.503" height="9.017" fill="#272B2F"></rect><rect x="16.276" y="5.498" width="1.012" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.966" fill="#555D66"></rect><rect x="5.487" y="16.303" width="9.026" height="0.995" fill="#555D66"></rect></svg>'; |
| 4203 | 4201 | } |
| 4204 | 4202 | } |
@@ -11,18 +11,18 @@ discard block |
||
| 11 | 11 | * @return mixed|void |
| 12 | 12 | */ |
| 13 | 13 | function sd_pagenow_exclude() { |
| 14 | - return apply_filters( 'sd_pagenow_exclude', array( |
|
| 15 | - 'upload.php', |
|
| 16 | - 'edit-comments.php', |
|
| 17 | - 'edit-tags.php', |
|
| 18 | - 'index.php', |
|
| 19 | - 'media-new.php', |
|
| 20 | - 'options-discussion.php', |
|
| 21 | - 'options-writing.php', |
|
| 22 | - 'edit.php', |
|
| 23 | - 'themes.php', |
|
| 24 | - 'users.php', |
|
| 25 | - ) ); |
|
| 14 | + return apply_filters( 'sd_pagenow_exclude', array( |
|
| 15 | + 'upload.php', |
|
| 16 | + 'edit-comments.php', |
|
| 17 | + 'edit-tags.php', |
|
| 18 | + 'index.php', |
|
| 19 | + 'media-new.php', |
|
| 20 | + 'options-discussion.php', |
|
| 21 | + 'options-writing.php', |
|
| 22 | + 'edit.php', |
|
| 23 | + 'themes.php', |
|
| 24 | + 'users.php', |
|
| 25 | + ) ); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * @return mixed|void |
| 35 | 35 | */ |
| 36 | 36 | function sd_widget_exclude() { |
| 37 | - return apply_filters( 'sd_widget_exclude', array() ); |
|
| 37 | + return apply_filters( 'sd_widget_exclude', array() ); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | |
@@ -47,70 +47,70 @@ discard block |
||
| 47 | 47 | * @return array |
| 48 | 48 | */ |
| 49 | 49 | function sd_get_margin_input( $type = 'mt', $overwrite = array(), $include_negatives = true ) { |
| 50 | - $options = array( |
|
| 51 | - "" => __( 'None' ), |
|
| 52 | - "auto" => __( 'auto' ), |
|
| 53 | - "0" => "0", |
|
| 54 | - "1" => "1", |
|
| 55 | - "2" => "2", |
|
| 56 | - "3" => "3", |
|
| 57 | - "4" => "4", |
|
| 58 | - "5" => "5", |
|
| 59 | - ); |
|
| 60 | - |
|
| 61 | - if ( $include_negatives ) { |
|
| 62 | - $options['n1'] = '-1'; |
|
| 63 | - $options['n2'] = '-2'; |
|
| 64 | - $options['n3'] = '-3'; |
|
| 65 | - $options['n4'] = '-4'; |
|
| 66 | - $options['n5'] = '-5'; |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - $defaults = array( |
|
| 70 | - 'type' => 'select', |
|
| 71 | - 'title' => __( 'Margin top' ), |
|
| 72 | - 'options' => $options, |
|
| 73 | - 'default' => '', |
|
| 74 | - 'desc_tip' => true, |
|
| 75 | - 'group' => __( "Wrapper Styles", "geodirectory" ), |
|
| 50 | + $options = array( |
|
| 51 | + "" => __( 'None' ), |
|
| 52 | + "auto" => __( 'auto' ), |
|
| 53 | + "0" => "0", |
|
| 54 | + "1" => "1", |
|
| 55 | + "2" => "2", |
|
| 56 | + "3" => "3", |
|
| 57 | + "4" => "4", |
|
| 58 | + "5" => "5", |
|
| 59 | + ); |
|
| 60 | + |
|
| 61 | + if ( $include_negatives ) { |
|
| 62 | + $options['n1'] = '-1'; |
|
| 63 | + $options['n2'] = '-2'; |
|
| 64 | + $options['n3'] = '-3'; |
|
| 65 | + $options['n4'] = '-4'; |
|
| 66 | + $options['n5'] = '-5'; |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + $defaults = array( |
|
| 70 | + 'type' => 'select', |
|
| 71 | + 'title' => __( 'Margin top' ), |
|
| 72 | + 'options' => $options, |
|
| 73 | + 'default' => '', |
|
| 74 | + 'desc_tip' => true, |
|
| 75 | + 'group' => __( "Wrapper Styles", "geodirectory" ), |
|
| 76 | 76 | // 'device_type' => 'Desktop', |
| 77 | - ); |
|
| 78 | - |
|
| 79 | - // title |
|
| 80 | - if ( $type == 'mt' ) { |
|
| 81 | - $defaults['title'] = __( 'Margin top' ); |
|
| 82 | - $defaults['icon'] = 'box-top'; |
|
| 83 | - $defaults['row'] = array( |
|
| 84 | - 'title' => __( 'Margins' ), |
|
| 85 | - 'key' => 'wrapper-margins', |
|
| 86 | - 'open' => true, |
|
| 87 | - 'class' => 'text-center', |
|
| 88 | - ); |
|
| 89 | - } elseif ( $type == 'mr' ) { |
|
| 90 | - $defaults['title'] = __( 'Margin right' ); |
|
| 91 | - $defaults['icon'] = 'box-right'; |
|
| 92 | - $defaults['row'] = array( |
|
| 93 | - 'key' => 'wrapper-margins', |
|
| 94 | - ); |
|
| 95 | - } elseif ( $type == 'mb' ) { |
|
| 96 | - $defaults['title'] = __( 'Margin bottom' ); |
|
| 97 | - $defaults['icon'] = 'box-bottom'; |
|
| 98 | - $defaults['row'] = array( |
|
| 99 | - 'key' => 'wrapper-margins', |
|
| 100 | - ); |
|
| 101 | - } elseif ( $type == 'ml' ) { |
|
| 102 | - $defaults['title'] = __( 'Margin left' ); |
|
| 103 | - $defaults['icon'] = 'box-left'; |
|
| 104 | - $defaults['row'] = array( |
|
| 105 | - 'key' => 'wrapper-margins', |
|
| 106 | - 'close' => true, |
|
| 107 | - ); |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 111 | - |
|
| 112 | - |
|
| 113 | - return $input; |
|
| 77 | + ); |
|
| 78 | + |
|
| 79 | + // title |
|
| 80 | + if ( $type == 'mt' ) { |
|
| 81 | + $defaults['title'] = __( 'Margin top' ); |
|
| 82 | + $defaults['icon'] = 'box-top'; |
|
| 83 | + $defaults['row'] = array( |
|
| 84 | + 'title' => __( 'Margins' ), |
|
| 85 | + 'key' => 'wrapper-margins', |
|
| 86 | + 'open' => true, |
|
| 87 | + 'class' => 'text-center', |
|
| 88 | + ); |
|
| 89 | + } elseif ( $type == 'mr' ) { |
|
| 90 | + $defaults['title'] = __( 'Margin right' ); |
|
| 91 | + $defaults['icon'] = 'box-right'; |
|
| 92 | + $defaults['row'] = array( |
|
| 93 | + 'key' => 'wrapper-margins', |
|
| 94 | + ); |
|
| 95 | + } elseif ( $type == 'mb' ) { |
|
| 96 | + $defaults['title'] = __( 'Margin bottom' ); |
|
| 97 | + $defaults['icon'] = 'box-bottom'; |
|
| 98 | + $defaults['row'] = array( |
|
| 99 | + 'key' => 'wrapper-margins', |
|
| 100 | + ); |
|
| 101 | + } elseif ( $type == 'ml' ) { |
|
| 102 | + $defaults['title'] = __( 'Margin left' ); |
|
| 103 | + $defaults['icon'] = 'box-left'; |
|
| 104 | + $defaults['row'] = array( |
|
| 105 | + 'key' => 'wrapper-margins', |
|
| 106 | + 'close' => true, |
|
| 107 | + ); |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 111 | + |
|
| 112 | + |
|
| 113 | + return $input; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -122,61 +122,61 @@ discard block |
||
| 122 | 122 | * @return array |
| 123 | 123 | */ |
| 124 | 124 | function sd_get_padding_input( $type = 'pt', $overwrite = array() ) { |
| 125 | - $options = array( |
|
| 126 | - "" => __( 'None' ), |
|
| 127 | - "0" => "0", |
|
| 128 | - "1" => "1", |
|
| 129 | - "2" => "2", |
|
| 130 | - "3" => "3", |
|
| 131 | - "4" => "4", |
|
| 132 | - "5" => "5", |
|
| 133 | - ); |
|
| 134 | - |
|
| 135 | - $defaults = array( |
|
| 136 | - 'type' => 'select', |
|
| 137 | - 'title' => __( 'Padding top' ), |
|
| 138 | - 'options' => $options, |
|
| 139 | - 'default' => '', |
|
| 140 | - 'desc_tip' => true, |
|
| 141 | - 'group' => __( "Wrapper Styles", "geodirectory" ) |
|
| 142 | - ); |
|
| 143 | - |
|
| 144 | - // title |
|
| 145 | - if ( $type == 'pt' ) { |
|
| 146 | - $defaults['title'] = __( 'Padding top' ); |
|
| 147 | - $defaults['icon'] = 'box-top'; |
|
| 148 | - $defaults['row'] = array( |
|
| 149 | - 'title' => __( 'Padding' ), |
|
| 150 | - 'key' => 'wrapper-padding', |
|
| 151 | - 'open' => true, |
|
| 152 | - 'class' => 'text-center', |
|
| 153 | - ); |
|
| 154 | - } elseif ( $type == 'pr' ) { |
|
| 155 | - $defaults['title'] = __( 'Padding right' ); |
|
| 156 | - $defaults['icon'] = 'box-right'; |
|
| 157 | - $defaults['row'] = array( |
|
| 158 | - 'key' => 'wrapper-padding', |
|
| 159 | - ); |
|
| 160 | - } elseif ( $type == 'pb' ) { |
|
| 161 | - $defaults['title'] = __( 'Padding bottom' ); |
|
| 162 | - $defaults['icon'] = 'box-bottom'; |
|
| 163 | - $defaults['row'] = array( |
|
| 164 | - 'key' => 'wrapper-padding', |
|
| 165 | - ); |
|
| 166 | - } elseif ( $type == 'pl' ) { |
|
| 167 | - $defaults['title'] = __( 'Padding left' ); |
|
| 168 | - $defaults['icon'] = 'box-left'; |
|
| 169 | - $defaults['row'] = array( |
|
| 170 | - 'key' => 'wrapper-padding', |
|
| 171 | - 'close' => true, |
|
| 172 | - |
|
| 173 | - ); |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 177 | - |
|
| 178 | - |
|
| 179 | - return $input; |
|
| 125 | + $options = array( |
|
| 126 | + "" => __( 'None' ), |
|
| 127 | + "0" => "0", |
|
| 128 | + "1" => "1", |
|
| 129 | + "2" => "2", |
|
| 130 | + "3" => "3", |
|
| 131 | + "4" => "4", |
|
| 132 | + "5" => "5", |
|
| 133 | + ); |
|
| 134 | + |
|
| 135 | + $defaults = array( |
|
| 136 | + 'type' => 'select', |
|
| 137 | + 'title' => __( 'Padding top' ), |
|
| 138 | + 'options' => $options, |
|
| 139 | + 'default' => '', |
|
| 140 | + 'desc_tip' => true, |
|
| 141 | + 'group' => __( "Wrapper Styles", "geodirectory" ) |
|
| 142 | + ); |
|
| 143 | + |
|
| 144 | + // title |
|
| 145 | + if ( $type == 'pt' ) { |
|
| 146 | + $defaults['title'] = __( 'Padding top' ); |
|
| 147 | + $defaults['icon'] = 'box-top'; |
|
| 148 | + $defaults['row'] = array( |
|
| 149 | + 'title' => __( 'Padding' ), |
|
| 150 | + 'key' => 'wrapper-padding', |
|
| 151 | + 'open' => true, |
|
| 152 | + 'class' => 'text-center', |
|
| 153 | + ); |
|
| 154 | + } elseif ( $type == 'pr' ) { |
|
| 155 | + $defaults['title'] = __( 'Padding right' ); |
|
| 156 | + $defaults['icon'] = 'box-right'; |
|
| 157 | + $defaults['row'] = array( |
|
| 158 | + 'key' => 'wrapper-padding', |
|
| 159 | + ); |
|
| 160 | + } elseif ( $type == 'pb' ) { |
|
| 161 | + $defaults['title'] = __( 'Padding bottom' ); |
|
| 162 | + $defaults['icon'] = 'box-bottom'; |
|
| 163 | + $defaults['row'] = array( |
|
| 164 | + 'key' => 'wrapper-padding', |
|
| 165 | + ); |
|
| 166 | + } elseif ( $type == 'pl' ) { |
|
| 167 | + $defaults['title'] = __( 'Padding left' ); |
|
| 168 | + $defaults['icon'] = 'box-left'; |
|
| 169 | + $defaults['row'] = array( |
|
| 170 | + 'key' => 'wrapper-padding', |
|
| 171 | + 'close' => true, |
|
| 172 | + |
|
| 173 | + ); |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 177 | + |
|
| 178 | + |
|
| 179 | + return $input; |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /** |
@@ -189,58 +189,58 @@ discard block |
||
| 189 | 189 | */ |
| 190 | 190 | function sd_get_border_input( $type = 'border', $overwrite = array() ) { |
| 191 | 191 | |
| 192 | - $defaults = array( |
|
| 193 | - 'type' => 'select', |
|
| 194 | - 'title' => __( 'Border' ), |
|
| 195 | - 'options' => array(), |
|
| 196 | - 'default' => '', |
|
| 197 | - 'desc_tip' => true, |
|
| 198 | - 'group' => __( "Wrapper Styles", "geodirectory" ) |
|
| 199 | - ); |
|
| 200 | - |
|
| 201 | - // title |
|
| 202 | - if ( $type == 'rounded' ) { |
|
| 203 | - $defaults['title'] = __( 'Border radius type' ); |
|
| 204 | - $defaults['options'] = array( |
|
| 205 | - '' => __( "Default", "geodirectory" ), |
|
| 206 | - 'rounded' => 'rounded', |
|
| 207 | - 'rounded-top' => 'rounded-top', |
|
| 208 | - 'rounded-right' => 'rounded-right', |
|
| 209 | - 'rounded-bottom' => 'rounded-bottom', |
|
| 210 | - 'rounded-left' => 'rounded-left', |
|
| 211 | - 'rounded-circle' => 'rounded-circle', |
|
| 212 | - 'rounded-pill' => 'rounded-pill', |
|
| 213 | - 'rounded-0' => 'rounded-0', |
|
| 214 | - ); |
|
| 215 | - } elseif ( $type == 'rounded_size' ) { |
|
| 216 | - $defaults['title'] = __( 'Border radius size' ); |
|
| 217 | - $defaults['options'] = array( |
|
| 218 | - '' => __( "Default", "geodirectory" ), |
|
| 219 | - 'sm' => __( "Small", "geodirectory" ), |
|
| 220 | - 'lg' => __( "Large", "geodirectory" ), |
|
| 221 | - ); |
|
| 222 | - } elseif ( $type == 'type' ) { |
|
| 223 | - $defaults['title'] = __( 'Border type' ); |
|
| 224 | - $defaults['options'] = array( |
|
| 225 | - '' => __( "None", "geodirectory" ), |
|
| 226 | - 'border' => __( "Full", "geodirectory" ), |
|
| 227 | - 'border-top' => __( "Top", "geodirectory" ), |
|
| 228 | - 'border-bottom' => __( "Bottom", "geodirectory" ), |
|
| 229 | - 'border-left' => __( "Left", "geodirectory" ), |
|
| 230 | - 'border-right' => __( "Right", "geodirectory" ), |
|
| 231 | - ); |
|
| 232 | - } else { |
|
| 233 | - $defaults['title'] = __( 'Border color' ); |
|
| 234 | - $defaults['options'] = array( |
|
| 235 | - '' => __( "Default", "geodirectory" ), |
|
| 236 | - '0' => __( "None", "geodirectory" ), |
|
| 237 | - ) + sd_aui_colors(); |
|
| 238 | - } |
|
| 239 | - |
|
| 240 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 241 | - |
|
| 242 | - |
|
| 243 | - return $input; |
|
| 192 | + $defaults = array( |
|
| 193 | + 'type' => 'select', |
|
| 194 | + 'title' => __( 'Border' ), |
|
| 195 | + 'options' => array(), |
|
| 196 | + 'default' => '', |
|
| 197 | + 'desc_tip' => true, |
|
| 198 | + 'group' => __( "Wrapper Styles", "geodirectory" ) |
|
| 199 | + ); |
|
| 200 | + |
|
| 201 | + // title |
|
| 202 | + if ( $type == 'rounded' ) { |
|
| 203 | + $defaults['title'] = __( 'Border radius type' ); |
|
| 204 | + $defaults['options'] = array( |
|
| 205 | + '' => __( "Default", "geodirectory" ), |
|
| 206 | + 'rounded' => 'rounded', |
|
| 207 | + 'rounded-top' => 'rounded-top', |
|
| 208 | + 'rounded-right' => 'rounded-right', |
|
| 209 | + 'rounded-bottom' => 'rounded-bottom', |
|
| 210 | + 'rounded-left' => 'rounded-left', |
|
| 211 | + 'rounded-circle' => 'rounded-circle', |
|
| 212 | + 'rounded-pill' => 'rounded-pill', |
|
| 213 | + 'rounded-0' => 'rounded-0', |
|
| 214 | + ); |
|
| 215 | + } elseif ( $type == 'rounded_size' ) { |
|
| 216 | + $defaults['title'] = __( 'Border radius size' ); |
|
| 217 | + $defaults['options'] = array( |
|
| 218 | + '' => __( "Default", "geodirectory" ), |
|
| 219 | + 'sm' => __( "Small", "geodirectory" ), |
|
| 220 | + 'lg' => __( "Large", "geodirectory" ), |
|
| 221 | + ); |
|
| 222 | + } elseif ( $type == 'type' ) { |
|
| 223 | + $defaults['title'] = __( 'Border type' ); |
|
| 224 | + $defaults['options'] = array( |
|
| 225 | + '' => __( "None", "geodirectory" ), |
|
| 226 | + 'border' => __( "Full", "geodirectory" ), |
|
| 227 | + 'border-top' => __( "Top", "geodirectory" ), |
|
| 228 | + 'border-bottom' => __( "Bottom", "geodirectory" ), |
|
| 229 | + 'border-left' => __( "Left", "geodirectory" ), |
|
| 230 | + 'border-right' => __( "Right", "geodirectory" ), |
|
| 231 | + ); |
|
| 232 | + } else { |
|
| 233 | + $defaults['title'] = __( 'Border color' ); |
|
| 234 | + $defaults['options'] = array( |
|
| 235 | + '' => __( "Default", "geodirectory" ), |
|
| 236 | + '0' => __( "None", "geodirectory" ), |
|
| 237 | + ) + sd_aui_colors(); |
|
| 238 | + } |
|
| 239 | + |
|
| 240 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 241 | + |
|
| 242 | + |
|
| 243 | + return $input; |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | /** |
@@ -252,27 +252,27 @@ discard block |
||
| 252 | 252 | * @return array |
| 253 | 253 | */ |
| 254 | 254 | function sd_get_shadow_input( $type = 'shadow', $overwrite = array() ) { |
| 255 | - $options = array( |
|
| 256 | - "" => __( 'None' ), |
|
| 257 | - "shadow-sm" => __( 'Small' ), |
|
| 258 | - "shadow" => __( 'Regular' ), |
|
| 259 | - "shadow-lg" => __( 'Large' ), |
|
| 260 | - ); |
|
| 255 | + $options = array( |
|
| 256 | + "" => __( 'None' ), |
|
| 257 | + "shadow-sm" => __( 'Small' ), |
|
| 258 | + "shadow" => __( 'Regular' ), |
|
| 259 | + "shadow-lg" => __( 'Large' ), |
|
| 260 | + ); |
|
| 261 | 261 | |
| 262 | - $defaults = array( |
|
| 263 | - 'type' => 'select', |
|
| 264 | - 'title' => __( 'Shadow' ), |
|
| 265 | - 'options' => $options, |
|
| 266 | - 'default' => '', |
|
| 267 | - 'desc_tip' => true, |
|
| 268 | - 'group' => __( "Wrapper Styles", "geodirectory" ) |
|
| 269 | - ); |
|
| 262 | + $defaults = array( |
|
| 263 | + 'type' => 'select', |
|
| 264 | + 'title' => __( 'Shadow' ), |
|
| 265 | + 'options' => $options, |
|
| 266 | + 'default' => '', |
|
| 267 | + 'desc_tip' => true, |
|
| 268 | + 'group' => __( "Wrapper Styles", "geodirectory" ) |
|
| 269 | + ); |
|
| 270 | 270 | |
| 271 | 271 | |
| 272 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 272 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 273 | 273 | |
| 274 | 274 | |
| 275 | - return $input; |
|
| 275 | + return $input; |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | /** |
@@ -284,25 +284,25 @@ discard block |
||
| 284 | 284 | * @return array |
| 285 | 285 | */ |
| 286 | 286 | function sd_get_background_input( $type = 'bg', $overwrite = array() ) { |
| 287 | - $options = array( |
|
| 288 | - '' => __( "None", "geodirectory" ), |
|
| 289 | - 'transparent' => __( "Transparent", "geodirectory" ), |
|
| 290 | - ) + sd_aui_colors(); |
|
| 287 | + $options = array( |
|
| 288 | + '' => __( "None", "geodirectory" ), |
|
| 289 | + 'transparent' => __( "Transparent", "geodirectory" ), |
|
| 290 | + ) + sd_aui_colors(); |
|
| 291 | 291 | |
| 292 | - $defaults = array( |
|
| 293 | - 'type' => 'select', |
|
| 294 | - 'title' => __( 'Background color' ), |
|
| 295 | - 'options' => $options, |
|
| 296 | - 'default' => '', |
|
| 297 | - 'desc_tip' => true, |
|
| 298 | - 'group' => __( "Wrapper Styles", "geodirectory" ) |
|
| 299 | - ); |
|
| 292 | + $defaults = array( |
|
| 293 | + 'type' => 'select', |
|
| 294 | + 'title' => __( 'Background color' ), |
|
| 295 | + 'options' => $options, |
|
| 296 | + 'default' => '', |
|
| 297 | + 'desc_tip' => true, |
|
| 298 | + 'group' => __( "Wrapper Styles", "geodirectory" ) |
|
| 299 | + ); |
|
| 300 | 300 | |
| 301 | 301 | |
| 302 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 302 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 303 | 303 | |
| 304 | 304 | |
| 305 | - return $input; |
|
| 305 | + return $input; |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | /** |
@@ -314,108 +314,108 @@ discard block |
||
| 314 | 314 | * @return array |
| 315 | 315 | */ |
| 316 | 316 | function sd_get_background_inputs( $type = 'bg', $overwrite = array(), $overwrite_color = array(), $overwrite_gradient = array(), $overwrite_image = array() ) { |
| 317 | - $options = array( |
|
| 318 | - '' => __( "None", "geodirectory" ), |
|
| 319 | - 'transparent' => __( "Transparent", "geodirectory" ), |
|
| 320 | - ) + sd_aui_colors() |
|
| 321 | - + array( |
|
| 322 | - 'custom-color' => __( "Custom Color", "geodirectory" ), |
|
| 323 | - 'custom-gradient' => __( "Custom Gradient", "geodirectory" ), |
|
| 317 | + $options = array( |
|
| 318 | + '' => __( "None", "geodirectory" ), |
|
| 319 | + 'transparent' => __( "Transparent", "geodirectory" ), |
|
| 320 | + ) + sd_aui_colors() |
|
| 321 | + + array( |
|
| 322 | + 'custom-color' => __( "Custom Color", "geodirectory" ), |
|
| 323 | + 'custom-gradient' => __( "Custom Gradient", "geodirectory" ), |
|
| 324 | 324 | // 'custom-image' => __("Custom Image","geodirectory"), |
| 325 | - ); |
|
| 326 | - |
|
| 327 | - $defaults = array( |
|
| 328 | - 'type' => 'select', |
|
| 329 | - 'title' => __( 'Background Color' ), |
|
| 330 | - 'options' => $options, |
|
| 331 | - 'default' => '', |
|
| 332 | - 'desc_tip' => true, |
|
| 333 | - 'group' => __( "Background", "geodirectory" ) |
|
| 334 | - ); |
|
| 335 | - |
|
| 336 | - |
|
| 337 | - if ( $overwrite !== false ) { |
|
| 338 | - $input[ $type ] = wp_parse_args( $overwrite, $defaults ); |
|
| 339 | - } |
|
| 340 | - |
|
| 341 | - |
|
| 342 | - if ( $overwrite_color !== false ) { |
|
| 343 | - $input[ $type . '_color' ] = wp_parse_args( $overwrite_color, array( |
|
| 344 | - 'type' => 'color', |
|
| 345 | - 'title' => __( 'Custom color' ), |
|
| 346 | - 'placeholder' => '', |
|
| 347 | - 'default' => '#0073aa', |
|
| 348 | - 'desc_tip' => true, |
|
| 349 | - 'group' => __( "Background" ), |
|
| 350 | - 'element_require' => '[%' . $type . '%]=="custom-color"' |
|
| 351 | - ) ); |
|
| 352 | - } |
|
| 353 | - |
|
| 354 | - |
|
| 355 | - if ( $overwrite_gradient !== false ) { |
|
| 356 | - $input[ $type . '_gradient' ] = wp_parse_args( $overwrite_gradient, array( |
|
| 357 | - 'type' => 'gradient', |
|
| 358 | - 'title' => __( 'Custom gradient' ), |
|
| 359 | - 'placeholder' => '', |
|
| 360 | - 'default' => 'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)', |
|
| 361 | - 'desc_tip' => true, |
|
| 362 | - 'group' => __( "Background" ), |
|
| 363 | - 'element_require' => '[%' . $type . '%]=="custom-gradient"' |
|
| 364 | - ) ); |
|
| 365 | - } |
|
| 366 | - |
|
| 367 | - if ( $overwrite_image !== false ) { |
|
| 368 | - |
|
| 369 | - $input[ $type . '_image_fixed' ] = array( |
|
| 370 | - 'type' => 'checkbox', |
|
| 371 | - 'title' => __( 'Fixed background' ), |
|
| 372 | - 'default' => '', |
|
| 373 | - 'desc_tip' => true, |
|
| 374 | - 'group' => __( "Background" ), |
|
| 375 | - 'element_require' => '( [%' . $type . '%]=="" || [%' . $type . '%]=="custom-color" || [%' . $type . '%]=="custom-gradient" || [%' . $type . '%]=="transparent" )' |
|
| 376 | - |
|
| 377 | - ); |
|
| 378 | - |
|
| 379 | - $input[ $type . '_image_use_featured' ] = array( |
|
| 380 | - 'type' => 'checkbox', |
|
| 381 | - 'title' => __( 'Use featured image' ), |
|
| 382 | - 'default' => '', |
|
| 383 | - 'desc_tip' => true, |
|
| 384 | - 'group' => __( "Background" ), |
|
| 385 | - 'element_require' => '( [%' . $type . '%]=="" || [%' . $type . '%]=="custom-color" || [%' . $type . '%]=="custom-gradient" || [%' . $type . '%]=="transparent" )' |
|
| 386 | - |
|
| 387 | - ); |
|
| 388 | - |
|
| 389 | - |
|
| 390 | - $input[ $type . '_image' ] = wp_parse_args( $overwrite_image, array( |
|
| 391 | - 'type' => 'image', |
|
| 392 | - 'title' => __( 'Custom image' ), |
|
| 393 | - 'placeholder' => '', |
|
| 394 | - 'default' => '', |
|
| 395 | - 'desc_tip' => true, |
|
| 396 | - 'group' => __( "Background" ), |
|
| 325 | + ); |
|
| 326 | + |
|
| 327 | + $defaults = array( |
|
| 328 | + 'type' => 'select', |
|
| 329 | + 'title' => __( 'Background Color' ), |
|
| 330 | + 'options' => $options, |
|
| 331 | + 'default' => '', |
|
| 332 | + 'desc_tip' => true, |
|
| 333 | + 'group' => __( "Background", "geodirectory" ) |
|
| 334 | + ); |
|
| 335 | + |
|
| 336 | + |
|
| 337 | + if ( $overwrite !== false ) { |
|
| 338 | + $input[ $type ] = wp_parse_args( $overwrite, $defaults ); |
|
| 339 | + } |
|
| 340 | + |
|
| 341 | + |
|
| 342 | + if ( $overwrite_color !== false ) { |
|
| 343 | + $input[ $type . '_color' ] = wp_parse_args( $overwrite_color, array( |
|
| 344 | + 'type' => 'color', |
|
| 345 | + 'title' => __( 'Custom color' ), |
|
| 346 | + 'placeholder' => '', |
|
| 347 | + 'default' => '#0073aa', |
|
| 348 | + 'desc_tip' => true, |
|
| 349 | + 'group' => __( "Background" ), |
|
| 350 | + 'element_require' => '[%' . $type . '%]=="custom-color"' |
|
| 351 | + ) ); |
|
| 352 | + } |
|
| 353 | + |
|
| 354 | + |
|
| 355 | + if ( $overwrite_gradient !== false ) { |
|
| 356 | + $input[ $type . '_gradient' ] = wp_parse_args( $overwrite_gradient, array( |
|
| 357 | + 'type' => 'gradient', |
|
| 358 | + 'title' => __( 'Custom gradient' ), |
|
| 359 | + 'placeholder' => '', |
|
| 360 | + 'default' => 'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)', |
|
| 361 | + 'desc_tip' => true, |
|
| 362 | + 'group' => __( "Background" ), |
|
| 363 | + 'element_require' => '[%' . $type . '%]=="custom-gradient"' |
|
| 364 | + ) ); |
|
| 365 | + } |
|
| 366 | + |
|
| 367 | + if ( $overwrite_image !== false ) { |
|
| 368 | + |
|
| 369 | + $input[ $type . '_image_fixed' ] = array( |
|
| 370 | + 'type' => 'checkbox', |
|
| 371 | + 'title' => __( 'Fixed background' ), |
|
| 372 | + 'default' => '', |
|
| 373 | + 'desc_tip' => true, |
|
| 374 | + 'group' => __( "Background" ), |
|
| 375 | + 'element_require' => '( [%' . $type . '%]=="" || [%' . $type . '%]=="custom-color" || [%' . $type . '%]=="custom-gradient" || [%' . $type . '%]=="transparent" )' |
|
| 376 | + |
|
| 377 | + ); |
|
| 378 | + |
|
| 379 | + $input[ $type . '_image_use_featured' ] = array( |
|
| 380 | + 'type' => 'checkbox', |
|
| 381 | + 'title' => __( 'Use featured image' ), |
|
| 382 | + 'default' => '', |
|
| 383 | + 'desc_tip' => true, |
|
| 384 | + 'group' => __( "Background" ), |
|
| 385 | + 'element_require' => '( [%' . $type . '%]=="" || [%' . $type . '%]=="custom-color" || [%' . $type . '%]=="custom-gradient" || [%' . $type . '%]=="transparent" )' |
|
| 386 | + |
|
| 387 | + ); |
|
| 388 | + |
|
| 389 | + |
|
| 390 | + $input[ $type . '_image' ] = wp_parse_args( $overwrite_image, array( |
|
| 391 | + 'type' => 'image', |
|
| 392 | + 'title' => __( 'Custom image' ), |
|
| 393 | + 'placeholder' => '', |
|
| 394 | + 'default' => '', |
|
| 395 | + 'desc_tip' => true, |
|
| 396 | + 'group' => __( "Background" ), |
|
| 397 | 397 | // 'element_require' => ' ![%' . $type . '_image_use_featured%] ' |
| 398 | - ) ); |
|
| 399 | - |
|
| 400 | - $input[ $type . '_image_id' ] = wp_parse_args( $overwrite_image, array( |
|
| 401 | - 'type' => 'hidden', |
|
| 402 | - 'hidden_type' => 'number', |
|
| 403 | - 'title' => '', |
|
| 404 | - 'placeholder' => '', |
|
| 405 | - 'default' => '', |
|
| 406 | - 'group' => __( "Background" ), |
|
| 407 | - ) ); |
|
| 408 | - |
|
| 409 | - $input[ $type . '_image_xy' ] = wp_parse_args( $overwrite_image, array( |
|
| 410 | - 'type' => 'image_xy', |
|
| 411 | - 'title' => '', |
|
| 412 | - 'placeholder' => '', |
|
| 413 | - 'default' => '', |
|
| 414 | - 'group' => __( "Background" ), |
|
| 415 | - ) ); |
|
| 416 | - } |
|
| 417 | - |
|
| 418 | - return $input; |
|
| 398 | + ) ); |
|
| 399 | + |
|
| 400 | + $input[ $type . '_image_id' ] = wp_parse_args( $overwrite_image, array( |
|
| 401 | + 'type' => 'hidden', |
|
| 402 | + 'hidden_type' => 'number', |
|
| 403 | + 'title' => '', |
|
| 404 | + 'placeholder' => '', |
|
| 405 | + 'default' => '', |
|
| 406 | + 'group' => __( "Background" ), |
|
| 407 | + ) ); |
|
| 408 | + |
|
| 409 | + $input[ $type . '_image_xy' ] = wp_parse_args( $overwrite_image, array( |
|
| 410 | + 'type' => 'image_xy', |
|
| 411 | + 'title' => '', |
|
| 412 | + 'placeholder' => '', |
|
| 413 | + 'default' => '', |
|
| 414 | + 'group' => __( "Background" ), |
|
| 415 | + ) ); |
|
| 416 | + } |
|
| 417 | + |
|
| 418 | + return $input; |
|
| 419 | 419 | } |
| 420 | 420 | |
| 421 | 421 | /** |
@@ -428,169 +428,169 @@ discard block |
||
| 428 | 428 | */ |
| 429 | 429 | function sd_get_shape_divider_inputs( $type = 'sd', $overwrite = array(), $overwrite_color = array(), $overwrite_gradient = array(), $overwrite_image = array() ) { |
| 430 | 430 | |
| 431 | - $options = array( |
|
| 432 | - '' => __( "None" ), |
|
| 433 | - 'mountains' => __( "Mountains" ), |
|
| 434 | - 'drops' => __( "Drops" ), |
|
| 435 | - 'clouds' => __( "Clouds" ), |
|
| 436 | - 'zigzag' => __( "Zigzag" ), |
|
| 437 | - 'pyramids' => __( "Pyramids" ), |
|
| 438 | - 'triangle' => __( "Triangle" ), |
|
| 439 | - 'triangle-asymmetrical' => __( "Triangle Asymmetrical" ), |
|
| 440 | - 'tilt' => __( "Tilt" ), |
|
| 441 | - 'opacity-tilt' => __( "Opacity Tilt" ), |
|
| 442 | - 'opacity-fan' => __( "Opacity Fan" ), |
|
| 443 | - 'curve' => __( "Curve" ), |
|
| 444 | - 'curve-asymmetrical' => __( "Curve Asymmetrical" ), |
|
| 445 | - 'waves' => __( "Waves" ), |
|
| 446 | - 'wave-brush' => __( "Wave Brush" ), |
|
| 447 | - 'waves-pattern' => __( "Waves Pattern" ), |
|
| 448 | - 'arrow' => __( "Arrow" ), |
|
| 449 | - 'split' => __( "Split" ), |
|
| 450 | - 'book' => __( "Book" ), |
|
| 451 | - ); |
|
| 452 | - |
|
| 453 | - $defaults = array( |
|
| 454 | - 'type' => 'select', |
|
| 455 | - 'title' => __( 'Type' ), |
|
| 456 | - 'options' => $options, |
|
| 457 | - 'default' => '', |
|
| 458 | - 'desc_tip' => true, |
|
| 459 | - 'group' => __( "Shape Divider" ), |
|
| 460 | - ); |
|
| 461 | - |
|
| 462 | - |
|
| 463 | - $input[ $type ] = wp_parse_args( $overwrite, $defaults ); |
|
| 464 | - |
|
| 465 | - |
|
| 466 | - $input[ $type . '_notice' ] = array( |
|
| 467 | - 'type' => 'notice', |
|
| 468 | - 'desc' => __( 'Parent element must be position `relative`' ), |
|
| 469 | - 'status' => 'warning', |
|
| 470 | - 'group' => __( "Shape Divider" ), |
|
| 471 | - 'element_require' => '[%' . $type . '%]!=""', |
|
| 472 | - ); |
|
| 473 | - |
|
| 474 | - |
|
| 475 | - $input[ $type . '_position' ] = wp_parse_args( $overwrite_color, array( |
|
| 476 | - 'type' => 'select', |
|
| 477 | - 'title' => __( 'Position' ), |
|
| 478 | - 'options' => array( |
|
| 479 | - 'top' => __( 'Top' ), |
|
| 480 | - 'bottom' => __( 'Bottom' ), |
|
| 481 | - //'left' => __('Left'), |
|
| 482 | - //'right' => __('Right'), |
|
| 483 | - ), |
|
| 484 | - 'desc_tip' => true, |
|
| 485 | - 'group' => __( "Shape Divider" ), |
|
| 486 | - 'element_require' => '[%' . $type . '%]!=""' |
|
| 487 | - ) ); |
|
| 488 | - |
|
| 489 | - $options = array( |
|
| 490 | - '' => __( "None" ), |
|
| 491 | - 'transparent' => __( "Transparent" ), |
|
| 492 | - ) + sd_aui_colors() |
|
| 493 | - + array( |
|
| 494 | - 'custom-color' => __( "Custom Color" ), |
|
| 495 | - ); |
|
| 496 | - |
|
| 497 | - $input[ $type . '_color' ] = wp_parse_args( $overwrite_color, array( |
|
| 498 | - 'type' => 'select', |
|
| 499 | - 'title' => __( 'Color' ), |
|
| 500 | - 'options' => $options, |
|
| 501 | - 'desc_tip' => true, |
|
| 502 | - 'group' => __( "Shape Divider" ), |
|
| 503 | - 'element_require' => '[%' . $type . '%]!=""' |
|
| 504 | - ) ); |
|
| 505 | - |
|
| 506 | - $input[ $type . '_custom_color' ] = wp_parse_args( $overwrite_color, array( |
|
| 507 | - 'type' => 'color', |
|
| 508 | - 'title' => __( 'Custom color' ), |
|
| 509 | - 'placeholder' => '', |
|
| 510 | - 'default' => '#0073aa', |
|
| 511 | - 'desc_tip' => true, |
|
| 512 | - 'group' => __( "Shape Divider" ), |
|
| 513 | - 'element_require' => '[%' . $type . '_color%]=="custom-color" && [%' . $type . '%]!=""' |
|
| 514 | - ) ); |
|
| 515 | - |
|
| 516 | - $input[ $type . '_width' ] = wp_parse_args( $overwrite_gradient, array( |
|
| 517 | - 'type' => 'range', |
|
| 518 | - 'title' => __( 'Width' ), |
|
| 519 | - 'placeholder' => '', |
|
| 520 | - 'default' => '200', |
|
| 521 | - 'desc_tip' => true, |
|
| 522 | - 'custom_attributes' => array( |
|
| 523 | - 'min' => 100, |
|
| 524 | - 'max' => 300, |
|
| 525 | - ), |
|
| 526 | - 'group' => __( "Shape Divider" ), |
|
| 527 | - 'element_require' => '[%' . $type . '%]!=""' |
|
| 528 | - ) ); |
|
| 529 | - |
|
| 530 | - $input[ $type . '_height' ] = array( |
|
| 531 | - 'type' => 'range', |
|
| 532 | - 'title' => __( 'Height' ), |
|
| 533 | - 'default' => '100', |
|
| 534 | - 'desc_tip' => true, |
|
| 535 | - 'custom_attributes' => array( |
|
| 536 | - 'min' => 0, |
|
| 537 | - 'max' => 500, |
|
| 538 | - ), |
|
| 539 | - 'group' => __( "Shape Divider" ), |
|
| 540 | - 'element_require' => '[%' . $type . '%]!=""' |
|
| 541 | - ); |
|
| 542 | - |
|
| 543 | - $requires = array( |
|
| 544 | - 'mountains' => array( 'flip' ), |
|
| 545 | - 'drops' => array( 'flip', 'invert' ), |
|
| 546 | - 'clouds' => array( 'flip', 'invert' ), |
|
| 547 | - 'zigzag' => array(), |
|
| 548 | - 'pyramids' => array( 'flip', 'invert' ), |
|
| 549 | - 'triangle' => array( 'invert' ), |
|
| 550 | - 'triangle-asymmetrical' => array( 'flip', 'invert' ), |
|
| 551 | - 'tilt' => array( 'flip' ), |
|
| 552 | - 'opacity-tilt' => array( 'flip' ), |
|
| 553 | - 'opacity-fan' => array(), |
|
| 554 | - 'curve' => array( 'invert' ), |
|
| 555 | - 'curve-asymmetrical' => array( 'flip', 'invert' ), |
|
| 556 | - 'waves' => array( 'flip', 'invert' ), |
|
| 557 | - 'wave-brush' => array( 'flip' ), |
|
| 558 | - 'waves-pattern' => array( 'flip' ), |
|
| 559 | - 'arrow' => array( 'invert' ), |
|
| 560 | - 'split' => array( 'invert' ), |
|
| 561 | - 'book' => array( 'invert' ), |
|
| 562 | - ); |
|
| 563 | - |
|
| 564 | - $input[ $type . '_flip' ] = array( |
|
| 565 | - 'type' => 'checkbox', |
|
| 566 | - 'title' => __( 'Flip' ), |
|
| 567 | - 'default' => '', |
|
| 568 | - 'desc_tip' => true, |
|
| 569 | - 'group' => __( "Shape Divider" ), |
|
| 570 | - 'element_require' => sd_get_element_require_string( $requires, 'flip', 'sd' ) |
|
| 571 | - ); |
|
| 572 | - |
|
| 573 | - $input[ $type . '_invert' ] = array( |
|
| 574 | - 'type' => 'checkbox', |
|
| 575 | - 'title' => __( 'Invert' ), |
|
| 576 | - 'default' => '', |
|
| 577 | - 'desc_tip' => true, |
|
| 578 | - 'group' => __( "Shape Divider" ), |
|
| 579 | - 'element_require' => sd_get_element_require_string( $requires, 'invert', 'sd' ) |
|
| 580 | - ); |
|
| 581 | - |
|
| 582 | - $input[ $type . '_btf' ] = array( |
|
| 583 | - 'type' => 'checkbox', |
|
| 584 | - 'title' => __( 'Bring to front' ), |
|
| 585 | - 'default' => '', |
|
| 586 | - 'desc_tip' => true, |
|
| 587 | - 'group' => __( "Shape Divider" ), |
|
| 588 | - 'element_require' => '[%' . $type . '%]!=""' |
|
| 589 | - |
|
| 590 | - ); |
|
| 591 | - |
|
| 592 | - |
|
| 593 | - return $input; |
|
| 431 | + $options = array( |
|
| 432 | + '' => __( "None" ), |
|
| 433 | + 'mountains' => __( "Mountains" ), |
|
| 434 | + 'drops' => __( "Drops" ), |
|
| 435 | + 'clouds' => __( "Clouds" ), |
|
| 436 | + 'zigzag' => __( "Zigzag" ), |
|
| 437 | + 'pyramids' => __( "Pyramids" ), |
|
| 438 | + 'triangle' => __( "Triangle" ), |
|
| 439 | + 'triangle-asymmetrical' => __( "Triangle Asymmetrical" ), |
|
| 440 | + 'tilt' => __( "Tilt" ), |
|
| 441 | + 'opacity-tilt' => __( "Opacity Tilt" ), |
|
| 442 | + 'opacity-fan' => __( "Opacity Fan" ), |
|
| 443 | + 'curve' => __( "Curve" ), |
|
| 444 | + 'curve-asymmetrical' => __( "Curve Asymmetrical" ), |
|
| 445 | + 'waves' => __( "Waves" ), |
|
| 446 | + 'wave-brush' => __( "Wave Brush" ), |
|
| 447 | + 'waves-pattern' => __( "Waves Pattern" ), |
|
| 448 | + 'arrow' => __( "Arrow" ), |
|
| 449 | + 'split' => __( "Split" ), |
|
| 450 | + 'book' => __( "Book" ), |
|
| 451 | + ); |
|
| 452 | + |
|
| 453 | + $defaults = array( |
|
| 454 | + 'type' => 'select', |
|
| 455 | + 'title' => __( 'Type' ), |
|
| 456 | + 'options' => $options, |
|
| 457 | + 'default' => '', |
|
| 458 | + 'desc_tip' => true, |
|
| 459 | + 'group' => __( "Shape Divider" ), |
|
| 460 | + ); |
|
| 461 | + |
|
| 462 | + |
|
| 463 | + $input[ $type ] = wp_parse_args( $overwrite, $defaults ); |
|
| 464 | + |
|
| 465 | + |
|
| 466 | + $input[ $type . '_notice' ] = array( |
|
| 467 | + 'type' => 'notice', |
|
| 468 | + 'desc' => __( 'Parent element must be position `relative`' ), |
|
| 469 | + 'status' => 'warning', |
|
| 470 | + 'group' => __( "Shape Divider" ), |
|
| 471 | + 'element_require' => '[%' . $type . '%]!=""', |
|
| 472 | + ); |
|
| 473 | + |
|
| 474 | + |
|
| 475 | + $input[ $type . '_position' ] = wp_parse_args( $overwrite_color, array( |
|
| 476 | + 'type' => 'select', |
|
| 477 | + 'title' => __( 'Position' ), |
|
| 478 | + 'options' => array( |
|
| 479 | + 'top' => __( 'Top' ), |
|
| 480 | + 'bottom' => __( 'Bottom' ), |
|
| 481 | + //'left' => __('Left'), |
|
| 482 | + //'right' => __('Right'), |
|
| 483 | + ), |
|
| 484 | + 'desc_tip' => true, |
|
| 485 | + 'group' => __( "Shape Divider" ), |
|
| 486 | + 'element_require' => '[%' . $type . '%]!=""' |
|
| 487 | + ) ); |
|
| 488 | + |
|
| 489 | + $options = array( |
|
| 490 | + '' => __( "None" ), |
|
| 491 | + 'transparent' => __( "Transparent" ), |
|
| 492 | + ) + sd_aui_colors() |
|
| 493 | + + array( |
|
| 494 | + 'custom-color' => __( "Custom Color" ), |
|
| 495 | + ); |
|
| 496 | + |
|
| 497 | + $input[ $type . '_color' ] = wp_parse_args( $overwrite_color, array( |
|
| 498 | + 'type' => 'select', |
|
| 499 | + 'title' => __( 'Color' ), |
|
| 500 | + 'options' => $options, |
|
| 501 | + 'desc_tip' => true, |
|
| 502 | + 'group' => __( "Shape Divider" ), |
|
| 503 | + 'element_require' => '[%' . $type . '%]!=""' |
|
| 504 | + ) ); |
|
| 505 | + |
|
| 506 | + $input[ $type . '_custom_color' ] = wp_parse_args( $overwrite_color, array( |
|
| 507 | + 'type' => 'color', |
|
| 508 | + 'title' => __( 'Custom color' ), |
|
| 509 | + 'placeholder' => '', |
|
| 510 | + 'default' => '#0073aa', |
|
| 511 | + 'desc_tip' => true, |
|
| 512 | + 'group' => __( "Shape Divider" ), |
|
| 513 | + 'element_require' => '[%' . $type . '_color%]=="custom-color" && [%' . $type . '%]!=""' |
|
| 514 | + ) ); |
|
| 515 | + |
|
| 516 | + $input[ $type . '_width' ] = wp_parse_args( $overwrite_gradient, array( |
|
| 517 | + 'type' => 'range', |
|
| 518 | + 'title' => __( 'Width' ), |
|
| 519 | + 'placeholder' => '', |
|
| 520 | + 'default' => '200', |
|
| 521 | + 'desc_tip' => true, |
|
| 522 | + 'custom_attributes' => array( |
|
| 523 | + 'min' => 100, |
|
| 524 | + 'max' => 300, |
|
| 525 | + ), |
|
| 526 | + 'group' => __( "Shape Divider" ), |
|
| 527 | + 'element_require' => '[%' . $type . '%]!=""' |
|
| 528 | + ) ); |
|
| 529 | + |
|
| 530 | + $input[ $type . '_height' ] = array( |
|
| 531 | + 'type' => 'range', |
|
| 532 | + 'title' => __( 'Height' ), |
|
| 533 | + 'default' => '100', |
|
| 534 | + 'desc_tip' => true, |
|
| 535 | + 'custom_attributes' => array( |
|
| 536 | + 'min' => 0, |
|
| 537 | + 'max' => 500, |
|
| 538 | + ), |
|
| 539 | + 'group' => __( "Shape Divider" ), |
|
| 540 | + 'element_require' => '[%' . $type . '%]!=""' |
|
| 541 | + ); |
|
| 542 | + |
|
| 543 | + $requires = array( |
|
| 544 | + 'mountains' => array( 'flip' ), |
|
| 545 | + 'drops' => array( 'flip', 'invert' ), |
|
| 546 | + 'clouds' => array( 'flip', 'invert' ), |
|
| 547 | + 'zigzag' => array(), |
|
| 548 | + 'pyramids' => array( 'flip', 'invert' ), |
|
| 549 | + 'triangle' => array( 'invert' ), |
|
| 550 | + 'triangle-asymmetrical' => array( 'flip', 'invert' ), |
|
| 551 | + 'tilt' => array( 'flip' ), |
|
| 552 | + 'opacity-tilt' => array( 'flip' ), |
|
| 553 | + 'opacity-fan' => array(), |
|
| 554 | + 'curve' => array( 'invert' ), |
|
| 555 | + 'curve-asymmetrical' => array( 'flip', 'invert' ), |
|
| 556 | + 'waves' => array( 'flip', 'invert' ), |
|
| 557 | + 'wave-brush' => array( 'flip' ), |
|
| 558 | + 'waves-pattern' => array( 'flip' ), |
|
| 559 | + 'arrow' => array( 'invert' ), |
|
| 560 | + 'split' => array( 'invert' ), |
|
| 561 | + 'book' => array( 'invert' ), |
|
| 562 | + ); |
|
| 563 | + |
|
| 564 | + $input[ $type . '_flip' ] = array( |
|
| 565 | + 'type' => 'checkbox', |
|
| 566 | + 'title' => __( 'Flip' ), |
|
| 567 | + 'default' => '', |
|
| 568 | + 'desc_tip' => true, |
|
| 569 | + 'group' => __( "Shape Divider" ), |
|
| 570 | + 'element_require' => sd_get_element_require_string( $requires, 'flip', 'sd' ) |
|
| 571 | + ); |
|
| 572 | + |
|
| 573 | + $input[ $type . '_invert' ] = array( |
|
| 574 | + 'type' => 'checkbox', |
|
| 575 | + 'title' => __( 'Invert' ), |
|
| 576 | + 'default' => '', |
|
| 577 | + 'desc_tip' => true, |
|
| 578 | + 'group' => __( "Shape Divider" ), |
|
| 579 | + 'element_require' => sd_get_element_require_string( $requires, 'invert', 'sd' ) |
|
| 580 | + ); |
|
| 581 | + |
|
| 582 | + $input[ $type . '_btf' ] = array( |
|
| 583 | + 'type' => 'checkbox', |
|
| 584 | + 'title' => __( 'Bring to front' ), |
|
| 585 | + 'default' => '', |
|
| 586 | + 'desc_tip' => true, |
|
| 587 | + 'group' => __( "Shape Divider" ), |
|
| 588 | + 'element_require' => '[%' . $type . '%]!=""' |
|
| 589 | + |
|
| 590 | + ); |
|
| 591 | + |
|
| 592 | + |
|
| 593 | + return $input; |
|
| 594 | 594 | } |
| 595 | 595 | |
| 596 | 596 | /** |
@@ -603,23 +603,23 @@ discard block |
||
| 603 | 603 | * @return string |
| 604 | 604 | */ |
| 605 | 605 | function sd_get_element_require_string( $args, $key, $type ) { |
| 606 | - $output = ''; |
|
| 607 | - $requires = array(); |
|
| 606 | + $output = ''; |
|
| 607 | + $requires = array(); |
|
| 608 | 608 | |
| 609 | - if ( ! empty( $args ) ) { |
|
| 610 | - foreach ( $args as $t => $k ) { |
|
| 611 | - if ( in_array( $key, $k ) ) { |
|
| 612 | - $requires[] = '[%' . $type . '%]=="' . $t . '"'; |
|
| 613 | - } |
|
| 614 | - } |
|
| 609 | + if ( ! empty( $args ) ) { |
|
| 610 | + foreach ( $args as $t => $k ) { |
|
| 611 | + if ( in_array( $key, $k ) ) { |
|
| 612 | + $requires[] = '[%' . $type . '%]=="' . $t . '"'; |
|
| 613 | + } |
|
| 614 | + } |
|
| 615 | 615 | |
| 616 | - if ( ! empty( $requires ) ) { |
|
| 617 | - $output = '(' . implode( ' || ', $requires ) . ')'; |
|
| 618 | - } |
|
| 619 | - } |
|
| 616 | + if ( ! empty( $requires ) ) { |
|
| 617 | + $output = '(' . implode( ' || ', $requires ) . ')'; |
|
| 618 | + } |
|
| 619 | + } |
|
| 620 | 620 | |
| 621 | 621 | |
| 622 | - return $output; |
|
| 622 | + return $output; |
|
| 623 | 623 | } |
| 624 | 624 | |
| 625 | 625 | /** |
@@ -631,44 +631,44 @@ discard block |
||
| 631 | 631 | * @return array |
| 632 | 632 | */ |
| 633 | 633 | function sd_get_text_color_input( $type = 'text_color', $overwrite = array(), $has_custom = false ) { |
| 634 | - $options = array( |
|
| 635 | - '' => __( "None" ), |
|
| 636 | - ) + sd_aui_colors(); |
|
| 634 | + $options = array( |
|
| 635 | + '' => __( "None" ), |
|
| 636 | + ) + sd_aui_colors(); |
|
| 637 | 637 | |
| 638 | - if ( $has_custom ) { |
|
| 639 | - $options['custom'] = __( 'Custom color' ); |
|
| 640 | - } |
|
| 638 | + if ( $has_custom ) { |
|
| 639 | + $options['custom'] = __( 'Custom color' ); |
|
| 640 | + } |
|
| 641 | 641 | |
| 642 | - $defaults = array( |
|
| 643 | - 'type' => 'select', |
|
| 644 | - 'title' => __( 'Text color' ), |
|
| 645 | - 'options' => $options, |
|
| 646 | - 'default' => '', |
|
| 647 | - 'desc_tip' => true, |
|
| 648 | - 'group' => __( "Typography" ) |
|
| 649 | - ); |
|
| 642 | + $defaults = array( |
|
| 643 | + 'type' => 'select', |
|
| 644 | + 'title' => __( 'Text color' ), |
|
| 645 | + 'options' => $options, |
|
| 646 | + 'default' => '', |
|
| 647 | + 'desc_tip' => true, |
|
| 648 | + 'group' => __( "Typography" ) |
|
| 649 | + ); |
|
| 650 | 650 | |
| 651 | 651 | |
| 652 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 652 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 653 | 653 | |
| 654 | 654 | |
| 655 | - return $input; |
|
| 655 | + return $input; |
|
| 656 | 656 | } |
| 657 | 657 | |
| 658 | 658 | function sd_get_text_color_input_group( $type = 'text_color', $overwrite = array(), $overwrite_custom = array() ) { |
| 659 | - $inputs = array(); |
|
| 659 | + $inputs = array(); |
|
| 660 | 660 | |
| 661 | - if ( $overwrite !== false ) { |
|
| 662 | - $inputs[ $type ] = sd_get_text_color_input( $type, $overwrite, true ); |
|
| 663 | - } |
|
| 661 | + if ( $overwrite !== false ) { |
|
| 662 | + $inputs[ $type ] = sd_get_text_color_input( $type, $overwrite, true ); |
|
| 663 | + } |
|
| 664 | 664 | |
| 665 | - if ( $overwrite_custom !== false ) { |
|
| 666 | - $custom = $type . "_custom"; |
|
| 667 | - $inputs[ $custom ] = sd_get_custom_color_input( $custom, $overwrite_custom, $type ); |
|
| 668 | - } |
|
| 665 | + if ( $overwrite_custom !== false ) { |
|
| 666 | + $custom = $type . "_custom"; |
|
| 667 | + $inputs[ $custom ] = sd_get_custom_color_input( $custom, $overwrite_custom, $type ); |
|
| 668 | + } |
|
| 669 | 669 | |
| 670 | 670 | |
| 671 | - return $inputs; |
|
| 671 | + return $inputs; |
|
| 672 | 672 | } |
| 673 | 673 | |
| 674 | 674 | /** |
@@ -682,24 +682,24 @@ discard block |
||
| 682 | 682 | function sd_get_custom_color_input( $type = 'color_custom', $overwrite = array(), $parent_type = '' ) { |
| 683 | 683 | |
| 684 | 684 | |
| 685 | - $defaults = array( |
|
| 686 | - 'type' => 'color', |
|
| 687 | - 'title' => __( 'Custom color' ), |
|
| 688 | - 'default' => '', |
|
| 689 | - 'placeholder' => '', |
|
| 690 | - 'desc_tip' => true, |
|
| 691 | - 'group' => __( "Typography" ) |
|
| 692 | - ); |
|
| 685 | + $defaults = array( |
|
| 686 | + 'type' => 'color', |
|
| 687 | + 'title' => __( 'Custom color' ), |
|
| 688 | + 'default' => '', |
|
| 689 | + 'placeholder' => '', |
|
| 690 | + 'desc_tip' => true, |
|
| 691 | + 'group' => __( "Typography" ) |
|
| 692 | + ); |
|
| 693 | 693 | |
| 694 | - if ( $parent_type ) { |
|
| 695 | - $defaults['element_require'] = '[%' . $parent_type . '%]=="custom"'; |
|
| 696 | - } |
|
| 694 | + if ( $parent_type ) { |
|
| 695 | + $defaults['element_require'] = '[%' . $parent_type . '%]=="custom"'; |
|
| 696 | + } |
|
| 697 | 697 | |
| 698 | 698 | |
| 699 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 699 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 700 | 700 | |
| 701 | 701 | |
| 702 | - return $input; |
|
| 702 | + return $input; |
|
| 703 | 703 | } |
| 704 | 704 | |
| 705 | 705 | /** |
@@ -712,45 +712,45 @@ discard block |
||
| 712 | 712 | */ |
| 713 | 713 | function sd_get_col_input( $type = 'col', $overwrite = array() ) { |
| 714 | 714 | |
| 715 | - $device_size = ''; |
|
| 716 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 717 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 718 | - $device_size = '-md'; |
|
| 719 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 720 | - $device_size = '-lg'; |
|
| 721 | - } |
|
| 722 | - } |
|
| 723 | - $options = array( |
|
| 724 | - '' => __( 'auto' ), |
|
| 725 | - '1' => '1/12', |
|
| 726 | - '2' => '2/12', |
|
| 727 | - '3' => '3/12', |
|
| 728 | - '4' => '4/12', |
|
| 729 | - '5' => '5/12', |
|
| 730 | - '6' => '6/12', |
|
| 731 | - '7' => '7/12', |
|
| 732 | - '8' => '8/12', |
|
| 733 | - '9' => '9/12', |
|
| 734 | - '10' => '10/12', |
|
| 735 | - '11' => '11/12', |
|
| 736 | - '12' => '12/12', |
|
| 737 | - ); |
|
| 738 | - |
|
| 739 | - $defaults = array( |
|
| 740 | - 'type' => 'select', |
|
| 741 | - 'title' => __( 'Column width' ), |
|
| 742 | - 'options' => $options, |
|
| 743 | - 'default' => '', |
|
| 744 | - 'desc_tip' => true, |
|
| 745 | - 'group' => __( "Container" ), |
|
| 746 | - 'element_require' => '[%container%]=="col"', |
|
| 747 | - ); |
|
| 748 | - |
|
| 749 | - |
|
| 750 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 751 | - |
|
| 752 | - |
|
| 753 | - return $input; |
|
| 715 | + $device_size = ''; |
|
| 716 | + if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 717 | + if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 718 | + $device_size = '-md'; |
|
| 719 | + } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 720 | + $device_size = '-lg'; |
|
| 721 | + } |
|
| 722 | + } |
|
| 723 | + $options = array( |
|
| 724 | + '' => __( 'auto' ), |
|
| 725 | + '1' => '1/12', |
|
| 726 | + '2' => '2/12', |
|
| 727 | + '3' => '3/12', |
|
| 728 | + '4' => '4/12', |
|
| 729 | + '5' => '5/12', |
|
| 730 | + '6' => '6/12', |
|
| 731 | + '7' => '7/12', |
|
| 732 | + '8' => '8/12', |
|
| 733 | + '9' => '9/12', |
|
| 734 | + '10' => '10/12', |
|
| 735 | + '11' => '11/12', |
|
| 736 | + '12' => '12/12', |
|
| 737 | + ); |
|
| 738 | + |
|
| 739 | + $defaults = array( |
|
| 740 | + 'type' => 'select', |
|
| 741 | + 'title' => __( 'Column width' ), |
|
| 742 | + 'options' => $options, |
|
| 743 | + 'default' => '', |
|
| 744 | + 'desc_tip' => true, |
|
| 745 | + 'group' => __( "Container" ), |
|
| 746 | + 'element_require' => '[%container%]=="col"', |
|
| 747 | + ); |
|
| 748 | + |
|
| 749 | + |
|
| 750 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 751 | + |
|
| 752 | + |
|
| 753 | + return $input; |
|
| 754 | 754 | } |
| 755 | 755 | |
| 756 | 756 | /** |
@@ -763,39 +763,39 @@ discard block |
||
| 763 | 763 | */ |
| 764 | 764 | function sd_get_row_cols_input( $type = 'row_cols', $overwrite = array() ) { |
| 765 | 765 | |
| 766 | - $device_size = ''; |
|
| 767 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 768 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 769 | - $device_size = '-md'; |
|
| 770 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 771 | - $device_size = '-lg'; |
|
| 772 | - } |
|
| 773 | - } |
|
| 774 | - $options = array( |
|
| 775 | - '' => __( 'auto' ), |
|
| 776 | - '1' => '1', |
|
| 777 | - '2' => '2', |
|
| 778 | - '3' => '3', |
|
| 779 | - '4' => '4', |
|
| 780 | - '5' => '5', |
|
| 781 | - '6' => '6', |
|
| 782 | - ); |
|
| 783 | - |
|
| 784 | - $defaults = array( |
|
| 785 | - 'type' => 'select', |
|
| 786 | - 'title' => __( 'Row columns' ), |
|
| 787 | - 'options' => $options, |
|
| 788 | - 'default' => '', |
|
| 789 | - 'desc_tip' => true, |
|
| 790 | - 'group' => __( "Container" ), |
|
| 791 | - 'element_require' => '[%container%]=="row"', |
|
| 792 | - ); |
|
| 793 | - |
|
| 794 | - |
|
| 795 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 796 | - |
|
| 797 | - |
|
| 798 | - return $input; |
|
| 766 | + $device_size = ''; |
|
| 767 | + if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 768 | + if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 769 | + $device_size = '-md'; |
|
| 770 | + } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 771 | + $device_size = '-lg'; |
|
| 772 | + } |
|
| 773 | + } |
|
| 774 | + $options = array( |
|
| 775 | + '' => __( 'auto' ), |
|
| 776 | + '1' => '1', |
|
| 777 | + '2' => '2', |
|
| 778 | + '3' => '3', |
|
| 779 | + '4' => '4', |
|
| 780 | + '5' => '5', |
|
| 781 | + '6' => '6', |
|
| 782 | + ); |
|
| 783 | + |
|
| 784 | + $defaults = array( |
|
| 785 | + 'type' => 'select', |
|
| 786 | + 'title' => __( 'Row columns' ), |
|
| 787 | + 'options' => $options, |
|
| 788 | + 'default' => '', |
|
| 789 | + 'desc_tip' => true, |
|
| 790 | + 'group' => __( "Container" ), |
|
| 791 | + 'element_require' => '[%container%]=="row"', |
|
| 792 | + ); |
|
| 793 | + |
|
| 794 | + |
|
| 795 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 796 | + |
|
| 797 | + |
|
| 798 | + return $input; |
|
| 799 | 799 | } |
| 800 | 800 | |
| 801 | 801 | /** |
@@ -808,35 +808,35 @@ discard block |
||
| 808 | 808 | */ |
| 809 | 809 | function sd_get_text_align_input( $type = 'text_align', $overwrite = array() ) { |
| 810 | 810 | |
| 811 | - $device_size = ''; |
|
| 812 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 813 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 814 | - $device_size = '-md'; |
|
| 815 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 816 | - $device_size = '-lg'; |
|
| 817 | - } |
|
| 818 | - } |
|
| 819 | - $options = array( |
|
| 820 | - '' => __( "Default" ), |
|
| 821 | - 'text' . $device_size . '-left' => __( "Left" ), |
|
| 822 | - 'text' . $device_size . '-right' => __( "Right" ), |
|
| 823 | - 'text' . $device_size . '-center' => __( "Center" ), |
|
| 824 | - ); |
|
| 825 | - |
|
| 826 | - $defaults = array( |
|
| 827 | - 'type' => 'select', |
|
| 828 | - 'title' => __( 'Text align' ), |
|
| 829 | - 'options' => $options, |
|
| 830 | - 'default' => '', |
|
| 831 | - 'desc_tip' => true, |
|
| 832 | - 'group' => __( "Typography" ) |
|
| 833 | - ); |
|
| 834 | - |
|
| 835 | - |
|
| 836 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 837 | - |
|
| 838 | - |
|
| 839 | - return $input; |
|
| 811 | + $device_size = ''; |
|
| 812 | + if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 813 | + if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 814 | + $device_size = '-md'; |
|
| 815 | + } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 816 | + $device_size = '-lg'; |
|
| 817 | + } |
|
| 818 | + } |
|
| 819 | + $options = array( |
|
| 820 | + '' => __( "Default" ), |
|
| 821 | + 'text' . $device_size . '-left' => __( "Left" ), |
|
| 822 | + 'text' . $device_size . '-right' => __( "Right" ), |
|
| 823 | + 'text' . $device_size . '-center' => __( "Center" ), |
|
| 824 | + ); |
|
| 825 | + |
|
| 826 | + $defaults = array( |
|
| 827 | + 'type' => 'select', |
|
| 828 | + 'title' => __( 'Text align' ), |
|
| 829 | + 'options' => $options, |
|
| 830 | + 'default' => '', |
|
| 831 | + 'desc_tip' => true, |
|
| 832 | + 'group' => __( "Typography" ) |
|
| 833 | + ); |
|
| 834 | + |
|
| 835 | + |
|
| 836 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 837 | + |
|
| 838 | + |
|
| 839 | + return $input; |
|
| 840 | 840 | } |
| 841 | 841 | |
| 842 | 842 | /** |
@@ -849,41 +849,41 @@ discard block |
||
| 849 | 849 | */ |
| 850 | 850 | function sd_get_display_input( $type = 'display', $overwrite = array() ) { |
| 851 | 851 | |
| 852 | - $device_size = ''; |
|
| 853 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 854 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 855 | - $device_size = '-md'; |
|
| 856 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 857 | - $device_size = '-lg'; |
|
| 858 | - } |
|
| 859 | - } |
|
| 860 | - $options = array( |
|
| 861 | - '' => __( "Default" ), |
|
| 862 | - 'd' . $device_size . '-none' => "none", |
|
| 863 | - 'd' . $device_size . '-inline' => "inline", |
|
| 864 | - 'd' . $device_size . '-inline-block' => "inline-block", |
|
| 865 | - 'd' . $device_size . '-block' => "block", |
|
| 866 | - 'd' . $device_size . '-table' => "table", |
|
| 867 | - 'd' . $device_size . '-table-cell' => "table-cell", |
|
| 868 | - 'd' . $device_size . '-table-row' => "table-row", |
|
| 869 | - 'd' . $device_size . '-flex' => "flex", |
|
| 870 | - 'd' . $device_size . '-inline-flex' => "inline-flex", |
|
| 871 | - ); |
|
| 872 | - |
|
| 873 | - $defaults = array( |
|
| 874 | - 'type' => 'select', |
|
| 875 | - 'title' => __( 'Display' ), |
|
| 876 | - 'options' => $options, |
|
| 877 | - 'default' => '', |
|
| 878 | - 'desc_tip' => true, |
|
| 879 | - 'group' => __( "Wrapper Styles" ) |
|
| 880 | - ); |
|
| 881 | - |
|
| 882 | - |
|
| 883 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 884 | - |
|
| 885 | - |
|
| 886 | - return $input; |
|
| 852 | + $device_size = ''; |
|
| 853 | + if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 854 | + if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 855 | + $device_size = '-md'; |
|
| 856 | + } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 857 | + $device_size = '-lg'; |
|
| 858 | + } |
|
| 859 | + } |
|
| 860 | + $options = array( |
|
| 861 | + '' => __( "Default" ), |
|
| 862 | + 'd' . $device_size . '-none' => "none", |
|
| 863 | + 'd' . $device_size . '-inline' => "inline", |
|
| 864 | + 'd' . $device_size . '-inline-block' => "inline-block", |
|
| 865 | + 'd' . $device_size . '-block' => "block", |
|
| 866 | + 'd' . $device_size . '-table' => "table", |
|
| 867 | + 'd' . $device_size . '-table-cell' => "table-cell", |
|
| 868 | + 'd' . $device_size . '-table-row' => "table-row", |
|
| 869 | + 'd' . $device_size . '-flex' => "flex", |
|
| 870 | + 'd' . $device_size . '-inline-flex' => "inline-flex", |
|
| 871 | + ); |
|
| 872 | + |
|
| 873 | + $defaults = array( |
|
| 874 | + 'type' => 'select', |
|
| 875 | + 'title' => __( 'Display' ), |
|
| 876 | + 'options' => $options, |
|
| 877 | + 'default' => '', |
|
| 878 | + 'desc_tip' => true, |
|
| 879 | + 'group' => __( "Wrapper Styles" ) |
|
| 880 | + ); |
|
| 881 | + |
|
| 882 | + |
|
| 883 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 884 | + |
|
| 885 | + |
|
| 886 | + return $input; |
|
| 887 | 887 | } |
| 888 | 888 | |
| 889 | 889 | /** |
@@ -896,19 +896,19 @@ discard block |
||
| 896 | 896 | */ |
| 897 | 897 | function sd_get_text_justify_input( $type = 'text_justify', $overwrite = array() ) { |
| 898 | 898 | |
| 899 | - $defaults = array( |
|
| 900 | - 'type' => 'checkbox', |
|
| 901 | - 'title' => __( 'Text justify' ), |
|
| 902 | - 'default' => '', |
|
| 903 | - 'desc_tip' => true, |
|
| 904 | - 'group' => __( "Typography" ) |
|
| 905 | - ); |
|
| 899 | + $defaults = array( |
|
| 900 | + 'type' => 'checkbox', |
|
| 901 | + 'title' => __( 'Text justify' ), |
|
| 902 | + 'default' => '', |
|
| 903 | + 'desc_tip' => true, |
|
| 904 | + 'group' => __( "Typography" ) |
|
| 905 | + ); |
|
| 906 | 906 | |
| 907 | 907 | |
| 908 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 908 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 909 | 909 | |
| 910 | 910 | |
| 911 | - return $input; |
|
| 911 | + return $input; |
|
| 912 | 912 | } |
| 913 | 913 | |
| 914 | 914 | /** |
@@ -921,51 +921,51 @@ discard block |
||
| 921 | 921 | * @return array |
| 922 | 922 | */ |
| 923 | 923 | function sd_aui_colors( $include_branding = false, $include_outlines = false, $outline_button_only_text = false ) { |
| 924 | - $theme_colors = array(); |
|
| 925 | - |
|
| 926 | - $theme_colors["primary"] = __( 'Primary' ); |
|
| 927 | - $theme_colors["secondary"] = __( 'Secondary' ); |
|
| 928 | - $theme_colors["success"] = __( 'Success' ); |
|
| 929 | - $theme_colors["danger"] = __( 'Danger' ); |
|
| 930 | - $theme_colors["warning"] = __( 'Warning' ); |
|
| 931 | - $theme_colors["info"] = __( 'Info' ); |
|
| 932 | - $theme_colors["light"] = __( 'Light' ); |
|
| 933 | - $theme_colors["dark"] = __( 'Dark' ); |
|
| 934 | - $theme_colors["white"] = __( 'White' ); |
|
| 935 | - $theme_colors["purple"] = __( 'Purple' ); |
|
| 936 | - $theme_colors["salmon"] = __( 'Salmon' ); |
|
| 937 | - $theme_colors["cyan"] = __( 'Cyan' ); |
|
| 938 | - $theme_colors["gray"] = __( 'Gray' ); |
|
| 939 | - $theme_colors["gray-dark"] = __( 'Gray dark' ); |
|
| 940 | - $theme_colors["indigo"] = __( 'Indigo' ); |
|
| 941 | - $theme_colors["orange"] = __( 'Orange' ); |
|
| 942 | - |
|
| 943 | - if ( $include_outlines ) { |
|
| 944 | - $button_only = $outline_button_only_text ? " " . __( "(button only)" ) : ''; |
|
| 945 | - $theme_colors["outline-primary"] = __( 'Primary outline' ) . $button_only; |
|
| 946 | - $theme_colors["outline-secondary"] = __( 'Secondary outline' ) . $button_only; |
|
| 947 | - $theme_colors["outline-success"] = __( 'Success outline' ) . $button_only; |
|
| 948 | - $theme_colors["outline-danger"] = __( 'Danger outline' ) . $button_only; |
|
| 949 | - $theme_colors["outline-warning"] = __( 'Warning outline' ) . $button_only; |
|
| 950 | - $theme_colors["outline-info"] = __( 'Info outline' ) . $button_only; |
|
| 951 | - $theme_colors["outline-light"] = __( 'Light outline' ) . $button_only; |
|
| 952 | - $theme_colors["outline-dark"] = __( 'Dark outline' ) . $button_only; |
|
| 953 | - $theme_colors["outline-white"] = __( 'White outline' ) . $button_only; |
|
| 954 | - $theme_colors["outline-purple"] = __( 'Purple outline' ) . $button_only; |
|
| 955 | - $theme_colors["outline-salmon"] = __( 'Salmon outline' ) . $button_only; |
|
| 956 | - $theme_colors["outline-cyan"] = __( 'Cyan outline' ) . $button_only; |
|
| 957 | - $theme_colors["outline-gray"] = __( 'Gray outline' ) . $button_only; |
|
| 958 | - $theme_colors["outline-gray-dark"] = __( 'Gray dark outline' ) . $button_only; |
|
| 959 | - $theme_colors["outline-indigo"] = __( 'Indigo outline' ) . $button_only; |
|
| 960 | - $theme_colors["outline-orange"] = __( 'Orange outline' ) . $button_only; |
|
| 961 | - } |
|
| 962 | - |
|
| 963 | - |
|
| 964 | - if ( $include_branding ) { |
|
| 965 | - $theme_colors = $theme_colors + sd_aui_branding_colors(); |
|
| 966 | - } |
|
| 967 | - |
|
| 968 | - return apply_filters( 'sd_aui_colors', $theme_colors, $include_outlines, $include_branding ); |
|
| 924 | + $theme_colors = array(); |
|
| 925 | + |
|
| 926 | + $theme_colors["primary"] = __( 'Primary' ); |
|
| 927 | + $theme_colors["secondary"] = __( 'Secondary' ); |
|
| 928 | + $theme_colors["success"] = __( 'Success' ); |
|
| 929 | + $theme_colors["danger"] = __( 'Danger' ); |
|
| 930 | + $theme_colors["warning"] = __( 'Warning' ); |
|
| 931 | + $theme_colors["info"] = __( 'Info' ); |
|
| 932 | + $theme_colors["light"] = __( 'Light' ); |
|
| 933 | + $theme_colors["dark"] = __( 'Dark' ); |
|
| 934 | + $theme_colors["white"] = __( 'White' ); |
|
| 935 | + $theme_colors["purple"] = __( 'Purple' ); |
|
| 936 | + $theme_colors["salmon"] = __( 'Salmon' ); |
|
| 937 | + $theme_colors["cyan"] = __( 'Cyan' ); |
|
| 938 | + $theme_colors["gray"] = __( 'Gray' ); |
|
| 939 | + $theme_colors["gray-dark"] = __( 'Gray dark' ); |
|
| 940 | + $theme_colors["indigo"] = __( 'Indigo' ); |
|
| 941 | + $theme_colors["orange"] = __( 'Orange' ); |
|
| 942 | + |
|
| 943 | + if ( $include_outlines ) { |
|
| 944 | + $button_only = $outline_button_only_text ? " " . __( "(button only)" ) : ''; |
|
| 945 | + $theme_colors["outline-primary"] = __( 'Primary outline' ) . $button_only; |
|
| 946 | + $theme_colors["outline-secondary"] = __( 'Secondary outline' ) . $button_only; |
|
| 947 | + $theme_colors["outline-success"] = __( 'Success outline' ) . $button_only; |
|
| 948 | + $theme_colors["outline-danger"] = __( 'Danger outline' ) . $button_only; |
|
| 949 | + $theme_colors["outline-warning"] = __( 'Warning outline' ) . $button_only; |
|
| 950 | + $theme_colors["outline-info"] = __( 'Info outline' ) . $button_only; |
|
| 951 | + $theme_colors["outline-light"] = __( 'Light outline' ) . $button_only; |
|
| 952 | + $theme_colors["outline-dark"] = __( 'Dark outline' ) . $button_only; |
|
| 953 | + $theme_colors["outline-white"] = __( 'White outline' ) . $button_only; |
|
| 954 | + $theme_colors["outline-purple"] = __( 'Purple outline' ) . $button_only; |
|
| 955 | + $theme_colors["outline-salmon"] = __( 'Salmon outline' ) . $button_only; |
|
| 956 | + $theme_colors["outline-cyan"] = __( 'Cyan outline' ) . $button_only; |
|
| 957 | + $theme_colors["outline-gray"] = __( 'Gray outline' ) . $button_only; |
|
| 958 | + $theme_colors["outline-gray-dark"] = __( 'Gray dark outline' ) . $button_only; |
|
| 959 | + $theme_colors["outline-indigo"] = __( 'Indigo outline' ) . $button_only; |
|
| 960 | + $theme_colors["outline-orange"] = __( 'Orange outline' ) . $button_only; |
|
| 961 | + } |
|
| 962 | + |
|
| 963 | + |
|
| 964 | + if ( $include_branding ) { |
|
| 965 | + $theme_colors = $theme_colors + sd_aui_branding_colors(); |
|
| 966 | + } |
|
| 967 | + |
|
| 968 | + return apply_filters( 'sd_aui_colors', $theme_colors, $include_outlines, $include_branding ); |
|
| 969 | 969 | } |
| 970 | 970 | |
| 971 | 971 | /** |
@@ -974,19 +974,19 @@ discard block |
||
| 974 | 974 | * @return array |
| 975 | 975 | */ |
| 976 | 976 | function sd_aui_branding_colors() { |
| 977 | - return array( |
|
| 978 | - "facebook" => __( 'Facebook' ), |
|
| 979 | - "twitter" => __( 'Twitter' ), |
|
| 980 | - "instagram" => __( 'Instagram' ), |
|
| 981 | - "linkedin" => __( 'Linkedin' ), |
|
| 982 | - "flickr" => __( 'Flickr' ), |
|
| 983 | - "github" => __( 'GitHub' ), |
|
| 984 | - "youtube" => __( 'YouTube' ), |
|
| 985 | - "wordpress" => __( 'WordPress' ), |
|
| 986 | - "google" => __( 'Google' ), |
|
| 987 | - "yahoo" => __( 'Yahoo' ), |
|
| 988 | - "vkontakte" => __( 'Vkontakte' ), |
|
| 989 | - ); |
|
| 977 | + return array( |
|
| 978 | + "facebook" => __( 'Facebook' ), |
|
| 979 | + "twitter" => __( 'Twitter' ), |
|
| 980 | + "instagram" => __( 'Instagram' ), |
|
| 981 | + "linkedin" => __( 'Linkedin' ), |
|
| 982 | + "flickr" => __( 'Flickr' ), |
|
| 983 | + "github" => __( 'GitHub' ), |
|
| 984 | + "youtube" => __( 'YouTube' ), |
|
| 985 | + "wordpress" => __( 'WordPress' ), |
|
| 986 | + "google" => __( 'Google' ), |
|
| 987 | + "yahoo" => __( 'Yahoo' ), |
|
| 988 | + "vkontakte" => __( 'Vkontakte' ), |
|
| 989 | + ); |
|
| 990 | 990 | } |
| 991 | 991 | |
| 992 | 992 | |
@@ -1001,38 +1001,38 @@ discard block |
||
| 1001 | 1001 | function sd_get_container_class_input( $type = 'container', $overwrite = array() ) { |
| 1002 | 1002 | |
| 1003 | 1003 | |
| 1004 | - $options = array( |
|
| 1005 | - "container" => __( 'container (default)' ), |
|
| 1006 | - "container-sm" => 'container-sm', |
|
| 1007 | - "container-md" => 'container-md', |
|
| 1008 | - "container-lg" => 'container-lg', |
|
| 1009 | - "container-xl" => 'container-xl', |
|
| 1010 | - "container-xxl" => 'container-xxl', |
|
| 1011 | - "container-fluid" => 'container-fluid', |
|
| 1012 | - "row" => 'row', |
|
| 1013 | - "col" => 'col', |
|
| 1014 | - "card" => 'card', |
|
| 1015 | - "card-header" => 'card-header', |
|
| 1016 | - "card-body" => 'card-body', |
|
| 1017 | - "card-footer" => 'card-footer', |
|
| 1018 | - "list-group" => 'list-group', |
|
| 1019 | - "list-group-item" => 'list-group-item', |
|
| 1020 | - ); |
|
| 1021 | - |
|
| 1022 | - $defaults = array( |
|
| 1023 | - 'type' => 'select', |
|
| 1024 | - 'title' => __( 'Type' ), |
|
| 1025 | - 'options' => $options, |
|
| 1026 | - 'default' => '', |
|
| 1027 | - 'desc_tip' => true, |
|
| 1028 | - 'group' => __( "Container" ) |
|
| 1029 | - ); |
|
| 1030 | - |
|
| 1031 | - |
|
| 1032 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1033 | - |
|
| 1034 | - |
|
| 1035 | - return $input; |
|
| 1004 | + $options = array( |
|
| 1005 | + "container" => __( 'container (default)' ), |
|
| 1006 | + "container-sm" => 'container-sm', |
|
| 1007 | + "container-md" => 'container-md', |
|
| 1008 | + "container-lg" => 'container-lg', |
|
| 1009 | + "container-xl" => 'container-xl', |
|
| 1010 | + "container-xxl" => 'container-xxl', |
|
| 1011 | + "container-fluid" => 'container-fluid', |
|
| 1012 | + "row" => 'row', |
|
| 1013 | + "col" => 'col', |
|
| 1014 | + "card" => 'card', |
|
| 1015 | + "card-header" => 'card-header', |
|
| 1016 | + "card-body" => 'card-body', |
|
| 1017 | + "card-footer" => 'card-footer', |
|
| 1018 | + "list-group" => 'list-group', |
|
| 1019 | + "list-group-item" => 'list-group-item', |
|
| 1020 | + ); |
|
| 1021 | + |
|
| 1022 | + $defaults = array( |
|
| 1023 | + 'type' => 'select', |
|
| 1024 | + 'title' => __( 'Type' ), |
|
| 1025 | + 'options' => $options, |
|
| 1026 | + 'default' => '', |
|
| 1027 | + 'desc_tip' => true, |
|
| 1028 | + 'group' => __( "Container" ) |
|
| 1029 | + ); |
|
| 1030 | + |
|
| 1031 | + |
|
| 1032 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1033 | + |
|
| 1034 | + |
|
| 1035 | + return $input; |
|
| 1036 | 1036 | } |
| 1037 | 1037 | |
| 1038 | 1038 | /** |
@@ -1046,32 +1046,32 @@ discard block |
||
| 1046 | 1046 | function sd_get_position_class_input( $type = 'position', $overwrite = array() ) { |
| 1047 | 1047 | |
| 1048 | 1048 | |
| 1049 | - $options = array( |
|
| 1050 | - "" => __( 'Default' ), |
|
| 1051 | - "position-static" => 'static', |
|
| 1052 | - "position-relative" => 'relative', |
|
| 1053 | - "position-absolute" => 'absolute', |
|
| 1054 | - "position-fixed" => 'fixed', |
|
| 1055 | - "position-sticky" => 'sticky', |
|
| 1056 | - "fixed-top" => 'fixed-top', |
|
| 1057 | - "fixed-bottom" => 'fixed-bottom', |
|
| 1058 | - "sticky-top" => 'sticky-top', |
|
| 1059 | - ); |
|
| 1049 | + $options = array( |
|
| 1050 | + "" => __( 'Default' ), |
|
| 1051 | + "position-static" => 'static', |
|
| 1052 | + "position-relative" => 'relative', |
|
| 1053 | + "position-absolute" => 'absolute', |
|
| 1054 | + "position-fixed" => 'fixed', |
|
| 1055 | + "position-sticky" => 'sticky', |
|
| 1056 | + "fixed-top" => 'fixed-top', |
|
| 1057 | + "fixed-bottom" => 'fixed-bottom', |
|
| 1058 | + "sticky-top" => 'sticky-top', |
|
| 1059 | + ); |
|
| 1060 | 1060 | |
| 1061 | - $defaults = array( |
|
| 1062 | - 'type' => 'select', |
|
| 1063 | - 'title' => __( 'Position' ), |
|
| 1064 | - 'options' => $options, |
|
| 1065 | - 'default' => '', |
|
| 1066 | - 'desc_tip' => true, |
|
| 1067 | - 'group' => __( "Wrapper Styles" ) |
|
| 1068 | - ); |
|
| 1061 | + $defaults = array( |
|
| 1062 | + 'type' => 'select', |
|
| 1063 | + 'title' => __( 'Position' ), |
|
| 1064 | + 'options' => $options, |
|
| 1065 | + 'default' => '', |
|
| 1066 | + 'desc_tip' => true, |
|
| 1067 | + 'group' => __( "Wrapper Styles" ) |
|
| 1068 | + ); |
|
| 1069 | 1069 | |
| 1070 | 1070 | |
| 1071 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1071 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1072 | 1072 | |
| 1073 | 1073 | |
| 1074 | - return $input; |
|
| 1074 | + return $input; |
|
| 1075 | 1075 | } |
| 1076 | 1076 | |
| 1077 | 1077 | /** |
@@ -1084,40 +1084,40 @@ discard block |
||
| 1084 | 1084 | */ |
| 1085 | 1085 | function sd_get_sticky_offset_input( $type = 'top', $overwrite = array() ) { |
| 1086 | 1086 | |
| 1087 | - $defaults = array( |
|
| 1088 | - 'type' => 'number', |
|
| 1089 | - 'title' => __( 'Sticky offset' ), |
|
| 1090 | - //'desc' => __('Sticky offset'), |
|
| 1091 | - 'default' => '', |
|
| 1092 | - 'desc_tip' => true, |
|
| 1093 | - 'group' => __( "Wrapper Styles" ), |
|
| 1094 | - 'element_require' => '[%position%]=="sticky" || [%position%]=="sticky-top"' |
|
| 1095 | - ); |
|
| 1096 | - |
|
| 1097 | - // title |
|
| 1098 | - if ( $type == 'top' ) { |
|
| 1099 | - $defaults['title'] = __( 'Top offset' ); |
|
| 1100 | - $defaults['icon'] = 'box-top'; |
|
| 1101 | - $defaults['row'] = array( |
|
| 1102 | - 'title' => __( 'Sticky offset' ), |
|
| 1103 | - 'key' => 'sticky-offset', |
|
| 1104 | - 'open' => true, |
|
| 1105 | - 'class' => 'text-center', |
|
| 1106 | - ); |
|
| 1107 | - } elseif ( $type == 'bottom' ) { |
|
| 1108 | - $defaults['title'] = __( 'Bottom offset' ); |
|
| 1109 | - $defaults['icon'] = 'box-bottom'; |
|
| 1110 | - $defaults['row'] = array( |
|
| 1111 | - 'key' => 'sticky-offset', |
|
| 1112 | - 'close' => true, |
|
| 1113 | - ); |
|
| 1114 | - } |
|
| 1115 | - |
|
| 1116 | - |
|
| 1117 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1118 | - |
|
| 1119 | - |
|
| 1120 | - return $input; |
|
| 1087 | + $defaults = array( |
|
| 1088 | + 'type' => 'number', |
|
| 1089 | + 'title' => __( 'Sticky offset' ), |
|
| 1090 | + //'desc' => __('Sticky offset'), |
|
| 1091 | + 'default' => '', |
|
| 1092 | + 'desc_tip' => true, |
|
| 1093 | + 'group' => __( "Wrapper Styles" ), |
|
| 1094 | + 'element_require' => '[%position%]=="sticky" || [%position%]=="sticky-top"' |
|
| 1095 | + ); |
|
| 1096 | + |
|
| 1097 | + // title |
|
| 1098 | + if ( $type == 'top' ) { |
|
| 1099 | + $defaults['title'] = __( 'Top offset' ); |
|
| 1100 | + $defaults['icon'] = 'box-top'; |
|
| 1101 | + $defaults['row'] = array( |
|
| 1102 | + 'title' => __( 'Sticky offset' ), |
|
| 1103 | + 'key' => 'sticky-offset', |
|
| 1104 | + 'open' => true, |
|
| 1105 | + 'class' => 'text-center', |
|
| 1106 | + ); |
|
| 1107 | + } elseif ( $type == 'bottom' ) { |
|
| 1108 | + $defaults['title'] = __( 'Bottom offset' ); |
|
| 1109 | + $defaults['icon'] = 'box-bottom'; |
|
| 1110 | + $defaults['row'] = array( |
|
| 1111 | + 'key' => 'sticky-offset', |
|
| 1112 | + 'close' => true, |
|
| 1113 | + ); |
|
| 1114 | + } |
|
| 1115 | + |
|
| 1116 | + |
|
| 1117 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1118 | + |
|
| 1119 | + |
|
| 1120 | + return $input; |
|
| 1121 | 1121 | } |
| 1122 | 1122 | |
| 1123 | 1123 | /** |
@@ -1131,38 +1131,38 @@ discard block |
||
| 1131 | 1131 | function sd_get_font_size_input( $type = 'font_size', $overwrite = array(), $has_custom = false ) { |
| 1132 | 1132 | |
| 1133 | 1133 | |
| 1134 | - $options = array( |
|
| 1135 | - "" => __( 'Inherit from parent' ), |
|
| 1136 | - "h6" => 'h6', |
|
| 1137 | - "h5" => 'h5', |
|
| 1138 | - "h4" => 'h4', |
|
| 1139 | - "h3" => 'h3', |
|
| 1140 | - "h2" => 'h2', |
|
| 1141 | - "h1" => 'h1', |
|
| 1142 | - "display-1" => "display-1", |
|
| 1143 | - "display-2" => "display-2", |
|
| 1144 | - "display-3" => "display-3", |
|
| 1145 | - "display-4" => "display-4", |
|
| 1146 | - ); |
|
| 1134 | + $options = array( |
|
| 1135 | + "" => __( 'Inherit from parent' ), |
|
| 1136 | + "h6" => 'h6', |
|
| 1137 | + "h5" => 'h5', |
|
| 1138 | + "h4" => 'h4', |
|
| 1139 | + "h3" => 'h3', |
|
| 1140 | + "h2" => 'h2', |
|
| 1141 | + "h1" => 'h1', |
|
| 1142 | + "display-1" => "display-1", |
|
| 1143 | + "display-2" => "display-2", |
|
| 1144 | + "display-3" => "display-3", |
|
| 1145 | + "display-4" => "display-4", |
|
| 1146 | + ); |
|
| 1147 | 1147 | |
| 1148 | - if ( $has_custom ) { |
|
| 1149 | - $options['custom'] = __( 'Custom size' ); |
|
| 1150 | - } |
|
| 1148 | + if ( $has_custom ) { |
|
| 1149 | + $options['custom'] = __( 'Custom size' ); |
|
| 1150 | + } |
|
| 1151 | 1151 | |
| 1152 | - $defaults = array( |
|
| 1153 | - 'type' => 'select', |
|
| 1154 | - 'title' => __( 'Font size' ), |
|
| 1155 | - 'options' => $options, |
|
| 1156 | - 'default' => '', |
|
| 1157 | - 'desc_tip' => true, |
|
| 1158 | - 'group' => __( "Typography" ) |
|
| 1159 | - ); |
|
| 1152 | + $defaults = array( |
|
| 1153 | + 'type' => 'select', |
|
| 1154 | + 'title' => __( 'Font size' ), |
|
| 1155 | + 'options' => $options, |
|
| 1156 | + 'default' => '', |
|
| 1157 | + 'desc_tip' => true, |
|
| 1158 | + 'group' => __( "Typography" ) |
|
| 1159 | + ); |
|
| 1160 | 1160 | |
| 1161 | 1161 | |
| 1162 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1162 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1163 | 1163 | |
| 1164 | 1164 | |
| 1165 | - return $input; |
|
| 1165 | + return $input; |
|
| 1166 | 1166 | } |
| 1167 | 1167 | |
| 1168 | 1168 | /** |
@@ -1176,29 +1176,29 @@ discard block |
||
| 1176 | 1176 | function sd_get_font_custom_size_input( $type = 'font_size_custom', $overwrite = array(), $parent_type = '' ) { |
| 1177 | 1177 | |
| 1178 | 1178 | |
| 1179 | - $defaults = array( |
|
| 1180 | - 'type' => 'number', |
|
| 1181 | - 'title' => __( 'Font size (rem)' ), |
|
| 1182 | - 'default' => '', |
|
| 1183 | - 'placeholder' => '1.25', |
|
| 1184 | - 'custom_attributes' => array( |
|
| 1185 | - 'step' => '0.1', |
|
| 1186 | - 'min' => '0', |
|
| 1187 | - 'max' => '100', |
|
| 1188 | - ), |
|
| 1189 | - 'desc_tip' => true, |
|
| 1190 | - 'group' => __( "Typography" ) |
|
| 1191 | - ); |
|
| 1179 | + $defaults = array( |
|
| 1180 | + 'type' => 'number', |
|
| 1181 | + 'title' => __( 'Font size (rem)' ), |
|
| 1182 | + 'default' => '', |
|
| 1183 | + 'placeholder' => '1.25', |
|
| 1184 | + 'custom_attributes' => array( |
|
| 1185 | + 'step' => '0.1', |
|
| 1186 | + 'min' => '0', |
|
| 1187 | + 'max' => '100', |
|
| 1188 | + ), |
|
| 1189 | + 'desc_tip' => true, |
|
| 1190 | + 'group' => __( "Typography" ) |
|
| 1191 | + ); |
|
| 1192 | 1192 | |
| 1193 | - if ( $parent_type ) { |
|
| 1194 | - $defaults['element_require'] = '[%' . $parent_type . '%]=="custom"'; |
|
| 1195 | - } |
|
| 1193 | + if ( $parent_type ) { |
|
| 1194 | + $defaults['element_require'] = '[%' . $parent_type . '%]=="custom"'; |
|
| 1195 | + } |
|
| 1196 | 1196 | |
| 1197 | 1197 | |
| 1198 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1198 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1199 | 1199 | |
| 1200 | 1200 | |
| 1201 | - return $input; |
|
| 1201 | + return $input; |
|
| 1202 | 1202 | } |
| 1203 | 1203 | |
| 1204 | 1204 | /** |
@@ -1212,19 +1212,19 @@ discard block |
||
| 1212 | 1212 | function sd_get_font_size_input_group( $type = 'font_size', $overwrite = array(), $overwrite_custom = array() ) { |
| 1213 | 1213 | |
| 1214 | 1214 | |
| 1215 | - $inputs = array(); |
|
| 1215 | + $inputs = array(); |
|
| 1216 | 1216 | |
| 1217 | - if ( $overwrite !== false ) { |
|
| 1218 | - $inputs[ $type ] = sd_get_font_size_input( $type, $overwrite, true ); |
|
| 1219 | - } |
|
| 1217 | + if ( $overwrite !== false ) { |
|
| 1218 | + $inputs[ $type ] = sd_get_font_size_input( $type, $overwrite, true ); |
|
| 1219 | + } |
|
| 1220 | 1220 | |
| 1221 | - if ( $overwrite_custom !== false ) { |
|
| 1222 | - $custom = $type . "_custom"; |
|
| 1223 | - $inputs[ $custom ] = sd_get_font_custom_size_input( $custom, $overwrite_custom, $type ); |
|
| 1224 | - } |
|
| 1221 | + if ( $overwrite_custom !== false ) { |
|
| 1222 | + $custom = $type . "_custom"; |
|
| 1223 | + $inputs[ $custom ] = sd_get_font_custom_size_input( $custom, $overwrite_custom, $type ); |
|
| 1224 | + } |
|
| 1225 | 1225 | |
| 1226 | 1226 | |
| 1227 | - return $inputs; |
|
| 1227 | + return $inputs; |
|
| 1228 | 1228 | } |
| 1229 | 1229 | |
| 1230 | 1230 | /** |
@@ -1238,35 +1238,35 @@ discard block |
||
| 1238 | 1238 | function sd_get_font_weight_input( $type = 'font_weight', $overwrite = array() ) { |
| 1239 | 1239 | |
| 1240 | 1240 | |
| 1241 | - $options = array( |
|
| 1242 | - "" => __( 'Inherit' ), |
|
| 1243 | - "font-weight-bold" => 'bold', |
|
| 1244 | - "font-weight-bolder" => 'bolder', |
|
| 1245 | - "font-weight-normal" => 'normal', |
|
| 1246 | - "font-weight-light" => 'light', |
|
| 1247 | - "font-weight-lighter" => 'lighter', |
|
| 1248 | - "font-italic" => 'italic', |
|
| 1249 | - "font-weight-bold font-italic" => 'bold italic', |
|
| 1250 | - "font-weight-bolder font-italic" => 'bolder italic', |
|
| 1251 | - "font-weight-normal font-italic" => 'normal italic', |
|
| 1252 | - "font-weight-light font-italic" => 'light italic', |
|
| 1253 | - "font-weight-lighter font-italic" => 'lighter italic', |
|
| 1254 | - ); |
|
| 1241 | + $options = array( |
|
| 1242 | + "" => __( 'Inherit' ), |
|
| 1243 | + "font-weight-bold" => 'bold', |
|
| 1244 | + "font-weight-bolder" => 'bolder', |
|
| 1245 | + "font-weight-normal" => 'normal', |
|
| 1246 | + "font-weight-light" => 'light', |
|
| 1247 | + "font-weight-lighter" => 'lighter', |
|
| 1248 | + "font-italic" => 'italic', |
|
| 1249 | + "font-weight-bold font-italic" => 'bold italic', |
|
| 1250 | + "font-weight-bolder font-italic" => 'bolder italic', |
|
| 1251 | + "font-weight-normal font-italic" => 'normal italic', |
|
| 1252 | + "font-weight-light font-italic" => 'light italic', |
|
| 1253 | + "font-weight-lighter font-italic" => 'lighter italic', |
|
| 1254 | + ); |
|
| 1255 | 1255 | |
| 1256 | - $defaults = array( |
|
| 1257 | - 'type' => 'select', |
|
| 1258 | - 'title' => __( 'Appearance' ), |
|
| 1259 | - 'options' => $options, |
|
| 1260 | - 'default' => '', |
|
| 1261 | - 'desc_tip' => true, |
|
| 1262 | - 'group' => __( "Typography" ) |
|
| 1263 | - ); |
|
| 1256 | + $defaults = array( |
|
| 1257 | + 'type' => 'select', |
|
| 1258 | + 'title' => __( 'Appearance' ), |
|
| 1259 | + 'options' => $options, |
|
| 1260 | + 'default' => '', |
|
| 1261 | + 'desc_tip' => true, |
|
| 1262 | + 'group' => __( "Typography" ) |
|
| 1263 | + ); |
|
| 1264 | 1264 | |
| 1265 | 1265 | |
| 1266 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1266 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1267 | 1267 | |
| 1268 | 1268 | |
| 1269 | - return $input; |
|
| 1269 | + return $input; |
|
| 1270 | 1270 | } |
| 1271 | 1271 | |
| 1272 | 1272 | /** |
@@ -1280,27 +1280,27 @@ discard block |
||
| 1280 | 1280 | function sd_get_font_case_input( $type = 'font_weight', $overwrite = array() ) { |
| 1281 | 1281 | |
| 1282 | 1282 | |
| 1283 | - $options = array( |
|
| 1284 | - "" => __( 'Default' ), |
|
| 1285 | - "text-lowercase" => __( 'lowercase' ), |
|
| 1286 | - "text-uppercase" => __( 'UPPERCASE' ), |
|
| 1287 | - "text-capitalize" => __( 'Capitalize' ), |
|
| 1288 | - ); |
|
| 1283 | + $options = array( |
|
| 1284 | + "" => __( 'Default' ), |
|
| 1285 | + "text-lowercase" => __( 'lowercase' ), |
|
| 1286 | + "text-uppercase" => __( 'UPPERCASE' ), |
|
| 1287 | + "text-capitalize" => __( 'Capitalize' ), |
|
| 1288 | + ); |
|
| 1289 | 1289 | |
| 1290 | - $defaults = array( |
|
| 1291 | - 'type' => 'select', |
|
| 1292 | - 'title' => __( 'Letter case' ), |
|
| 1293 | - 'options' => $options, |
|
| 1294 | - 'default' => '', |
|
| 1295 | - 'desc_tip' => true, |
|
| 1296 | - 'group' => __( "Typography" ) |
|
| 1297 | - ); |
|
| 1290 | + $defaults = array( |
|
| 1291 | + 'type' => 'select', |
|
| 1292 | + 'title' => __( 'Letter case' ), |
|
| 1293 | + 'options' => $options, |
|
| 1294 | + 'default' => '', |
|
| 1295 | + 'desc_tip' => true, |
|
| 1296 | + 'group' => __( "Typography" ) |
|
| 1297 | + ); |
|
| 1298 | 1298 | |
| 1299 | 1299 | |
| 1300 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1300 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1301 | 1301 | |
| 1302 | 1302 | |
| 1303 | - return $input; |
|
| 1303 | + return $input; |
|
| 1304 | 1304 | } |
| 1305 | 1305 | |
| 1306 | 1306 | /** |
@@ -1315,24 +1315,24 @@ discard block |
||
| 1315 | 1315 | function sd_get_font_italic_input( $type = 'font_italic', $overwrite = array() ) { |
| 1316 | 1316 | |
| 1317 | 1317 | |
| 1318 | - $options = array( |
|
| 1319 | - "" => __( 'No' ), |
|
| 1320 | - "font-italic" => __( 'Yes' ) |
|
| 1321 | - ); |
|
| 1318 | + $options = array( |
|
| 1319 | + "" => __( 'No' ), |
|
| 1320 | + "font-italic" => __( 'Yes' ) |
|
| 1321 | + ); |
|
| 1322 | 1322 | |
| 1323 | - $defaults = array( |
|
| 1324 | - 'type' => 'select', |
|
| 1325 | - 'title' => __( 'Font italic' ), |
|
| 1326 | - 'options' => $options, |
|
| 1327 | - 'default' => '', |
|
| 1328 | - 'desc_tip' => true, |
|
| 1329 | - 'group' => __( "Typography" ) |
|
| 1330 | - ); |
|
| 1323 | + $defaults = array( |
|
| 1324 | + 'type' => 'select', |
|
| 1325 | + 'title' => __( 'Font italic' ), |
|
| 1326 | + 'options' => $options, |
|
| 1327 | + 'default' => '', |
|
| 1328 | + 'desc_tip' => true, |
|
| 1329 | + 'group' => __( "Typography" ) |
|
| 1330 | + ); |
|
| 1331 | 1331 | |
| 1332 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1332 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1333 | 1333 | |
| 1334 | 1334 | |
| 1335 | - return $input; |
|
| 1335 | + return $input; |
|
| 1336 | 1336 | } |
| 1337 | 1337 | |
| 1338 | 1338 | /** |
@@ -1346,19 +1346,19 @@ discard block |
||
| 1346 | 1346 | function sd_get_anchor_input( $type = 'anchor', $overwrite = array() ) { |
| 1347 | 1347 | |
| 1348 | 1348 | |
| 1349 | - $defaults = array( |
|
| 1350 | - 'type' => 'text', |
|
| 1351 | - 'title' => __( 'HTML anchor' ), |
|
| 1352 | - 'desc' => __( 'Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.' ), |
|
| 1353 | - 'default' => '', |
|
| 1354 | - 'desc_tip' => true, |
|
| 1355 | - 'group' => __( "Advanced" ) |
|
| 1356 | - ); |
|
| 1349 | + $defaults = array( |
|
| 1350 | + 'type' => 'text', |
|
| 1351 | + 'title' => __( 'HTML anchor' ), |
|
| 1352 | + 'desc' => __( 'Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.' ), |
|
| 1353 | + 'default' => '', |
|
| 1354 | + 'desc_tip' => true, |
|
| 1355 | + 'group' => __( "Advanced" ) |
|
| 1356 | + ); |
|
| 1357 | 1357 | |
| 1358 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1358 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1359 | 1359 | |
| 1360 | 1360 | |
| 1361 | - return $input; |
|
| 1361 | + return $input; |
|
| 1362 | 1362 | } |
| 1363 | 1363 | |
| 1364 | 1364 | /** |
@@ -1371,19 +1371,19 @@ discard block |
||
| 1371 | 1371 | */ |
| 1372 | 1372 | function sd_get_class_input( $type = 'css_class', $overwrite = array() ) { |
| 1373 | 1373 | |
| 1374 | - $defaults = array( |
|
| 1375 | - 'type' => 'text', |
|
| 1376 | - 'title' => __( 'Additional CSS class(es)' ), |
|
| 1377 | - 'desc' => __( 'Separate multiple classes with spaces.' ), |
|
| 1378 | - 'default' => '', |
|
| 1379 | - 'desc_tip' => true, |
|
| 1380 | - 'group' => __( "Advanced" ) |
|
| 1381 | - ); |
|
| 1374 | + $defaults = array( |
|
| 1375 | + 'type' => 'text', |
|
| 1376 | + 'title' => __( 'Additional CSS class(es)' ), |
|
| 1377 | + 'desc' => __( 'Separate multiple classes with spaces.' ), |
|
| 1378 | + 'default' => '', |
|
| 1379 | + 'desc_tip' => true, |
|
| 1380 | + 'group' => __( "Advanced" ) |
|
| 1381 | + ); |
|
| 1382 | 1382 | |
| 1383 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1383 | + $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1384 | 1384 | |
| 1385 | 1385 | |
| 1386 | - return $input; |
|
| 1386 | + return $input; |
|
| 1387 | 1387 | } |
| 1388 | 1388 | |
| 1389 | 1389 | |
@@ -1397,318 +1397,318 @@ discard block |
||
| 1397 | 1397 | */ |
| 1398 | 1398 | function sd_build_aui_class( $args ) { |
| 1399 | 1399 | |
| 1400 | - $classes = array(); |
|
| 1401 | - |
|
| 1402 | - // margins. |
|
| 1403 | - if ( isset( $args['mt'] ) && $args['mt'] !== '' ) { |
|
| 1404 | - $classes[] = "mt-" . sanitize_html_class( $args['mt'] ); |
|
| 1405 | - $mt = $args['mt']; |
|
| 1406 | - } else { |
|
| 1407 | - $mt = null; |
|
| 1408 | - } |
|
| 1409 | - if ( isset( $args['mr'] ) && $args['mr'] !== '' ) { |
|
| 1410 | - $classes[] = "mr-" . sanitize_html_class( $args['mr'] ); |
|
| 1411 | - $mr = $args['mr']; |
|
| 1412 | - } else { |
|
| 1413 | - $mr = null; |
|
| 1414 | - } |
|
| 1415 | - if ( isset( $args['mb'] ) && $args['mb'] !== '' ) { |
|
| 1416 | - $classes[] = "mb-" . sanitize_html_class( $args['mb'] ); |
|
| 1417 | - $mb = $args['mb']; |
|
| 1418 | - } else { |
|
| 1419 | - $mb = null; |
|
| 1420 | - } |
|
| 1421 | - if ( isset( $args['ml'] ) && $args['ml'] !== '' ) { |
|
| 1422 | - $classes[] = "ml-" . sanitize_html_class( $args['ml'] ); |
|
| 1423 | - $ml = $args['ml']; |
|
| 1424 | - } else { |
|
| 1425 | - $ml = null; |
|
| 1426 | - } |
|
| 1427 | - |
|
| 1428 | - // margins tablet. |
|
| 1429 | - if ( isset( $args['mt_md'] ) && $args['mt_md'] !== '' ) { |
|
| 1430 | - $classes[] = "mt-md-" . sanitize_html_class( $args['mt_md'] ); |
|
| 1431 | - $mt_md = $args['mt_md']; |
|
| 1432 | - } else { |
|
| 1433 | - $mt_md = null; |
|
| 1434 | - } |
|
| 1435 | - if ( isset( $args['mr_md'] ) && $args['mr_md'] !== '' ) { |
|
| 1436 | - $classes[] = "mr-md-" . sanitize_html_class( $args['mr_md'] ); |
|
| 1437 | - $mt_md = $args['mr_md']; |
|
| 1438 | - } else { |
|
| 1439 | - $mr_md = null; |
|
| 1440 | - } |
|
| 1441 | - if ( isset( $args['mb_md'] ) && $args['mb_md'] !== '' ) { |
|
| 1442 | - $classes[] = "mb-md-" . sanitize_html_class( $args['mb_md'] ); |
|
| 1443 | - $mt_md = $args['mb_md']; |
|
| 1444 | - } else { |
|
| 1445 | - $mb_md = null; |
|
| 1446 | - } |
|
| 1447 | - if ( isset( $args['ml_md'] ) && $args['ml_md'] !== '' ) { |
|
| 1448 | - $classes[] = "ml-md-" . sanitize_html_class( $args['ml_md'] ); |
|
| 1449 | - $mt_md = $args['ml_md']; |
|
| 1450 | - } else { |
|
| 1451 | - $ml_md = null; |
|
| 1452 | - } |
|
| 1453 | - |
|
| 1454 | - // margins desktop. |
|
| 1455 | - if ( isset( $args['mt_lg'] ) && $args['mt_lg'] !== '' ) { |
|
| 1456 | - if ( $mt == null && $mt_md == null ) { |
|
| 1457 | - $classes[] = "mt-" . sanitize_html_class( $args['mt_lg'] ); |
|
| 1458 | - } else { |
|
| 1459 | - $classes[] = "mt-lg-" . sanitize_html_class( $args['mt_lg'] ); |
|
| 1460 | - } |
|
| 1461 | - } |
|
| 1462 | - if ( isset( $args['mr_lg'] ) && $args['mr_lg'] !== '' ) { |
|
| 1463 | - if ( $mr == null && $mr_md == null ) { |
|
| 1464 | - $classes[] = "mr-" . sanitize_html_class( $args['mr_lg'] ); |
|
| 1465 | - } else { |
|
| 1466 | - $classes[] = "mr-lg-" . sanitize_html_class( $args['mr_lg'] ); |
|
| 1467 | - } |
|
| 1468 | - } |
|
| 1469 | - if ( isset( $args['mb_lg'] ) && $args['mb_lg'] !== '' ) { |
|
| 1470 | - if ( $mb == null && $mb_md == null ) { |
|
| 1471 | - $classes[] = "mb-" . sanitize_html_class( $args['mb_lg'] ); |
|
| 1472 | - } else { |
|
| 1473 | - $classes[] = "mb-lg-" . sanitize_html_class( $args['mb_lg'] ); |
|
| 1474 | - } |
|
| 1475 | - } |
|
| 1476 | - if ( isset( $args['ml_lg'] ) && $args['ml_lg'] !== '' ) { |
|
| 1477 | - if ( $ml == null && $ml_md == null ) { |
|
| 1478 | - $classes[] = "ml-" . sanitize_html_class( $args['ml_lg'] ); |
|
| 1479 | - } else { |
|
| 1480 | - $classes[] = "ml-lg-" . sanitize_html_class( $args['ml_lg'] ); |
|
| 1481 | - } |
|
| 1482 | - } |
|
| 1483 | - |
|
| 1484 | - |
|
| 1485 | - // padding. |
|
| 1486 | - if ( isset( $args['pt'] ) && $args['pt'] !== '' ) { |
|
| 1487 | - $classes[] = "pt-" . sanitize_html_class( $args['pt'] ); |
|
| 1488 | - $pt = $args['pt']; |
|
| 1489 | - } else { |
|
| 1490 | - $pt = null; |
|
| 1491 | - } |
|
| 1492 | - if ( isset( $args['pr'] ) && $args['pr'] !== '' ) { |
|
| 1493 | - $classes[] = "pr-" . sanitize_html_class( $args['pr'] ); |
|
| 1494 | - $pr = $args['pr']; |
|
| 1495 | - } else { |
|
| 1496 | - $pr = null; |
|
| 1497 | - } |
|
| 1498 | - if ( isset( $args['pb'] ) && $args['pb'] !== '' ) { |
|
| 1499 | - $classes[] = "pb-" . sanitize_html_class( $args['pb'] ); |
|
| 1500 | - $pb = $args['pb']; |
|
| 1501 | - } else { |
|
| 1502 | - $pb = null; |
|
| 1503 | - } |
|
| 1504 | - if ( isset( $args['pl'] ) && $args['pl'] !== '' ) { |
|
| 1505 | - $classes[] = "pl-" . sanitize_html_class( $args['pl'] ); |
|
| 1506 | - $pl = $args['pl']; |
|
| 1507 | - } else { |
|
| 1508 | - $pl = null; |
|
| 1509 | - } |
|
| 1510 | - |
|
| 1511 | - // padding tablet. |
|
| 1512 | - if ( isset( $args['pt_md'] ) && $args['pt_md'] !== '' ) { |
|
| 1513 | - $classes[] = "pt-md-" . sanitize_html_class( $args['pt_md'] ); |
|
| 1514 | - $pt_md = $args['pt_md']; |
|
| 1515 | - } else { |
|
| 1516 | - $pt_md = null; |
|
| 1517 | - } |
|
| 1518 | - if ( isset( $args['pr_md'] ) && $args['pr_md'] !== '' ) { |
|
| 1519 | - $classes[] = "pr-md-" . sanitize_html_class( $args['pr_md'] ); |
|
| 1520 | - $pt_md = $args['pr_md']; |
|
| 1521 | - } else { |
|
| 1522 | - $pr_md = null; |
|
| 1523 | - } |
|
| 1524 | - if ( isset( $args['pb_md'] ) && $args['pb_md'] !== '' ) { |
|
| 1525 | - $classes[] = "pb-md-" . sanitize_html_class( $args['pb_md'] ); |
|
| 1526 | - $pt_md = $args['pb_md']; |
|
| 1527 | - } else { |
|
| 1528 | - $pb_md = null; |
|
| 1529 | - } |
|
| 1530 | - if ( isset( $args['pl_md'] ) && $args['pl_md'] !== '' ) { |
|
| 1531 | - $classes[] = "pl-md-" . sanitize_html_class( $args['pl_md'] ); |
|
| 1532 | - $pt_md = $args['pl_md']; |
|
| 1533 | - } else { |
|
| 1534 | - $pl_md = null; |
|
| 1535 | - } |
|
| 1536 | - |
|
| 1537 | - // padding desktop. |
|
| 1538 | - if ( isset( $args['pt_lg'] ) && $args['pt_lg'] !== '' ) { |
|
| 1539 | - if ( $pt == null && $pt_md == null ) { |
|
| 1540 | - $classes[] = "pt-" . sanitize_html_class( $args['pt_lg'] ); |
|
| 1541 | - } else { |
|
| 1542 | - $classes[] = "pt-lg-" . sanitize_html_class( $args['pt_lg'] ); |
|
| 1543 | - } |
|
| 1544 | - } |
|
| 1545 | - if ( isset( $args['pr_lg'] ) && $args['pr_lg'] !== '' ) { |
|
| 1546 | - if ( $pr == null && $pr_md == null ) { |
|
| 1547 | - $classes[] = "pr-" . sanitize_html_class( $args['pr_lg'] ); |
|
| 1548 | - } else { |
|
| 1549 | - $classes[] = "pr-lg-" . sanitize_html_class( $args['pr_lg'] ); |
|
| 1550 | - } |
|
| 1551 | - } |
|
| 1552 | - if ( isset( $args['pb_lg'] ) && $args['pb_lg'] !== '' ) { |
|
| 1553 | - if ( $pb == null && $pb_md == null ) { |
|
| 1554 | - $classes[] = "pb-" . sanitize_html_class( $args['pb_lg'] ); |
|
| 1555 | - } else { |
|
| 1556 | - $classes[] = "pb-lg-" . sanitize_html_class( $args['pb_lg'] ); |
|
| 1557 | - } |
|
| 1558 | - } |
|
| 1559 | - if ( isset( $args['pl_lg'] ) && $args['pl_lg'] !== '' ) { |
|
| 1560 | - if ( $pl == null && $pl_md == null ) { |
|
| 1561 | - $classes[] = "pl-" . sanitize_html_class( $args['pl_lg'] ); |
|
| 1562 | - } else { |
|
| 1563 | - $classes[] = "pl-lg-" . sanitize_html_class( $args['pl_lg'] ); |
|
| 1564 | - } |
|
| 1565 | - } |
|
| 1566 | - |
|
| 1567 | - // row cols, mobile, tablet, desktop |
|
| 1568 | - if ( ! empty( $args['row_cols'] ) && $args['row_cols'] !== '' ) { |
|
| 1569 | - $classes[] = sanitize_html_class( "row-cols-" . $args['row_cols'] ); |
|
| 1570 | - $row_cols = $args['row_cols']; |
|
| 1571 | - } else { |
|
| 1572 | - $row_cols = null; |
|
| 1573 | - } |
|
| 1574 | - if ( ! empty( $args['row_cols_md'] ) && $args['row_cols_md'] !== '' ) { |
|
| 1575 | - $classes[] = sanitize_html_class( "row-cols-md-" . $args['row_cols_md'] ); |
|
| 1576 | - $row_cols_md = $args['row_cols_md']; |
|
| 1577 | - } else { |
|
| 1578 | - $row_cols_md = null; |
|
| 1579 | - } |
|
| 1580 | - if ( ! empty( $args['row_cols_lg'] ) && $args['row_cols_lg'] !== '' ) { |
|
| 1581 | - if ( $row_cols == null && $row_cols_md == null ) { |
|
| 1582 | - $classes[] = sanitize_html_class( "row-cols-" . $args['row_cols_lg'] ); |
|
| 1583 | - } else { |
|
| 1584 | - $classes[] = sanitize_html_class( "row-cols-lg-" . $args['row_cols_lg'] ); |
|
| 1585 | - } |
|
| 1586 | - } |
|
| 1587 | - |
|
| 1588 | - // columns , mobile, tablet, desktop |
|
| 1589 | - if ( ! empty( $args['col'] ) && $args['col'] !== '' ) { |
|
| 1590 | - $classes[] = sanitize_html_class( "col-" . $args['col'] ); |
|
| 1591 | - $col = $args['col']; |
|
| 1592 | - } else { |
|
| 1593 | - $col = null; |
|
| 1594 | - } |
|
| 1595 | - if ( ! empty( $args['col_md'] ) && $args['col_md'] !== '' ) { |
|
| 1596 | - $classes[] = sanitize_html_class( "col-md-" . $args['col_md'] ); |
|
| 1597 | - $col_md = $args['col_md']; |
|
| 1598 | - } else { |
|
| 1599 | - $col_md = null; |
|
| 1600 | - } |
|
| 1601 | - if ( ! empty( $args['col_lg'] ) && $args['col_lg'] !== '' ) { |
|
| 1602 | - if ( $col == null && $col_md == null ) { |
|
| 1603 | - $classes[] = sanitize_html_class( "col-" . $args['col_lg'] ); |
|
| 1604 | - } else { |
|
| 1605 | - $classes[] = sanitize_html_class( "col-lg-" . $args['col_lg'] ); |
|
| 1606 | - } |
|
| 1607 | - } |
|
| 1608 | - |
|
| 1609 | - |
|
| 1610 | - // border |
|
| 1611 | - if ( ! empty( $args['border'] ) && ( $args['border'] == 'none' || $args['border'] === '0' ) ) { |
|
| 1612 | - $classes[] = "border-0"; |
|
| 1613 | - } elseif ( ! empty( $args['border'] ) ) { |
|
| 1614 | - $classes[] = "border border-" . sanitize_html_class( $args['border'] ); |
|
| 1615 | - } |
|
| 1616 | - |
|
| 1617 | - // border radius type |
|
| 1618 | - if ( ! empty( $args['rounded'] ) ) { |
|
| 1619 | - $classes[] = sanitize_html_class( $args['rounded'] ); |
|
| 1620 | - } |
|
| 1621 | - |
|
| 1622 | - // border radius size |
|
| 1623 | - if ( ! empty( $args['rounded_size'] ) ) { |
|
| 1624 | - $classes[] = "rounded-" . sanitize_html_class( $args['rounded_size'] ); |
|
| 1625 | - // if we set a size then we need to remove "rounded" if set |
|
| 1626 | - if ( ( $key = array_search( "rounded", $classes ) ) !== false ) { |
|
| 1627 | - unset( $classes[ $key ] ); |
|
| 1628 | - } |
|
| 1629 | - } |
|
| 1630 | - |
|
| 1631 | - // shadow |
|
| 1632 | - //if ( !empty( $args['shadow'] ) ) { $classes[] = sanitize_html_class($args['shadow']); } |
|
| 1633 | - |
|
| 1634 | - // background |
|
| 1635 | - if ( ! empty( $args['bg'] ) ) { |
|
| 1636 | - $classes[] = "bg-" . sanitize_html_class( $args['bg'] ); |
|
| 1637 | - } |
|
| 1638 | - |
|
| 1639 | - // text_color |
|
| 1640 | - if ( ! empty( $args['text_color'] ) ) { |
|
| 1641 | - $classes[] = "text-" . sanitize_html_class( $args['text_color'] ); |
|
| 1642 | - } |
|
| 1643 | - |
|
| 1644 | - // text_align |
|
| 1645 | - if ( ! empty( $args['text_justify'] ) ) { |
|
| 1646 | - $classes[] = 'text-justify'; |
|
| 1647 | - } else { |
|
| 1648 | - if ( ! empty( $args['text_align'] ) ) { |
|
| 1649 | - $classes[] = sanitize_html_class( $args['text_align'] ); |
|
| 1650 | - $text_align = $args['text_align']; |
|
| 1651 | - } else { |
|
| 1652 | - $text_align = null; |
|
| 1653 | - } |
|
| 1654 | - if ( ! empty( $args['text_align_md'] ) && $args['text_align_md'] !== '' ) { |
|
| 1655 | - $classes[] = sanitize_html_class( $args['text_align_md'] ); |
|
| 1656 | - $text_align_md = $args['text_align_md']; |
|
| 1657 | - } else { |
|
| 1658 | - $text_align_md = null; |
|
| 1659 | - } |
|
| 1660 | - if ( ! empty( $args['text_align_lg'] ) && $args['text_align_lg'] !== '' ) { |
|
| 1661 | - if ( $text_align == null && $text_align_md == null ) { |
|
| 1662 | - $classes[] = sanitize_html_class( str_replace( "-lg", "", $args['text_align_lg'] ) ); |
|
| 1663 | - } else { |
|
| 1664 | - $classes[] = sanitize_html_class( $args['text_align_lg'] ); |
|
| 1665 | - } |
|
| 1666 | - } |
|
| 1667 | - } |
|
| 1668 | - |
|
| 1669 | - // display |
|
| 1670 | - if ( ! empty( $args['display'] ) ) { |
|
| 1671 | - $classes[] = sanitize_html_class( $args['display'] ); |
|
| 1672 | - $display = $args['display']; |
|
| 1673 | - } else { |
|
| 1674 | - $display = null; |
|
| 1675 | - } |
|
| 1676 | - if ( ! empty( $args['display_md'] ) && $args['display_md'] !== '' ) { |
|
| 1677 | - $classes[] = sanitize_html_class( $args['display_md'] ); |
|
| 1678 | - $display_md = $args['display_md']; |
|
| 1679 | - } else { |
|
| 1680 | - $display_md = null; |
|
| 1681 | - } |
|
| 1682 | - if ( ! empty( $args['display_lg'] ) && $args['display_lg'] !== '' ) { |
|
| 1683 | - if ( $display == null && $display_md == null ) { |
|
| 1684 | - $classes[] = sanitize_html_class( str_replace( "-lg", "", $args['display_lg'] ) ); |
|
| 1685 | - } else { |
|
| 1686 | - $classes[] = sanitize_html_class( $args['display_lg'] ); |
|
| 1687 | - } |
|
| 1688 | - } |
|
| 1689 | - |
|
| 1690 | - |
|
| 1691 | - // bgtus - background transparent until scroll |
|
| 1692 | - if ( ! empty( $args['bgtus'] ) ) { |
|
| 1693 | - $classes[] = sanitize_html_class( "bg-transparent-until-scroll" ); |
|
| 1694 | - } |
|
| 1695 | - |
|
| 1696 | - |
|
| 1697 | - // build classes from build keys |
|
| 1698 | - $build_keys = sd_get_class_build_keys(); |
|
| 1699 | - if ( ! empty( $build_keys ) ) { |
|
| 1700 | - foreach ( $build_keys as $key ) { |
|
| 1701 | - if ( $key == 'font_size' && ! empty( $args[ $key ] ) && $args[ $key ] == 'custom' ) { |
|
| 1702 | - continue; |
|
| 1703 | - } |
|
| 1704 | - if ( ! empty( $args[ $key ] ) ) { |
|
| 1705 | - $classes[] = sd_sanitize_html_classes( $args[ $key ] ); |
|
| 1706 | - } |
|
| 1707 | - } |
|
| 1708 | - } |
|
| 1709 | - |
|
| 1710 | - |
|
| 1711 | - return implode( " ", $classes ); |
|
| 1400 | + $classes = array(); |
|
| 1401 | + |
|
| 1402 | + // margins. |
|
| 1403 | + if ( isset( $args['mt'] ) && $args['mt'] !== '' ) { |
|
| 1404 | + $classes[] = "mt-" . sanitize_html_class( $args['mt'] ); |
|
| 1405 | + $mt = $args['mt']; |
|
| 1406 | + } else { |
|
| 1407 | + $mt = null; |
|
| 1408 | + } |
|
| 1409 | + if ( isset( $args['mr'] ) && $args['mr'] !== '' ) { |
|
| 1410 | + $classes[] = "mr-" . sanitize_html_class( $args['mr'] ); |
|
| 1411 | + $mr = $args['mr']; |
|
| 1412 | + } else { |
|
| 1413 | + $mr = null; |
|
| 1414 | + } |
|
| 1415 | + if ( isset( $args['mb'] ) && $args['mb'] !== '' ) { |
|
| 1416 | + $classes[] = "mb-" . sanitize_html_class( $args['mb'] ); |
|
| 1417 | + $mb = $args['mb']; |
|
| 1418 | + } else { |
|
| 1419 | + $mb = null; |
|
| 1420 | + } |
|
| 1421 | + if ( isset( $args['ml'] ) && $args['ml'] !== '' ) { |
|
| 1422 | + $classes[] = "ml-" . sanitize_html_class( $args['ml'] ); |
|
| 1423 | + $ml = $args['ml']; |
|
| 1424 | + } else { |
|
| 1425 | + $ml = null; |
|
| 1426 | + } |
|
| 1427 | + |
|
| 1428 | + // margins tablet. |
|
| 1429 | + if ( isset( $args['mt_md'] ) && $args['mt_md'] !== '' ) { |
|
| 1430 | + $classes[] = "mt-md-" . sanitize_html_class( $args['mt_md'] ); |
|
| 1431 | + $mt_md = $args['mt_md']; |
|
| 1432 | + } else { |
|
| 1433 | + $mt_md = null; |
|
| 1434 | + } |
|
| 1435 | + if ( isset( $args['mr_md'] ) && $args['mr_md'] !== '' ) { |
|
| 1436 | + $classes[] = "mr-md-" . sanitize_html_class( $args['mr_md'] ); |
|
| 1437 | + $mt_md = $args['mr_md']; |
|
| 1438 | + } else { |
|
| 1439 | + $mr_md = null; |
|
| 1440 | + } |
|
| 1441 | + if ( isset( $args['mb_md'] ) && $args['mb_md'] !== '' ) { |
|
| 1442 | + $classes[] = "mb-md-" . sanitize_html_class( $args['mb_md'] ); |
|
| 1443 | + $mt_md = $args['mb_md']; |
|
| 1444 | + } else { |
|
| 1445 | + $mb_md = null; |
|
| 1446 | + } |
|
| 1447 | + if ( isset( $args['ml_md'] ) && $args['ml_md'] !== '' ) { |
|
| 1448 | + $classes[] = "ml-md-" . sanitize_html_class( $args['ml_md'] ); |
|
| 1449 | + $mt_md = $args['ml_md']; |
|
| 1450 | + } else { |
|
| 1451 | + $ml_md = null; |
|
| 1452 | + } |
|
| 1453 | + |
|
| 1454 | + // margins desktop. |
|
| 1455 | + if ( isset( $args['mt_lg'] ) && $args['mt_lg'] !== '' ) { |
|
| 1456 | + if ( $mt == null && $mt_md == null ) { |
|
| 1457 | + $classes[] = "mt-" . sanitize_html_class( $args['mt_lg'] ); |
|
| 1458 | + } else { |
|
| 1459 | + $classes[] = "mt-lg-" . sanitize_html_class( $args['mt_lg'] ); |
|
| 1460 | + } |
|
| 1461 | + } |
|
| 1462 | + if ( isset( $args['mr_lg'] ) && $args['mr_lg'] !== '' ) { |
|
| 1463 | + if ( $mr == null && $mr_md == null ) { |
|
| 1464 | + $classes[] = "mr-" . sanitize_html_class( $args['mr_lg'] ); |
|
| 1465 | + } else { |
|
| 1466 | + $classes[] = "mr-lg-" . sanitize_html_class( $args['mr_lg'] ); |
|
| 1467 | + } |
|
| 1468 | + } |
|
| 1469 | + if ( isset( $args['mb_lg'] ) && $args['mb_lg'] !== '' ) { |
|
| 1470 | + if ( $mb == null && $mb_md == null ) { |
|
| 1471 | + $classes[] = "mb-" . sanitize_html_class( $args['mb_lg'] ); |
|
| 1472 | + } else { |
|
| 1473 | + $classes[] = "mb-lg-" . sanitize_html_class( $args['mb_lg'] ); |
|
| 1474 | + } |
|
| 1475 | + } |
|
| 1476 | + if ( isset( $args['ml_lg'] ) && $args['ml_lg'] !== '' ) { |
|
| 1477 | + if ( $ml == null && $ml_md == null ) { |
|
| 1478 | + $classes[] = "ml-" . sanitize_html_class( $args['ml_lg'] ); |
|
| 1479 | + } else { |
|
| 1480 | + $classes[] = "ml-lg-" . sanitize_html_class( $args['ml_lg'] ); |
|
| 1481 | + } |
|
| 1482 | + } |
|
| 1483 | + |
|
| 1484 | + |
|
| 1485 | + // padding. |
|
| 1486 | + if ( isset( $args['pt'] ) && $args['pt'] !== '' ) { |
|
| 1487 | + $classes[] = "pt-" . sanitize_html_class( $args['pt'] ); |
|
| 1488 | + $pt = $args['pt']; |
|
| 1489 | + } else { |
|
| 1490 | + $pt = null; |
|
| 1491 | + } |
|
| 1492 | + if ( isset( $args['pr'] ) && $args['pr'] !== '' ) { |
|
| 1493 | + $classes[] = "pr-" . sanitize_html_class( $args['pr'] ); |
|
| 1494 | + $pr = $args['pr']; |
|
| 1495 | + } else { |
|
| 1496 | + $pr = null; |
|
| 1497 | + } |
|
| 1498 | + if ( isset( $args['pb'] ) && $args['pb'] !== '' ) { |
|
| 1499 | + $classes[] = "pb-" . sanitize_html_class( $args['pb'] ); |
|
| 1500 | + $pb = $args['pb']; |
|
| 1501 | + } else { |
|
| 1502 | + $pb = null; |
|
| 1503 | + } |
|
| 1504 | + if ( isset( $args['pl'] ) && $args['pl'] !== '' ) { |
|
| 1505 | + $classes[] = "pl-" . sanitize_html_class( $args['pl'] ); |
|
| 1506 | + $pl = $args['pl']; |
|
| 1507 | + } else { |
|
| 1508 | + $pl = null; |
|
| 1509 | + } |
|
| 1510 | + |
|
| 1511 | + // padding tablet. |
|
| 1512 | + if ( isset( $args['pt_md'] ) && $args['pt_md'] !== '' ) { |
|
| 1513 | + $classes[] = "pt-md-" . sanitize_html_class( $args['pt_md'] ); |
|
| 1514 | + $pt_md = $args['pt_md']; |
|
| 1515 | + } else { |
|
| 1516 | + $pt_md = null; |
|
| 1517 | + } |
|
| 1518 | + if ( isset( $args['pr_md'] ) && $args['pr_md'] !== '' ) { |
|
| 1519 | + $classes[] = "pr-md-" . sanitize_html_class( $args['pr_md'] ); |
|
| 1520 | + $pt_md = $args['pr_md']; |
|
| 1521 | + } else { |
|
| 1522 | + $pr_md = null; |
|
| 1523 | + } |
|
| 1524 | + if ( isset( $args['pb_md'] ) && $args['pb_md'] !== '' ) { |
|
| 1525 | + $classes[] = "pb-md-" . sanitize_html_class( $args['pb_md'] ); |
|
| 1526 | + $pt_md = $args['pb_md']; |
|
| 1527 | + } else { |
|
| 1528 | + $pb_md = null; |
|
| 1529 | + } |
|
| 1530 | + if ( isset( $args['pl_md'] ) && $args['pl_md'] !== '' ) { |
|
| 1531 | + $classes[] = "pl-md-" . sanitize_html_class( $args['pl_md'] ); |
|
| 1532 | + $pt_md = $args['pl_md']; |
|
| 1533 | + } else { |
|
| 1534 | + $pl_md = null; |
|
| 1535 | + } |
|
| 1536 | + |
|
| 1537 | + // padding desktop. |
|
| 1538 | + if ( isset( $args['pt_lg'] ) && $args['pt_lg'] !== '' ) { |
|
| 1539 | + if ( $pt == null && $pt_md == null ) { |
|
| 1540 | + $classes[] = "pt-" . sanitize_html_class( $args['pt_lg'] ); |
|
| 1541 | + } else { |
|
| 1542 | + $classes[] = "pt-lg-" . sanitize_html_class( $args['pt_lg'] ); |
|
| 1543 | + } |
|
| 1544 | + } |
|
| 1545 | + if ( isset( $args['pr_lg'] ) && $args['pr_lg'] !== '' ) { |
|
| 1546 | + if ( $pr == null && $pr_md == null ) { |
|
| 1547 | + $classes[] = "pr-" . sanitize_html_class( $args['pr_lg'] ); |
|
| 1548 | + } else { |
|
| 1549 | + $classes[] = "pr-lg-" . sanitize_html_class( $args['pr_lg'] ); |
|
| 1550 | + } |
|
| 1551 | + } |
|
| 1552 | + if ( isset( $args['pb_lg'] ) && $args['pb_lg'] !== '' ) { |
|
| 1553 | + if ( $pb == null && $pb_md == null ) { |
|
| 1554 | + $classes[] = "pb-" . sanitize_html_class( $args['pb_lg'] ); |
|
| 1555 | + } else { |
|
| 1556 | + $classes[] = "pb-lg-" . sanitize_html_class( $args['pb_lg'] ); |
|
| 1557 | + } |
|
| 1558 | + } |
|
| 1559 | + if ( isset( $args['pl_lg'] ) && $args['pl_lg'] !== '' ) { |
|
| 1560 | + if ( $pl == null && $pl_md == null ) { |
|
| 1561 | + $classes[] = "pl-" . sanitize_html_class( $args['pl_lg'] ); |
|
| 1562 | + } else { |
|
| 1563 | + $classes[] = "pl-lg-" . sanitize_html_class( $args['pl_lg'] ); |
|
| 1564 | + } |
|
| 1565 | + } |
|
| 1566 | + |
|
| 1567 | + // row cols, mobile, tablet, desktop |
|
| 1568 | + if ( ! empty( $args['row_cols'] ) && $args['row_cols'] !== '' ) { |
|
| 1569 | + $classes[] = sanitize_html_class( "row-cols-" . $args['row_cols'] ); |
|
| 1570 | + $row_cols = $args['row_cols']; |
|
| 1571 | + } else { |
|
| 1572 | + $row_cols = null; |
|
| 1573 | + } |
|
| 1574 | + if ( ! empty( $args['row_cols_md'] ) && $args['row_cols_md'] !== '' ) { |
|
| 1575 | + $classes[] = sanitize_html_class( "row-cols-md-" . $args['row_cols_md'] ); |
|
| 1576 | + $row_cols_md = $args['row_cols_md']; |
|
| 1577 | + } else { |
|
| 1578 | + $row_cols_md = null; |
|
| 1579 | + } |
|
| 1580 | + if ( ! empty( $args['row_cols_lg'] ) && $args['row_cols_lg'] !== '' ) { |
|
| 1581 | + if ( $row_cols == null && $row_cols_md == null ) { |
|
| 1582 | + $classes[] = sanitize_html_class( "row-cols-" . $args['row_cols_lg'] ); |
|
| 1583 | + } else { |
|
| 1584 | + $classes[] = sanitize_html_class( "row-cols-lg-" . $args['row_cols_lg'] ); |
|
| 1585 | + } |
|
| 1586 | + } |
|
| 1587 | + |
|
| 1588 | + // columns , mobile, tablet, desktop |
|
| 1589 | + if ( ! empty( $args['col'] ) && $args['col'] !== '' ) { |
|
| 1590 | + $classes[] = sanitize_html_class( "col-" . $args['col'] ); |
|
| 1591 | + $col = $args['col']; |
|
| 1592 | + } else { |
|
| 1593 | + $col = null; |
|
| 1594 | + } |
|
| 1595 | + if ( ! empty( $args['col_md'] ) && $args['col_md'] !== '' ) { |
|
| 1596 | + $classes[] = sanitize_html_class( "col-md-" . $args['col_md'] ); |
|
| 1597 | + $col_md = $args['col_md']; |
|
| 1598 | + } else { |
|
| 1599 | + $col_md = null; |
|
| 1600 | + } |
|
| 1601 | + if ( ! empty( $args['col_lg'] ) && $args['col_lg'] !== '' ) { |
|
| 1602 | + if ( $col == null && $col_md == null ) { |
|
| 1603 | + $classes[] = sanitize_html_class( "col-" . $args['col_lg'] ); |
|
| 1604 | + } else { |
|
| 1605 | + $classes[] = sanitize_html_class( "col-lg-" . $args['col_lg'] ); |
|
| 1606 | + } |
|
| 1607 | + } |
|
| 1608 | + |
|
| 1609 | + |
|
| 1610 | + // border |
|
| 1611 | + if ( ! empty( $args['border'] ) && ( $args['border'] == 'none' || $args['border'] === '0' ) ) { |
|
| 1612 | + $classes[] = "border-0"; |
|
| 1613 | + } elseif ( ! empty( $args['border'] ) ) { |
|
| 1614 | + $classes[] = "border border-" . sanitize_html_class( $args['border'] ); |
|
| 1615 | + } |
|
| 1616 | + |
|
| 1617 | + // border radius type |
|
| 1618 | + if ( ! empty( $args['rounded'] ) ) { |
|
| 1619 | + $classes[] = sanitize_html_class( $args['rounded'] ); |
|
| 1620 | + } |
|
| 1621 | + |
|
| 1622 | + // border radius size |
|
| 1623 | + if ( ! empty( $args['rounded_size'] ) ) { |
|
| 1624 | + $classes[] = "rounded-" . sanitize_html_class( $args['rounded_size'] ); |
|
| 1625 | + // if we set a size then we need to remove "rounded" if set |
|
| 1626 | + if ( ( $key = array_search( "rounded", $classes ) ) !== false ) { |
|
| 1627 | + unset( $classes[ $key ] ); |
|
| 1628 | + } |
|
| 1629 | + } |
|
| 1630 | + |
|
| 1631 | + // shadow |
|
| 1632 | + //if ( !empty( $args['shadow'] ) ) { $classes[] = sanitize_html_class($args['shadow']); } |
|
| 1633 | + |
|
| 1634 | + // background |
|
| 1635 | + if ( ! empty( $args['bg'] ) ) { |
|
| 1636 | + $classes[] = "bg-" . sanitize_html_class( $args['bg'] ); |
|
| 1637 | + } |
|
| 1638 | + |
|
| 1639 | + // text_color |
|
| 1640 | + if ( ! empty( $args['text_color'] ) ) { |
|
| 1641 | + $classes[] = "text-" . sanitize_html_class( $args['text_color'] ); |
|
| 1642 | + } |
|
| 1643 | + |
|
| 1644 | + // text_align |
|
| 1645 | + if ( ! empty( $args['text_justify'] ) ) { |
|
| 1646 | + $classes[] = 'text-justify'; |
|
| 1647 | + } else { |
|
| 1648 | + if ( ! empty( $args['text_align'] ) ) { |
|
| 1649 | + $classes[] = sanitize_html_class( $args['text_align'] ); |
|
| 1650 | + $text_align = $args['text_align']; |
|
| 1651 | + } else { |
|
| 1652 | + $text_align = null; |
|
| 1653 | + } |
|
| 1654 | + if ( ! empty( $args['text_align_md'] ) && $args['text_align_md'] !== '' ) { |
|
| 1655 | + $classes[] = sanitize_html_class( $args['text_align_md'] ); |
|
| 1656 | + $text_align_md = $args['text_align_md']; |
|
| 1657 | + } else { |
|
| 1658 | + $text_align_md = null; |
|
| 1659 | + } |
|
| 1660 | + if ( ! empty( $args['text_align_lg'] ) && $args['text_align_lg'] !== '' ) { |
|
| 1661 | + if ( $text_align == null && $text_align_md == null ) { |
|
| 1662 | + $classes[] = sanitize_html_class( str_replace( "-lg", "", $args['text_align_lg'] ) ); |
|
| 1663 | + } else { |
|
| 1664 | + $classes[] = sanitize_html_class( $args['text_align_lg'] ); |
|
| 1665 | + } |
|
| 1666 | + } |
|
| 1667 | + } |
|
| 1668 | + |
|
| 1669 | + // display |
|
| 1670 | + if ( ! empty( $args['display'] ) ) { |
|
| 1671 | + $classes[] = sanitize_html_class( $args['display'] ); |
|
| 1672 | + $display = $args['display']; |
|
| 1673 | + } else { |
|
| 1674 | + $display = null; |
|
| 1675 | + } |
|
| 1676 | + if ( ! empty( $args['display_md'] ) && $args['display_md'] !== '' ) { |
|
| 1677 | + $classes[] = sanitize_html_class( $args['display_md'] ); |
|
| 1678 | + $display_md = $args['display_md']; |
|
| 1679 | + } else { |
|
| 1680 | + $display_md = null; |
|
| 1681 | + } |
|
| 1682 | + if ( ! empty( $args['display_lg'] ) && $args['display_lg'] !== '' ) { |
|
| 1683 | + if ( $display == null && $display_md == null ) { |
|
| 1684 | + $classes[] = sanitize_html_class( str_replace( "-lg", "", $args['display_lg'] ) ); |
|
| 1685 | + } else { |
|
| 1686 | + $classes[] = sanitize_html_class( $args['display_lg'] ); |
|
| 1687 | + } |
|
| 1688 | + } |
|
| 1689 | + |
|
| 1690 | + |
|
| 1691 | + // bgtus - background transparent until scroll |
|
| 1692 | + if ( ! empty( $args['bgtus'] ) ) { |
|
| 1693 | + $classes[] = sanitize_html_class( "bg-transparent-until-scroll" ); |
|
| 1694 | + } |
|
| 1695 | + |
|
| 1696 | + |
|
| 1697 | + // build classes from build keys |
|
| 1698 | + $build_keys = sd_get_class_build_keys(); |
|
| 1699 | + if ( ! empty( $build_keys ) ) { |
|
| 1700 | + foreach ( $build_keys as $key ) { |
|
| 1701 | + if ( $key == 'font_size' && ! empty( $args[ $key ] ) && $args[ $key ] == 'custom' ) { |
|
| 1702 | + continue; |
|
| 1703 | + } |
|
| 1704 | + if ( ! empty( $args[ $key ] ) ) { |
|
| 1705 | + $classes[] = sd_sanitize_html_classes( $args[ $key ] ); |
|
| 1706 | + } |
|
| 1707 | + } |
|
| 1708 | + } |
|
| 1709 | + |
|
| 1710 | + |
|
| 1711 | + return implode( " ", $classes ); |
|
| 1712 | 1712 | } |
| 1713 | 1713 | |
| 1714 | 1714 | /** |
@@ -1720,80 +1720,80 @@ discard block |
||
| 1720 | 1720 | */ |
| 1721 | 1721 | function sd_build_aui_styles( $args ) { |
| 1722 | 1722 | |
| 1723 | - $styles = array(); |
|
| 1724 | - |
|
| 1725 | - // background color |
|
| 1726 | - if ( ! empty( $args['bg'] ) && $args['bg'] !== '' ) { |
|
| 1727 | - if ( $args['bg'] == 'custom-color' ) { |
|
| 1728 | - $styles['background-color'] = $args['bg_color']; |
|
| 1729 | - } else if ( $args['bg'] == 'custom-gradient' ) { |
|
| 1730 | - $styles['background-image'] = $args['bg_gradient']; |
|
| 1731 | - |
|
| 1732 | - // use background on text. |
|
| 1733 | - if ( ! empty( $args['bg_on_text'] ) && $args['bg_on_text'] ) { |
|
| 1734 | - $styles['background-clip'] = "text"; |
|
| 1735 | - $styles['-webkit-background-clip'] = "text"; |
|
| 1736 | - $styles['text-fill-color'] = "transparent"; |
|
| 1737 | - $styles['-webkit-text-fill-color'] = "transparent"; |
|
| 1738 | - } |
|
| 1739 | - } |
|
| 1740 | - } |
|
| 1741 | - |
|
| 1742 | - if ( ! empty( $args['bg_image'] ) && $args['bg_image'] !== '' ) { |
|
| 1743 | - $hasImage = true; |
|
| 1744 | - if ( $styles['background-color'] !== undefined && $args['bg'] == 'custom-color' ) { |
|
| 1745 | - $styles['background-image'] = "url(" . $args['bg_image'] . ")"; |
|
| 1746 | - $styles['background-blend-mode'] = "overlay"; |
|
| 1747 | - } else if ( $styles['background-image'] !== undefined && $args['bg'] == 'custom-gradient' ) { |
|
| 1748 | - $styles['background-image'] .= ",url(" . $args['bg_image'] . ")"; |
|
| 1749 | - } else if ( ! empty( $args['bg'] ) && $args['bg'] != '' && $args['bg'] != 'transparent' ) { |
|
| 1750 | - // do nothing as we alreay have a preset |
|
| 1751 | - $hasImage = false; |
|
| 1752 | - } else { |
|
| 1753 | - $styles['background-image'] = "url(" . $args['bg_image'] . ")"; |
|
| 1754 | - } |
|
| 1755 | - |
|
| 1756 | - if ( $hasImage ) { |
|
| 1757 | - $styles['background-size'] = "cover"; |
|
| 1758 | - |
|
| 1759 | - if ( ! empty( $args['bg_image_fixed'] ) && $args['bg_image_fixed'] ) { |
|
| 1760 | - $styles['background-attachment'] = "fixed"; |
|
| 1761 | - } |
|
| 1762 | - } |
|
| 1763 | - |
|
| 1764 | - if ( $hasImage && ! empty( $args['bg_image_xy'] ) && $args['bg_image_xy'] . x . length ) { |
|
| 1765 | - $styles['background-position'] = ( $args['bg_image_xy'] . x * 100 ) . "% " . ( $args['bg_image_xy'] . y * 100 ) . "%"; |
|
| 1766 | - } |
|
| 1767 | - } |
|
| 1768 | - |
|
| 1769 | - // sticky offset top |
|
| 1770 | - if ( ! empty( $args['sticky_offset_top'] ) && $args['sticky_offset_top'] !== '' ) { |
|
| 1771 | - $styles['top'] = absint( $args['sticky_offset_top'] ); |
|
| 1772 | - } |
|
| 1773 | - |
|
| 1774 | - // sticky offset bottom |
|
| 1775 | - if ( ! empty( $args['sticky_offset_bottom'] ) && $args['sticky_offset_bottom'] !== '' ) { |
|
| 1776 | - $styles['bottom'] = absint( $args['sticky_offset_bottom'] ); |
|
| 1777 | - } |
|
| 1778 | - |
|
| 1779 | - // font size |
|
| 1780 | - if ( ! empty( $args['font_size_custom'] ) && $args['font_size_custom'] !== '' ) { |
|
| 1781 | - $styles['font-size'] = (float) $args['font_size_custom'] . "rem"; |
|
| 1782 | - } |
|
| 1783 | - |
|
| 1784 | - // font color |
|
| 1785 | - if ( ! empty( $args['text_color_custom'] ) && $args['text_color_custom'] !== '' ) { |
|
| 1786 | - $styles['color'] = esc_attr( $args['text_color_custom'] ); |
|
| 1787 | - } |
|
| 1788 | - |
|
| 1789 | - $style_string = ''; |
|
| 1790 | - if ( ! empty( $styles ) ) { |
|
| 1791 | - foreach ( $styles as $key => $val ) { |
|
| 1792 | - $style_string .= esc_attr( $key ) . ':' . esc_attr( $val ) . ';'; |
|
| 1793 | - } |
|
| 1794 | - } |
|
| 1795 | - |
|
| 1796 | - return $style_string; |
|
| 1723 | + $styles = array(); |
|
| 1724 | + |
|
| 1725 | + // background color |
|
| 1726 | + if ( ! empty( $args['bg'] ) && $args['bg'] !== '' ) { |
|
| 1727 | + if ( $args['bg'] == 'custom-color' ) { |
|
| 1728 | + $styles['background-color'] = $args['bg_color']; |
|
| 1729 | + } else if ( $args['bg'] == 'custom-gradient' ) { |
|
| 1730 | + $styles['background-image'] = $args['bg_gradient']; |
|
| 1731 | + |
|
| 1732 | + // use background on text. |
|
| 1733 | + if ( ! empty( $args['bg_on_text'] ) && $args['bg_on_text'] ) { |
|
| 1734 | + $styles['background-clip'] = "text"; |
|
| 1735 | + $styles['-webkit-background-clip'] = "text"; |
|
| 1736 | + $styles['text-fill-color'] = "transparent"; |
|
| 1737 | + $styles['-webkit-text-fill-color'] = "transparent"; |
|
| 1738 | + } |
|
| 1739 | + } |
|
| 1740 | + } |
|
| 1741 | + |
|
| 1742 | + if ( ! empty( $args['bg_image'] ) && $args['bg_image'] !== '' ) { |
|
| 1743 | + $hasImage = true; |
|
| 1744 | + if ( $styles['background-color'] !== undefined && $args['bg'] == 'custom-color' ) { |
|
| 1745 | + $styles['background-image'] = "url(" . $args['bg_image'] . ")"; |
|
| 1746 | + $styles['background-blend-mode'] = "overlay"; |
|
| 1747 | + } else if ( $styles['background-image'] !== undefined && $args['bg'] == 'custom-gradient' ) { |
|
| 1748 | + $styles['background-image'] .= ",url(" . $args['bg_image'] . ")"; |
|
| 1749 | + } else if ( ! empty( $args['bg'] ) && $args['bg'] != '' && $args['bg'] != 'transparent' ) { |
|
| 1750 | + // do nothing as we alreay have a preset |
|
| 1751 | + $hasImage = false; |
|
| 1752 | + } else { |
|
| 1753 | + $styles['background-image'] = "url(" . $args['bg_image'] . ")"; |
|
| 1754 | + } |
|
| 1755 | + |
|
| 1756 | + if ( $hasImage ) { |
|
| 1757 | + $styles['background-size'] = "cover"; |
|
| 1758 | + |
|
| 1759 | + if ( ! empty( $args['bg_image_fixed'] ) && $args['bg_image_fixed'] ) { |
|
| 1760 | + $styles['background-attachment'] = "fixed"; |
|
| 1761 | + } |
|
| 1762 | + } |
|
| 1763 | + |
|
| 1764 | + if ( $hasImage && ! empty( $args['bg_image_xy'] ) && $args['bg_image_xy'] . x . length ) { |
|
| 1765 | + $styles['background-position'] = ( $args['bg_image_xy'] . x * 100 ) . "% " . ( $args['bg_image_xy'] . y * 100 ) . "%"; |
|
| 1766 | + } |
|
| 1767 | + } |
|
| 1768 | + |
|
| 1769 | + // sticky offset top |
|
| 1770 | + if ( ! empty( $args['sticky_offset_top'] ) && $args['sticky_offset_top'] !== '' ) { |
|
| 1771 | + $styles['top'] = absint( $args['sticky_offset_top'] ); |
|
| 1772 | + } |
|
| 1773 | + |
|
| 1774 | + // sticky offset bottom |
|
| 1775 | + if ( ! empty( $args['sticky_offset_bottom'] ) && $args['sticky_offset_bottom'] !== '' ) { |
|
| 1776 | + $styles['bottom'] = absint( $args['sticky_offset_bottom'] ); |
|
| 1777 | + } |
|
| 1778 | + |
|
| 1779 | + // font size |
|
| 1780 | + if ( ! empty( $args['font_size_custom'] ) && $args['font_size_custom'] !== '' ) { |
|
| 1781 | + $styles['font-size'] = (float) $args['font_size_custom'] . "rem"; |
|
| 1782 | + } |
|
| 1783 | + |
|
| 1784 | + // font color |
|
| 1785 | + if ( ! empty( $args['text_color_custom'] ) && $args['text_color_custom'] !== '' ) { |
|
| 1786 | + $styles['color'] = esc_attr( $args['text_color_custom'] ); |
|
| 1787 | + } |
|
| 1788 | + |
|
| 1789 | + $style_string = ''; |
|
| 1790 | + if ( ! empty( $styles ) ) { |
|
| 1791 | + foreach ( $styles as $key => $val ) { |
|
| 1792 | + $style_string .= esc_attr( $key ) . ':' . esc_attr( $val ) . ';'; |
|
| 1793 | + } |
|
| 1794 | + } |
|
| 1795 | + |
|
| 1796 | + return $style_string; |
|
| 1797 | 1797 | |
| 1798 | 1798 | } |
| 1799 | 1799 | |
@@ -1806,19 +1806,19 @@ discard block |
||
| 1806 | 1806 | * @return string |
| 1807 | 1807 | */ |
| 1808 | 1808 | function sd_sanitize_html_classes( $classes, $sep = " " ) { |
| 1809 | - $return = ""; |
|
| 1809 | + $return = ""; |
|
| 1810 | 1810 | |
| 1811 | - if ( ! is_array( $classes ) ) { |
|
| 1812 | - $classes = explode( $sep, $classes ); |
|
| 1813 | - } |
|
| 1811 | + if ( ! is_array( $classes ) ) { |
|
| 1812 | + $classes = explode( $sep, $classes ); |
|
| 1813 | + } |
|
| 1814 | 1814 | |
| 1815 | - if ( ! empty( $classes ) ) { |
|
| 1816 | - foreach ( $classes as $class ) { |
|
| 1817 | - $return .= sanitize_html_class( $class ) . " "; |
|
| 1818 | - } |
|
| 1819 | - } |
|
| 1815 | + if ( ! empty( $classes ) ) { |
|
| 1816 | + foreach ( $classes as $class ) { |
|
| 1817 | + $return .= sanitize_html_class( $class ) . " "; |
|
| 1818 | + } |
|
| 1819 | + } |
|
| 1820 | 1820 | |
| 1821 | - return $return; |
|
| 1821 | + return $return; |
|
| 1822 | 1822 | } |
| 1823 | 1823 | |
| 1824 | 1824 | |
@@ -1828,21 +1828,21 @@ discard block |
||
| 1828 | 1828 | * @return void |
| 1829 | 1829 | */ |
| 1830 | 1830 | function sd_get_class_build_keys() { |
| 1831 | - $keys = array( |
|
| 1832 | - 'container', |
|
| 1833 | - 'position', |
|
| 1834 | - 'flex_direction', |
|
| 1835 | - 'shadow', |
|
| 1836 | - 'rounded', |
|
| 1837 | - 'nav_style', |
|
| 1838 | - 'horizontal_alignment', |
|
| 1839 | - 'nav_fill', |
|
| 1840 | - 'width', |
|
| 1841 | - 'font_weight', |
|
| 1842 | - 'font_size', |
|
| 1843 | - 'font_case', |
|
| 1844 | - 'css_class', |
|
| 1845 | - ); |
|
| 1846 | - |
|
| 1847 | - return apply_filters( "sd_class_build_keys", $keys ); |
|
| 1831 | + $keys = array( |
|
| 1832 | + 'container', |
|
| 1833 | + 'position', |
|
| 1834 | + 'flex_direction', |
|
| 1835 | + 'shadow', |
|
| 1836 | + 'rounded', |
|
| 1837 | + 'nav_style', |
|
| 1838 | + 'horizontal_alignment', |
|
| 1839 | + 'nav_fill', |
|
| 1840 | + 'width', |
|
| 1841 | + 'font_weight', |
|
| 1842 | + 'font_size', |
|
| 1843 | + 'font_case', |
|
| 1844 | + 'css_class', |
|
| 1845 | + ); |
|
| 1846 | + |
|
| 1847 | + return apply_filters( "sd_class_build_keys", $keys ); |
|
| 1848 | 1848 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * @return mixed|void |
| 12 | 12 | */ |
| 13 | 13 | function sd_pagenow_exclude() { |
| 14 | - return apply_filters( 'sd_pagenow_exclude', array( |
|
| 14 | + return apply_filters('sd_pagenow_exclude', array( |
|
| 15 | 15 | 'upload.php', |
| 16 | 16 | 'edit-comments.php', |
| 17 | 17 | 'edit-tags.php', |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | 'edit.php', |
| 23 | 23 | 'themes.php', |
| 24 | 24 | 'users.php', |
| 25 | - ) ); |
|
| 25 | + )); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * @return mixed|void |
| 35 | 35 | */ |
| 36 | 36 | function sd_widget_exclude() { |
| 37 | - return apply_filters( 'sd_widget_exclude', array() ); |
|
| 37 | + return apply_filters('sd_widget_exclude', array()); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | |
@@ -46,10 +46,10 @@ discard block |
||
| 46 | 46 | * |
| 47 | 47 | * @return array |
| 48 | 48 | */ |
| 49 | -function sd_get_margin_input( $type = 'mt', $overwrite = array(), $include_negatives = true ) { |
|
| 49 | +function sd_get_margin_input($type = 'mt', $overwrite = array(), $include_negatives = true) { |
|
| 50 | 50 | $options = array( |
| 51 | - "" => __( 'None' ), |
|
| 52 | - "auto" => __( 'auto' ), |
|
| 51 | + "" => __('None'), |
|
| 52 | + "auto" => __('auto'), |
|
| 53 | 53 | "0" => "0", |
| 54 | 54 | "1" => "1", |
| 55 | 55 | "2" => "2", |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | "5" => "5", |
| 59 | 59 | ); |
| 60 | 60 | |
| 61 | - if ( $include_negatives ) { |
|
| 61 | + if ($include_negatives) { |
|
| 62 | 62 | $options['n1'] = '-1'; |
| 63 | 63 | $options['n2'] = '-2'; |
| 64 | 64 | $options['n3'] = '-3'; |
@@ -68,38 +68,38 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | $defaults = array( |
| 70 | 70 | 'type' => 'select', |
| 71 | - 'title' => __( 'Margin top' ), |
|
| 71 | + 'title' => __('Margin top'), |
|
| 72 | 72 | 'options' => $options, |
| 73 | 73 | 'default' => '', |
| 74 | 74 | 'desc_tip' => true, |
| 75 | - 'group' => __( "Wrapper Styles", "geodirectory" ), |
|
| 75 | + 'group' => __("Wrapper Styles", "geodirectory"), |
|
| 76 | 76 | // 'device_type' => 'Desktop', |
| 77 | 77 | ); |
| 78 | 78 | |
| 79 | 79 | // title |
| 80 | - if ( $type == 'mt' ) { |
|
| 81 | - $defaults['title'] = __( 'Margin top' ); |
|
| 80 | + if ($type == 'mt') { |
|
| 81 | + $defaults['title'] = __('Margin top'); |
|
| 82 | 82 | $defaults['icon'] = 'box-top'; |
| 83 | 83 | $defaults['row'] = array( |
| 84 | - 'title' => __( 'Margins' ), |
|
| 84 | + 'title' => __('Margins'), |
|
| 85 | 85 | 'key' => 'wrapper-margins', |
| 86 | 86 | 'open' => true, |
| 87 | 87 | 'class' => 'text-center', |
| 88 | 88 | ); |
| 89 | - } elseif ( $type == 'mr' ) { |
|
| 90 | - $defaults['title'] = __( 'Margin right' ); |
|
| 89 | + } elseif ($type == 'mr') { |
|
| 90 | + $defaults['title'] = __('Margin right'); |
|
| 91 | 91 | $defaults['icon'] = 'box-right'; |
| 92 | 92 | $defaults['row'] = array( |
| 93 | 93 | 'key' => 'wrapper-margins', |
| 94 | 94 | ); |
| 95 | - } elseif ( $type == 'mb' ) { |
|
| 96 | - $defaults['title'] = __( 'Margin bottom' ); |
|
| 95 | + } elseif ($type == 'mb') { |
|
| 96 | + $defaults['title'] = __('Margin bottom'); |
|
| 97 | 97 | $defaults['icon'] = 'box-bottom'; |
| 98 | 98 | $defaults['row'] = array( |
| 99 | 99 | 'key' => 'wrapper-margins', |
| 100 | 100 | ); |
| 101 | - } elseif ( $type == 'ml' ) { |
|
| 102 | - $defaults['title'] = __( 'Margin left' ); |
|
| 101 | + } elseif ($type == 'ml') { |
|
| 102 | + $defaults['title'] = __('Margin left'); |
|
| 103 | 103 | $defaults['icon'] = 'box-left'; |
| 104 | 104 | $defaults['row'] = array( |
| 105 | 105 | 'key' => 'wrapper-margins', |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | ); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 110 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 111 | 111 | |
| 112 | 112 | |
| 113 | 113 | return $input; |
@@ -121,9 +121,9 @@ discard block |
||
| 121 | 121 | * |
| 122 | 122 | * @return array |
| 123 | 123 | */ |
| 124 | -function sd_get_padding_input( $type = 'pt', $overwrite = array() ) { |
|
| 124 | +function sd_get_padding_input($type = 'pt', $overwrite = array()) { |
|
| 125 | 125 | $options = array( |
| 126 | - "" => __( 'None' ), |
|
| 126 | + "" => __('None'), |
|
| 127 | 127 | "0" => "0", |
| 128 | 128 | "1" => "1", |
| 129 | 129 | "2" => "2", |
@@ -134,37 +134,37 @@ discard block |
||
| 134 | 134 | |
| 135 | 135 | $defaults = array( |
| 136 | 136 | 'type' => 'select', |
| 137 | - 'title' => __( 'Padding top' ), |
|
| 137 | + 'title' => __('Padding top'), |
|
| 138 | 138 | 'options' => $options, |
| 139 | 139 | 'default' => '', |
| 140 | 140 | 'desc_tip' => true, |
| 141 | - 'group' => __( "Wrapper Styles", "geodirectory" ) |
|
| 141 | + 'group' => __("Wrapper Styles", "geodirectory") |
|
| 142 | 142 | ); |
| 143 | 143 | |
| 144 | 144 | // title |
| 145 | - if ( $type == 'pt' ) { |
|
| 146 | - $defaults['title'] = __( 'Padding top' ); |
|
| 145 | + if ($type == 'pt') { |
|
| 146 | + $defaults['title'] = __('Padding top'); |
|
| 147 | 147 | $defaults['icon'] = 'box-top'; |
| 148 | 148 | $defaults['row'] = array( |
| 149 | - 'title' => __( 'Padding' ), |
|
| 149 | + 'title' => __('Padding'), |
|
| 150 | 150 | 'key' => 'wrapper-padding', |
| 151 | 151 | 'open' => true, |
| 152 | 152 | 'class' => 'text-center', |
| 153 | 153 | ); |
| 154 | - } elseif ( $type == 'pr' ) { |
|
| 155 | - $defaults['title'] = __( 'Padding right' ); |
|
| 154 | + } elseif ($type == 'pr') { |
|
| 155 | + $defaults['title'] = __('Padding right'); |
|
| 156 | 156 | $defaults['icon'] = 'box-right'; |
| 157 | 157 | $defaults['row'] = array( |
| 158 | 158 | 'key' => 'wrapper-padding', |
| 159 | 159 | ); |
| 160 | - } elseif ( $type == 'pb' ) { |
|
| 161 | - $defaults['title'] = __( 'Padding bottom' ); |
|
| 160 | + } elseif ($type == 'pb') { |
|
| 161 | + $defaults['title'] = __('Padding bottom'); |
|
| 162 | 162 | $defaults['icon'] = 'box-bottom'; |
| 163 | 163 | $defaults['row'] = array( |
| 164 | 164 | 'key' => 'wrapper-padding', |
| 165 | 165 | ); |
| 166 | - } elseif ( $type == 'pl' ) { |
|
| 167 | - $defaults['title'] = __( 'Padding left' ); |
|
| 166 | + } elseif ($type == 'pl') { |
|
| 167 | + $defaults['title'] = __('Padding left'); |
|
| 168 | 168 | $defaults['icon'] = 'box-left'; |
| 169 | 169 | $defaults['row'] = array( |
| 170 | 170 | 'key' => 'wrapper-padding', |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | ); |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 176 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 177 | 177 | |
| 178 | 178 | |
| 179 | 179 | return $input; |
@@ -187,22 +187,22 @@ discard block |
||
| 187 | 187 | * |
| 188 | 188 | * @return array |
| 189 | 189 | */ |
| 190 | -function sd_get_border_input( $type = 'border', $overwrite = array() ) { |
|
| 190 | +function sd_get_border_input($type = 'border', $overwrite = array()) { |
|
| 191 | 191 | |
| 192 | 192 | $defaults = array( |
| 193 | 193 | 'type' => 'select', |
| 194 | - 'title' => __( 'Border' ), |
|
| 194 | + 'title' => __('Border'), |
|
| 195 | 195 | 'options' => array(), |
| 196 | 196 | 'default' => '', |
| 197 | 197 | 'desc_tip' => true, |
| 198 | - 'group' => __( "Wrapper Styles", "geodirectory" ) |
|
| 198 | + 'group' => __("Wrapper Styles", "geodirectory") |
|
| 199 | 199 | ); |
| 200 | 200 | |
| 201 | 201 | // title |
| 202 | - if ( $type == 'rounded' ) { |
|
| 203 | - $defaults['title'] = __( 'Border radius type' ); |
|
| 202 | + if ($type == 'rounded') { |
|
| 203 | + $defaults['title'] = __('Border radius type'); |
|
| 204 | 204 | $defaults['options'] = array( |
| 205 | - '' => __( "Default", "geodirectory" ), |
|
| 205 | + '' => __("Default", "geodirectory"), |
|
| 206 | 206 | 'rounded' => 'rounded', |
| 207 | 207 | 'rounded-top' => 'rounded-top', |
| 208 | 208 | 'rounded-right' => 'rounded-right', |
@@ -212,32 +212,32 @@ discard block |
||
| 212 | 212 | 'rounded-pill' => 'rounded-pill', |
| 213 | 213 | 'rounded-0' => 'rounded-0', |
| 214 | 214 | ); |
| 215 | - } elseif ( $type == 'rounded_size' ) { |
|
| 216 | - $defaults['title'] = __( 'Border radius size' ); |
|
| 215 | + } elseif ($type == 'rounded_size') { |
|
| 216 | + $defaults['title'] = __('Border radius size'); |
|
| 217 | 217 | $defaults['options'] = array( |
| 218 | - '' => __( "Default", "geodirectory" ), |
|
| 219 | - 'sm' => __( "Small", "geodirectory" ), |
|
| 220 | - 'lg' => __( "Large", "geodirectory" ), |
|
| 218 | + '' => __("Default", "geodirectory"), |
|
| 219 | + 'sm' => __("Small", "geodirectory"), |
|
| 220 | + 'lg' => __("Large", "geodirectory"), |
|
| 221 | 221 | ); |
| 222 | - } elseif ( $type == 'type' ) { |
|
| 223 | - $defaults['title'] = __( 'Border type' ); |
|
| 222 | + } elseif ($type == 'type') { |
|
| 223 | + $defaults['title'] = __('Border type'); |
|
| 224 | 224 | $defaults['options'] = array( |
| 225 | - '' => __( "None", "geodirectory" ), |
|
| 226 | - 'border' => __( "Full", "geodirectory" ), |
|
| 227 | - 'border-top' => __( "Top", "geodirectory" ), |
|
| 228 | - 'border-bottom' => __( "Bottom", "geodirectory" ), |
|
| 229 | - 'border-left' => __( "Left", "geodirectory" ), |
|
| 230 | - 'border-right' => __( "Right", "geodirectory" ), |
|
| 225 | + '' => __("None", "geodirectory"), |
|
| 226 | + 'border' => __("Full", "geodirectory"), |
|
| 227 | + 'border-top' => __("Top", "geodirectory"), |
|
| 228 | + 'border-bottom' => __("Bottom", "geodirectory"), |
|
| 229 | + 'border-left' => __("Left", "geodirectory"), |
|
| 230 | + 'border-right' => __("Right", "geodirectory"), |
|
| 231 | 231 | ); |
| 232 | 232 | } else { |
| 233 | - $defaults['title'] = __( 'Border color' ); |
|
| 233 | + $defaults['title'] = __('Border color'); |
|
| 234 | 234 | $defaults['options'] = array( |
| 235 | - '' => __( "Default", "geodirectory" ), |
|
| 236 | - '0' => __( "None", "geodirectory" ), |
|
| 235 | + '' => __("Default", "geodirectory"), |
|
| 236 | + '0' => __("None", "geodirectory"), |
|
| 237 | 237 | ) + sd_aui_colors(); |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 240 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 241 | 241 | |
| 242 | 242 | |
| 243 | 243 | return $input; |
@@ -251,25 +251,25 @@ discard block |
||
| 251 | 251 | * |
| 252 | 252 | * @return array |
| 253 | 253 | */ |
| 254 | -function sd_get_shadow_input( $type = 'shadow', $overwrite = array() ) { |
|
| 254 | +function sd_get_shadow_input($type = 'shadow', $overwrite = array()) { |
|
| 255 | 255 | $options = array( |
| 256 | - "" => __( 'None' ), |
|
| 257 | - "shadow-sm" => __( 'Small' ), |
|
| 258 | - "shadow" => __( 'Regular' ), |
|
| 259 | - "shadow-lg" => __( 'Large' ), |
|
| 256 | + "" => __('None'), |
|
| 257 | + "shadow-sm" => __('Small'), |
|
| 258 | + "shadow" => __('Regular'), |
|
| 259 | + "shadow-lg" => __('Large'), |
|
| 260 | 260 | ); |
| 261 | 261 | |
| 262 | 262 | $defaults = array( |
| 263 | 263 | 'type' => 'select', |
| 264 | - 'title' => __( 'Shadow' ), |
|
| 264 | + 'title' => __('Shadow'), |
|
| 265 | 265 | 'options' => $options, |
| 266 | 266 | 'default' => '', |
| 267 | 267 | 'desc_tip' => true, |
| 268 | - 'group' => __( "Wrapper Styles", "geodirectory" ) |
|
| 268 | + 'group' => __("Wrapper Styles", "geodirectory") |
|
| 269 | 269 | ); |
| 270 | 270 | |
| 271 | 271 | |
| 272 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 272 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 273 | 273 | |
| 274 | 274 | |
| 275 | 275 | return $input; |
@@ -283,23 +283,23 @@ discard block |
||
| 283 | 283 | * |
| 284 | 284 | * @return array |
| 285 | 285 | */ |
| 286 | -function sd_get_background_input( $type = 'bg', $overwrite = array() ) { |
|
| 286 | +function sd_get_background_input($type = 'bg', $overwrite = array()) { |
|
| 287 | 287 | $options = array( |
| 288 | - '' => __( "None", "geodirectory" ), |
|
| 289 | - 'transparent' => __( "Transparent", "geodirectory" ), |
|
| 288 | + '' => __("None", "geodirectory"), |
|
| 289 | + 'transparent' => __("Transparent", "geodirectory"), |
|
| 290 | 290 | ) + sd_aui_colors(); |
| 291 | 291 | |
| 292 | 292 | $defaults = array( |
| 293 | 293 | 'type' => 'select', |
| 294 | - 'title' => __( 'Background color' ), |
|
| 294 | + 'title' => __('Background color'), |
|
| 295 | 295 | 'options' => $options, |
| 296 | 296 | 'default' => '', |
| 297 | 297 | 'desc_tip' => true, |
| 298 | - 'group' => __( "Wrapper Styles", "geodirectory" ) |
|
| 298 | + 'group' => __("Wrapper Styles", "geodirectory") |
|
| 299 | 299 | ); |
| 300 | 300 | |
| 301 | 301 | |
| 302 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 302 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 303 | 303 | |
| 304 | 304 | |
| 305 | 305 | return $input; |
@@ -313,106 +313,106 @@ discard block |
||
| 313 | 313 | * |
| 314 | 314 | * @return array |
| 315 | 315 | */ |
| 316 | -function sd_get_background_inputs( $type = 'bg', $overwrite = array(), $overwrite_color = array(), $overwrite_gradient = array(), $overwrite_image = array() ) { |
|
| 316 | +function sd_get_background_inputs($type = 'bg', $overwrite = array(), $overwrite_color = array(), $overwrite_gradient = array(), $overwrite_image = array()) { |
|
| 317 | 317 | $options = array( |
| 318 | - '' => __( "None", "geodirectory" ), |
|
| 319 | - 'transparent' => __( "Transparent", "geodirectory" ), |
|
| 318 | + '' => __("None", "geodirectory"), |
|
| 319 | + 'transparent' => __("Transparent", "geodirectory"), |
|
| 320 | 320 | ) + sd_aui_colors() |
| 321 | 321 | + array( |
| 322 | - 'custom-color' => __( "Custom Color", "geodirectory" ), |
|
| 323 | - 'custom-gradient' => __( "Custom Gradient", "geodirectory" ), |
|
| 322 | + 'custom-color' => __("Custom Color", "geodirectory"), |
|
| 323 | + 'custom-gradient' => __("Custom Gradient", "geodirectory"), |
|
| 324 | 324 | // 'custom-image' => __("Custom Image","geodirectory"), |
| 325 | 325 | ); |
| 326 | 326 | |
| 327 | 327 | $defaults = array( |
| 328 | 328 | 'type' => 'select', |
| 329 | - 'title' => __( 'Background Color' ), |
|
| 329 | + 'title' => __('Background Color'), |
|
| 330 | 330 | 'options' => $options, |
| 331 | 331 | 'default' => '', |
| 332 | 332 | 'desc_tip' => true, |
| 333 | - 'group' => __( "Background", "geodirectory" ) |
|
| 333 | + 'group' => __("Background", "geodirectory") |
|
| 334 | 334 | ); |
| 335 | 335 | |
| 336 | 336 | |
| 337 | - if ( $overwrite !== false ) { |
|
| 338 | - $input[ $type ] = wp_parse_args( $overwrite, $defaults ); |
|
| 337 | + if ($overwrite !== false) { |
|
| 338 | + $input[$type] = wp_parse_args($overwrite, $defaults); |
|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | |
| 342 | - if ( $overwrite_color !== false ) { |
|
| 343 | - $input[ $type . '_color' ] = wp_parse_args( $overwrite_color, array( |
|
| 342 | + if ($overwrite_color !== false) { |
|
| 343 | + $input[$type . '_color'] = wp_parse_args($overwrite_color, array( |
|
| 344 | 344 | 'type' => 'color', |
| 345 | - 'title' => __( 'Custom color' ), |
|
| 345 | + 'title' => __('Custom color'), |
|
| 346 | 346 | 'placeholder' => '', |
| 347 | 347 | 'default' => '#0073aa', |
| 348 | 348 | 'desc_tip' => true, |
| 349 | - 'group' => __( "Background" ), |
|
| 349 | + 'group' => __("Background"), |
|
| 350 | 350 | 'element_require' => '[%' . $type . '%]=="custom-color"' |
| 351 | - ) ); |
|
| 351 | + )); |
|
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | |
| 355 | - if ( $overwrite_gradient !== false ) { |
|
| 356 | - $input[ $type . '_gradient' ] = wp_parse_args( $overwrite_gradient, array( |
|
| 355 | + if ($overwrite_gradient !== false) { |
|
| 356 | + $input[$type . '_gradient'] = wp_parse_args($overwrite_gradient, array( |
|
| 357 | 357 | 'type' => 'gradient', |
| 358 | - 'title' => __( 'Custom gradient' ), |
|
| 358 | + 'title' => __('Custom gradient'), |
|
| 359 | 359 | 'placeholder' => '', |
| 360 | 360 | 'default' => 'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)', |
| 361 | 361 | 'desc_tip' => true, |
| 362 | - 'group' => __( "Background" ), |
|
| 362 | + 'group' => __("Background"), |
|
| 363 | 363 | 'element_require' => '[%' . $type . '%]=="custom-gradient"' |
| 364 | - ) ); |
|
| 364 | + )); |
|
| 365 | 365 | } |
| 366 | 366 | |
| 367 | - if ( $overwrite_image !== false ) { |
|
| 367 | + if ($overwrite_image !== false) { |
|
| 368 | 368 | |
| 369 | - $input[ $type . '_image_fixed' ] = array( |
|
| 369 | + $input[$type . '_image_fixed'] = array( |
|
| 370 | 370 | 'type' => 'checkbox', |
| 371 | - 'title' => __( 'Fixed background' ), |
|
| 371 | + 'title' => __('Fixed background'), |
|
| 372 | 372 | 'default' => '', |
| 373 | 373 | 'desc_tip' => true, |
| 374 | - 'group' => __( "Background" ), |
|
| 374 | + 'group' => __("Background"), |
|
| 375 | 375 | 'element_require' => '( [%' . $type . '%]=="" || [%' . $type . '%]=="custom-color" || [%' . $type . '%]=="custom-gradient" || [%' . $type . '%]=="transparent" )' |
| 376 | 376 | |
| 377 | 377 | ); |
| 378 | 378 | |
| 379 | - $input[ $type . '_image_use_featured' ] = array( |
|
| 379 | + $input[$type . '_image_use_featured'] = array( |
|
| 380 | 380 | 'type' => 'checkbox', |
| 381 | - 'title' => __( 'Use featured image' ), |
|
| 381 | + 'title' => __('Use featured image'), |
|
| 382 | 382 | 'default' => '', |
| 383 | 383 | 'desc_tip' => true, |
| 384 | - 'group' => __( "Background" ), |
|
| 384 | + 'group' => __("Background"), |
|
| 385 | 385 | 'element_require' => '( [%' . $type . '%]=="" || [%' . $type . '%]=="custom-color" || [%' . $type . '%]=="custom-gradient" || [%' . $type . '%]=="transparent" )' |
| 386 | 386 | |
| 387 | 387 | ); |
| 388 | 388 | |
| 389 | 389 | |
| 390 | - $input[ $type . '_image' ] = wp_parse_args( $overwrite_image, array( |
|
| 390 | + $input[$type . '_image'] = wp_parse_args($overwrite_image, array( |
|
| 391 | 391 | 'type' => 'image', |
| 392 | - 'title' => __( 'Custom image' ), |
|
| 392 | + 'title' => __('Custom image'), |
|
| 393 | 393 | 'placeholder' => '', |
| 394 | 394 | 'default' => '', |
| 395 | 395 | 'desc_tip' => true, |
| 396 | - 'group' => __( "Background" ), |
|
| 396 | + 'group' => __("Background"), |
|
| 397 | 397 | // 'element_require' => ' ![%' . $type . '_image_use_featured%] ' |
| 398 | - ) ); |
|
| 398 | + )); |
|
| 399 | 399 | |
| 400 | - $input[ $type . '_image_id' ] = wp_parse_args( $overwrite_image, array( |
|
| 400 | + $input[$type . '_image_id'] = wp_parse_args($overwrite_image, array( |
|
| 401 | 401 | 'type' => 'hidden', |
| 402 | 402 | 'hidden_type' => 'number', |
| 403 | 403 | 'title' => '', |
| 404 | 404 | 'placeholder' => '', |
| 405 | 405 | 'default' => '', |
| 406 | - 'group' => __( "Background" ), |
|
| 407 | - ) ); |
|
| 406 | + 'group' => __("Background"), |
|
| 407 | + )); |
|
| 408 | 408 | |
| 409 | - $input[ $type . '_image_xy' ] = wp_parse_args( $overwrite_image, array( |
|
| 409 | + $input[$type . '_image_xy'] = wp_parse_args($overwrite_image, array( |
|
| 410 | 410 | 'type' => 'image_xy', |
| 411 | 411 | 'title' => '', |
| 412 | 412 | 'placeholder' => '', |
| 413 | 413 | 'default' => '', |
| 414 | - 'group' => __( "Background" ), |
|
| 415 | - ) ); |
|
| 414 | + 'group' => __("Background"), |
|
| 415 | + )); |
|
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | return $input; |
@@ -426,96 +426,96 @@ discard block |
||
| 426 | 426 | * |
| 427 | 427 | * @return array |
| 428 | 428 | */ |
| 429 | -function sd_get_shape_divider_inputs( $type = 'sd', $overwrite = array(), $overwrite_color = array(), $overwrite_gradient = array(), $overwrite_image = array() ) { |
|
| 429 | +function sd_get_shape_divider_inputs($type = 'sd', $overwrite = array(), $overwrite_color = array(), $overwrite_gradient = array(), $overwrite_image = array()) { |
|
| 430 | 430 | |
| 431 | 431 | $options = array( |
| 432 | - '' => __( "None" ), |
|
| 433 | - 'mountains' => __( "Mountains" ), |
|
| 434 | - 'drops' => __( "Drops" ), |
|
| 435 | - 'clouds' => __( "Clouds" ), |
|
| 436 | - 'zigzag' => __( "Zigzag" ), |
|
| 437 | - 'pyramids' => __( "Pyramids" ), |
|
| 438 | - 'triangle' => __( "Triangle" ), |
|
| 439 | - 'triangle-asymmetrical' => __( "Triangle Asymmetrical" ), |
|
| 440 | - 'tilt' => __( "Tilt" ), |
|
| 441 | - 'opacity-tilt' => __( "Opacity Tilt" ), |
|
| 442 | - 'opacity-fan' => __( "Opacity Fan" ), |
|
| 443 | - 'curve' => __( "Curve" ), |
|
| 444 | - 'curve-asymmetrical' => __( "Curve Asymmetrical" ), |
|
| 445 | - 'waves' => __( "Waves" ), |
|
| 446 | - 'wave-brush' => __( "Wave Brush" ), |
|
| 447 | - 'waves-pattern' => __( "Waves Pattern" ), |
|
| 448 | - 'arrow' => __( "Arrow" ), |
|
| 449 | - 'split' => __( "Split" ), |
|
| 450 | - 'book' => __( "Book" ), |
|
| 432 | + '' => __("None"), |
|
| 433 | + 'mountains' => __("Mountains"), |
|
| 434 | + 'drops' => __("Drops"), |
|
| 435 | + 'clouds' => __("Clouds"), |
|
| 436 | + 'zigzag' => __("Zigzag"), |
|
| 437 | + 'pyramids' => __("Pyramids"), |
|
| 438 | + 'triangle' => __("Triangle"), |
|
| 439 | + 'triangle-asymmetrical' => __("Triangle Asymmetrical"), |
|
| 440 | + 'tilt' => __("Tilt"), |
|
| 441 | + 'opacity-tilt' => __("Opacity Tilt"), |
|
| 442 | + 'opacity-fan' => __("Opacity Fan"), |
|
| 443 | + 'curve' => __("Curve"), |
|
| 444 | + 'curve-asymmetrical' => __("Curve Asymmetrical"), |
|
| 445 | + 'waves' => __("Waves"), |
|
| 446 | + 'wave-brush' => __("Wave Brush"), |
|
| 447 | + 'waves-pattern' => __("Waves Pattern"), |
|
| 448 | + 'arrow' => __("Arrow"), |
|
| 449 | + 'split' => __("Split"), |
|
| 450 | + 'book' => __("Book"), |
|
| 451 | 451 | ); |
| 452 | 452 | |
| 453 | 453 | $defaults = array( |
| 454 | 454 | 'type' => 'select', |
| 455 | - 'title' => __( 'Type' ), |
|
| 455 | + 'title' => __('Type'), |
|
| 456 | 456 | 'options' => $options, |
| 457 | 457 | 'default' => '', |
| 458 | 458 | 'desc_tip' => true, |
| 459 | - 'group' => __( "Shape Divider" ), |
|
| 459 | + 'group' => __("Shape Divider"), |
|
| 460 | 460 | ); |
| 461 | 461 | |
| 462 | 462 | |
| 463 | - $input[ $type ] = wp_parse_args( $overwrite, $defaults ); |
|
| 463 | + $input[$type] = wp_parse_args($overwrite, $defaults); |
|
| 464 | 464 | |
| 465 | 465 | |
| 466 | - $input[ $type . '_notice' ] = array( |
|
| 466 | + $input[$type . '_notice'] = array( |
|
| 467 | 467 | 'type' => 'notice', |
| 468 | - 'desc' => __( 'Parent element must be position `relative`' ), |
|
| 468 | + 'desc' => __('Parent element must be position `relative`'), |
|
| 469 | 469 | 'status' => 'warning', |
| 470 | - 'group' => __( "Shape Divider" ), |
|
| 470 | + 'group' => __("Shape Divider"), |
|
| 471 | 471 | 'element_require' => '[%' . $type . '%]!=""', |
| 472 | 472 | ); |
| 473 | 473 | |
| 474 | 474 | |
| 475 | - $input[ $type . '_position' ] = wp_parse_args( $overwrite_color, array( |
|
| 475 | + $input[$type . '_position'] = wp_parse_args($overwrite_color, array( |
|
| 476 | 476 | 'type' => 'select', |
| 477 | - 'title' => __( 'Position' ), |
|
| 477 | + 'title' => __('Position'), |
|
| 478 | 478 | 'options' => array( |
| 479 | - 'top' => __( 'Top' ), |
|
| 480 | - 'bottom' => __( 'Bottom' ), |
|
| 479 | + 'top' => __('Top'), |
|
| 480 | + 'bottom' => __('Bottom'), |
|
| 481 | 481 | //'left' => __('Left'), |
| 482 | 482 | //'right' => __('Right'), |
| 483 | 483 | ), |
| 484 | 484 | 'desc_tip' => true, |
| 485 | - 'group' => __( "Shape Divider" ), |
|
| 485 | + 'group' => __("Shape Divider"), |
|
| 486 | 486 | 'element_require' => '[%' . $type . '%]!=""' |
| 487 | - ) ); |
|
| 487 | + )); |
|
| 488 | 488 | |
| 489 | 489 | $options = array( |
| 490 | - '' => __( "None" ), |
|
| 491 | - 'transparent' => __( "Transparent" ), |
|
| 490 | + '' => __("None"), |
|
| 491 | + 'transparent' => __("Transparent"), |
|
| 492 | 492 | ) + sd_aui_colors() |
| 493 | 493 | + array( |
| 494 | - 'custom-color' => __( "Custom Color" ), |
|
| 494 | + 'custom-color' => __("Custom Color"), |
|
| 495 | 495 | ); |
| 496 | 496 | |
| 497 | - $input[ $type . '_color' ] = wp_parse_args( $overwrite_color, array( |
|
| 497 | + $input[$type . '_color'] = wp_parse_args($overwrite_color, array( |
|
| 498 | 498 | 'type' => 'select', |
| 499 | - 'title' => __( 'Color' ), |
|
| 499 | + 'title' => __('Color'), |
|
| 500 | 500 | 'options' => $options, |
| 501 | 501 | 'desc_tip' => true, |
| 502 | - 'group' => __( "Shape Divider" ), |
|
| 502 | + 'group' => __("Shape Divider"), |
|
| 503 | 503 | 'element_require' => '[%' . $type . '%]!=""' |
| 504 | - ) ); |
|
| 504 | + )); |
|
| 505 | 505 | |
| 506 | - $input[ $type . '_custom_color' ] = wp_parse_args( $overwrite_color, array( |
|
| 506 | + $input[$type . '_custom_color'] = wp_parse_args($overwrite_color, array( |
|
| 507 | 507 | 'type' => 'color', |
| 508 | - 'title' => __( 'Custom color' ), |
|
| 508 | + 'title' => __('Custom color'), |
|
| 509 | 509 | 'placeholder' => '', |
| 510 | 510 | 'default' => '#0073aa', |
| 511 | 511 | 'desc_tip' => true, |
| 512 | - 'group' => __( "Shape Divider" ), |
|
| 512 | + 'group' => __("Shape Divider"), |
|
| 513 | 513 | 'element_require' => '[%' . $type . '_color%]=="custom-color" && [%' . $type . '%]!=""' |
| 514 | - ) ); |
|
| 514 | + )); |
|
| 515 | 515 | |
| 516 | - $input[ $type . '_width' ] = wp_parse_args( $overwrite_gradient, array( |
|
| 516 | + $input[$type . '_width'] = wp_parse_args($overwrite_gradient, array( |
|
| 517 | 517 | 'type' => 'range', |
| 518 | - 'title' => __( 'Width' ), |
|
| 518 | + 'title' => __('Width'), |
|
| 519 | 519 | 'placeholder' => '', |
| 520 | 520 | 'default' => '200', |
| 521 | 521 | 'desc_tip' => true, |
@@ -523,68 +523,68 @@ discard block |
||
| 523 | 523 | 'min' => 100, |
| 524 | 524 | 'max' => 300, |
| 525 | 525 | ), |
| 526 | - 'group' => __( "Shape Divider" ), |
|
| 526 | + 'group' => __("Shape Divider"), |
|
| 527 | 527 | 'element_require' => '[%' . $type . '%]!=""' |
| 528 | - ) ); |
|
| 528 | + )); |
|
| 529 | 529 | |
| 530 | - $input[ $type . '_height' ] = array( |
|
| 530 | + $input[$type . '_height'] = array( |
|
| 531 | 531 | 'type' => 'range', |
| 532 | - 'title' => __( 'Height' ), |
|
| 532 | + 'title' => __('Height'), |
|
| 533 | 533 | 'default' => '100', |
| 534 | 534 | 'desc_tip' => true, |
| 535 | 535 | 'custom_attributes' => array( |
| 536 | 536 | 'min' => 0, |
| 537 | 537 | 'max' => 500, |
| 538 | 538 | ), |
| 539 | - 'group' => __( "Shape Divider" ), |
|
| 539 | + 'group' => __("Shape Divider"), |
|
| 540 | 540 | 'element_require' => '[%' . $type . '%]!=""' |
| 541 | 541 | ); |
| 542 | 542 | |
| 543 | 543 | $requires = array( |
| 544 | - 'mountains' => array( 'flip' ), |
|
| 545 | - 'drops' => array( 'flip', 'invert' ), |
|
| 546 | - 'clouds' => array( 'flip', 'invert' ), |
|
| 544 | + 'mountains' => array('flip'), |
|
| 545 | + 'drops' => array('flip', 'invert'), |
|
| 546 | + 'clouds' => array('flip', 'invert'), |
|
| 547 | 547 | 'zigzag' => array(), |
| 548 | - 'pyramids' => array( 'flip', 'invert' ), |
|
| 549 | - 'triangle' => array( 'invert' ), |
|
| 550 | - 'triangle-asymmetrical' => array( 'flip', 'invert' ), |
|
| 551 | - 'tilt' => array( 'flip' ), |
|
| 552 | - 'opacity-tilt' => array( 'flip' ), |
|
| 548 | + 'pyramids' => array('flip', 'invert'), |
|
| 549 | + 'triangle' => array('invert'), |
|
| 550 | + 'triangle-asymmetrical' => array('flip', 'invert'), |
|
| 551 | + 'tilt' => array('flip'), |
|
| 552 | + 'opacity-tilt' => array('flip'), |
|
| 553 | 553 | 'opacity-fan' => array(), |
| 554 | - 'curve' => array( 'invert' ), |
|
| 555 | - 'curve-asymmetrical' => array( 'flip', 'invert' ), |
|
| 556 | - 'waves' => array( 'flip', 'invert' ), |
|
| 557 | - 'wave-brush' => array( 'flip' ), |
|
| 558 | - 'waves-pattern' => array( 'flip' ), |
|
| 559 | - 'arrow' => array( 'invert' ), |
|
| 560 | - 'split' => array( 'invert' ), |
|
| 561 | - 'book' => array( 'invert' ), |
|
| 554 | + 'curve' => array('invert'), |
|
| 555 | + 'curve-asymmetrical' => array('flip', 'invert'), |
|
| 556 | + 'waves' => array('flip', 'invert'), |
|
| 557 | + 'wave-brush' => array('flip'), |
|
| 558 | + 'waves-pattern' => array('flip'), |
|
| 559 | + 'arrow' => array('invert'), |
|
| 560 | + 'split' => array('invert'), |
|
| 561 | + 'book' => array('invert'), |
|
| 562 | 562 | ); |
| 563 | 563 | |
| 564 | - $input[ $type . '_flip' ] = array( |
|
| 564 | + $input[$type . '_flip'] = array( |
|
| 565 | 565 | 'type' => 'checkbox', |
| 566 | - 'title' => __( 'Flip' ), |
|
| 566 | + 'title' => __('Flip'), |
|
| 567 | 567 | 'default' => '', |
| 568 | 568 | 'desc_tip' => true, |
| 569 | - 'group' => __( "Shape Divider" ), |
|
| 570 | - 'element_require' => sd_get_element_require_string( $requires, 'flip', 'sd' ) |
|
| 569 | + 'group' => __("Shape Divider"), |
|
| 570 | + 'element_require' => sd_get_element_require_string($requires, 'flip', 'sd') |
|
| 571 | 571 | ); |
| 572 | 572 | |
| 573 | - $input[ $type . '_invert' ] = array( |
|
| 573 | + $input[$type . '_invert'] = array( |
|
| 574 | 574 | 'type' => 'checkbox', |
| 575 | - 'title' => __( 'Invert' ), |
|
| 575 | + 'title' => __('Invert'), |
|
| 576 | 576 | 'default' => '', |
| 577 | 577 | 'desc_tip' => true, |
| 578 | - 'group' => __( "Shape Divider" ), |
|
| 579 | - 'element_require' => sd_get_element_require_string( $requires, 'invert', 'sd' ) |
|
| 578 | + 'group' => __("Shape Divider"), |
|
| 579 | + 'element_require' => sd_get_element_require_string($requires, 'invert', 'sd') |
|
| 580 | 580 | ); |
| 581 | 581 | |
| 582 | - $input[ $type . '_btf' ] = array( |
|
| 582 | + $input[$type . '_btf'] = array( |
|
| 583 | 583 | 'type' => 'checkbox', |
| 584 | - 'title' => __( 'Bring to front' ), |
|
| 584 | + 'title' => __('Bring to front'), |
|
| 585 | 585 | 'default' => '', |
| 586 | 586 | 'desc_tip' => true, |
| 587 | - 'group' => __( "Shape Divider" ), |
|
| 587 | + 'group' => __("Shape Divider"), |
|
| 588 | 588 | 'element_require' => '[%' . $type . '%]!=""' |
| 589 | 589 | |
| 590 | 590 | ); |
@@ -602,19 +602,19 @@ discard block |
||
| 602 | 602 | * |
| 603 | 603 | * @return string |
| 604 | 604 | */ |
| 605 | -function sd_get_element_require_string( $args, $key, $type ) { |
|
| 605 | +function sd_get_element_require_string($args, $key, $type) { |
|
| 606 | 606 | $output = ''; |
| 607 | 607 | $requires = array(); |
| 608 | 608 | |
| 609 | - if ( ! empty( $args ) ) { |
|
| 610 | - foreach ( $args as $t => $k ) { |
|
| 611 | - if ( in_array( $key, $k ) ) { |
|
| 609 | + if (!empty($args)) { |
|
| 610 | + foreach ($args as $t => $k) { |
|
| 611 | + if (in_array($key, $k)) { |
|
| 612 | 612 | $requires[] = '[%' . $type . '%]=="' . $t . '"'; |
| 613 | 613 | } |
| 614 | 614 | } |
| 615 | 615 | |
| 616 | - if ( ! empty( $requires ) ) { |
|
| 617 | - $output = '(' . implode( ' || ', $requires ) . ')'; |
|
| 616 | + if (!empty($requires)) { |
|
| 617 | + $output = '(' . implode(' || ', $requires) . ')'; |
|
| 618 | 618 | } |
| 619 | 619 | } |
| 620 | 620 | |
@@ -630,41 +630,41 @@ discard block |
||
| 630 | 630 | * |
| 631 | 631 | * @return array |
| 632 | 632 | */ |
| 633 | -function sd_get_text_color_input( $type = 'text_color', $overwrite = array(), $has_custom = false ) { |
|
| 633 | +function sd_get_text_color_input($type = 'text_color', $overwrite = array(), $has_custom = false) { |
|
| 634 | 634 | $options = array( |
| 635 | - '' => __( "None" ), |
|
| 635 | + '' => __("None"), |
|
| 636 | 636 | ) + sd_aui_colors(); |
| 637 | 637 | |
| 638 | - if ( $has_custom ) { |
|
| 639 | - $options['custom'] = __( 'Custom color' ); |
|
| 638 | + if ($has_custom) { |
|
| 639 | + $options['custom'] = __('Custom color'); |
|
| 640 | 640 | } |
| 641 | 641 | |
| 642 | 642 | $defaults = array( |
| 643 | 643 | 'type' => 'select', |
| 644 | - 'title' => __( 'Text color' ), |
|
| 644 | + 'title' => __('Text color'), |
|
| 645 | 645 | 'options' => $options, |
| 646 | 646 | 'default' => '', |
| 647 | 647 | 'desc_tip' => true, |
| 648 | - 'group' => __( "Typography" ) |
|
| 648 | + 'group' => __("Typography") |
|
| 649 | 649 | ); |
| 650 | 650 | |
| 651 | 651 | |
| 652 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 652 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 653 | 653 | |
| 654 | 654 | |
| 655 | 655 | return $input; |
| 656 | 656 | } |
| 657 | 657 | |
| 658 | -function sd_get_text_color_input_group( $type = 'text_color', $overwrite = array(), $overwrite_custom = array() ) { |
|
| 658 | +function sd_get_text_color_input_group($type = 'text_color', $overwrite = array(), $overwrite_custom = array()) { |
|
| 659 | 659 | $inputs = array(); |
| 660 | 660 | |
| 661 | - if ( $overwrite !== false ) { |
|
| 662 | - $inputs[ $type ] = sd_get_text_color_input( $type, $overwrite, true ); |
|
| 661 | + if ($overwrite !== false) { |
|
| 662 | + $inputs[$type] = sd_get_text_color_input($type, $overwrite, true); |
|
| 663 | 663 | } |
| 664 | 664 | |
| 665 | - if ( $overwrite_custom !== false ) { |
|
| 665 | + if ($overwrite_custom !== false) { |
|
| 666 | 666 | $custom = $type . "_custom"; |
| 667 | - $inputs[ $custom ] = sd_get_custom_color_input( $custom, $overwrite_custom, $type ); |
|
| 667 | + $inputs[$custom] = sd_get_custom_color_input($custom, $overwrite_custom, $type); |
|
| 668 | 668 | } |
| 669 | 669 | |
| 670 | 670 | |
@@ -679,24 +679,24 @@ discard block |
||
| 679 | 679 | * |
| 680 | 680 | * @return array |
| 681 | 681 | */ |
| 682 | -function sd_get_custom_color_input( $type = 'color_custom', $overwrite = array(), $parent_type = '' ) { |
|
| 682 | +function sd_get_custom_color_input($type = 'color_custom', $overwrite = array(), $parent_type = '') { |
|
| 683 | 683 | |
| 684 | 684 | |
| 685 | 685 | $defaults = array( |
| 686 | 686 | 'type' => 'color', |
| 687 | - 'title' => __( 'Custom color' ), |
|
| 687 | + 'title' => __('Custom color'), |
|
| 688 | 688 | 'default' => '', |
| 689 | 689 | 'placeholder' => '', |
| 690 | 690 | 'desc_tip' => true, |
| 691 | - 'group' => __( "Typography" ) |
|
| 691 | + 'group' => __("Typography") |
|
| 692 | 692 | ); |
| 693 | 693 | |
| 694 | - if ( $parent_type ) { |
|
| 694 | + if ($parent_type) { |
|
| 695 | 695 | $defaults['element_require'] = '[%' . $parent_type . '%]=="custom"'; |
| 696 | 696 | } |
| 697 | 697 | |
| 698 | 698 | |
| 699 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 699 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 700 | 700 | |
| 701 | 701 | |
| 702 | 702 | return $input; |
@@ -710,18 +710,18 @@ discard block |
||
| 710 | 710 | * |
| 711 | 711 | * @return array |
| 712 | 712 | */ |
| 713 | -function sd_get_col_input( $type = 'col', $overwrite = array() ) { |
|
| 713 | +function sd_get_col_input($type = 'col', $overwrite = array()) { |
|
| 714 | 714 | |
| 715 | 715 | $device_size = ''; |
| 716 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 717 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 716 | + if (!empty($overwrite['device_type'])) { |
|
| 717 | + if ($overwrite['device_type'] == 'Tablet') { |
|
| 718 | 718 | $device_size = '-md'; |
| 719 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 719 | + } elseif ($overwrite['device_type'] == 'Desktop') { |
|
| 720 | 720 | $device_size = '-lg'; |
| 721 | 721 | } |
| 722 | 722 | } |
| 723 | 723 | $options = array( |
| 724 | - '' => __( 'auto' ), |
|
| 724 | + '' => __('auto'), |
|
| 725 | 725 | '1' => '1/12', |
| 726 | 726 | '2' => '2/12', |
| 727 | 727 | '3' => '3/12', |
@@ -738,16 +738,16 @@ discard block |
||
| 738 | 738 | |
| 739 | 739 | $defaults = array( |
| 740 | 740 | 'type' => 'select', |
| 741 | - 'title' => __( 'Column width' ), |
|
| 741 | + 'title' => __('Column width'), |
|
| 742 | 742 | 'options' => $options, |
| 743 | 743 | 'default' => '', |
| 744 | 744 | 'desc_tip' => true, |
| 745 | - 'group' => __( "Container" ), |
|
| 745 | + 'group' => __("Container"), |
|
| 746 | 746 | 'element_require' => '[%container%]=="col"', |
| 747 | 747 | ); |
| 748 | 748 | |
| 749 | 749 | |
| 750 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 750 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 751 | 751 | |
| 752 | 752 | |
| 753 | 753 | return $input; |
@@ -761,18 +761,18 @@ discard block |
||
| 761 | 761 | * |
| 762 | 762 | * @return array |
| 763 | 763 | */ |
| 764 | -function sd_get_row_cols_input( $type = 'row_cols', $overwrite = array() ) { |
|
| 764 | +function sd_get_row_cols_input($type = 'row_cols', $overwrite = array()) { |
|
| 765 | 765 | |
| 766 | 766 | $device_size = ''; |
| 767 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 768 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 767 | + if (!empty($overwrite['device_type'])) { |
|
| 768 | + if ($overwrite['device_type'] == 'Tablet') { |
|
| 769 | 769 | $device_size = '-md'; |
| 770 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 770 | + } elseif ($overwrite['device_type'] == 'Desktop') { |
|
| 771 | 771 | $device_size = '-lg'; |
| 772 | 772 | } |
| 773 | 773 | } |
| 774 | 774 | $options = array( |
| 775 | - '' => __( 'auto' ), |
|
| 775 | + '' => __('auto'), |
|
| 776 | 776 | '1' => '1', |
| 777 | 777 | '2' => '2', |
| 778 | 778 | '3' => '3', |
@@ -783,16 +783,16 @@ discard block |
||
| 783 | 783 | |
| 784 | 784 | $defaults = array( |
| 785 | 785 | 'type' => 'select', |
| 786 | - 'title' => __( 'Row columns' ), |
|
| 786 | + 'title' => __('Row columns'), |
|
| 787 | 787 | 'options' => $options, |
| 788 | 788 | 'default' => '', |
| 789 | 789 | 'desc_tip' => true, |
| 790 | - 'group' => __( "Container" ), |
|
| 790 | + 'group' => __("Container"), |
|
| 791 | 791 | 'element_require' => '[%container%]=="row"', |
| 792 | 792 | ); |
| 793 | 793 | |
| 794 | 794 | |
| 795 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 795 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 796 | 796 | |
| 797 | 797 | |
| 798 | 798 | return $input; |
@@ -806,34 +806,34 @@ discard block |
||
| 806 | 806 | * |
| 807 | 807 | * @return array |
| 808 | 808 | */ |
| 809 | -function sd_get_text_align_input( $type = 'text_align', $overwrite = array() ) { |
|
| 809 | +function sd_get_text_align_input($type = 'text_align', $overwrite = array()) { |
|
| 810 | 810 | |
| 811 | 811 | $device_size = ''; |
| 812 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 813 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 812 | + if (!empty($overwrite['device_type'])) { |
|
| 813 | + if ($overwrite['device_type'] == 'Tablet') { |
|
| 814 | 814 | $device_size = '-md'; |
| 815 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 815 | + } elseif ($overwrite['device_type'] == 'Desktop') { |
|
| 816 | 816 | $device_size = '-lg'; |
| 817 | 817 | } |
| 818 | 818 | } |
| 819 | 819 | $options = array( |
| 820 | - '' => __( "Default" ), |
|
| 821 | - 'text' . $device_size . '-left' => __( "Left" ), |
|
| 822 | - 'text' . $device_size . '-right' => __( "Right" ), |
|
| 823 | - 'text' . $device_size . '-center' => __( "Center" ), |
|
| 820 | + '' => __("Default"), |
|
| 821 | + 'text' . $device_size . '-left' => __("Left"), |
|
| 822 | + 'text' . $device_size . '-right' => __("Right"), |
|
| 823 | + 'text' . $device_size . '-center' => __("Center"), |
|
| 824 | 824 | ); |
| 825 | 825 | |
| 826 | 826 | $defaults = array( |
| 827 | 827 | 'type' => 'select', |
| 828 | - 'title' => __( 'Text align' ), |
|
| 828 | + 'title' => __('Text align'), |
|
| 829 | 829 | 'options' => $options, |
| 830 | 830 | 'default' => '', |
| 831 | 831 | 'desc_tip' => true, |
| 832 | - 'group' => __( "Typography" ) |
|
| 832 | + 'group' => __("Typography") |
|
| 833 | 833 | ); |
| 834 | 834 | |
| 835 | 835 | |
| 836 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 836 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 837 | 837 | |
| 838 | 838 | |
| 839 | 839 | return $input; |
@@ -847,18 +847,18 @@ discard block |
||
| 847 | 847 | * |
| 848 | 848 | * @return array |
| 849 | 849 | */ |
| 850 | -function sd_get_display_input( $type = 'display', $overwrite = array() ) { |
|
| 850 | +function sd_get_display_input($type = 'display', $overwrite = array()) { |
|
| 851 | 851 | |
| 852 | 852 | $device_size = ''; |
| 853 | - if ( ! empty( $overwrite['device_type'] ) ) { |
|
| 854 | - if ( $overwrite['device_type'] == 'Tablet' ) { |
|
| 853 | + if (!empty($overwrite['device_type'])) { |
|
| 854 | + if ($overwrite['device_type'] == 'Tablet') { |
|
| 855 | 855 | $device_size = '-md'; |
| 856 | - } elseif ( $overwrite['device_type'] == 'Desktop' ) { |
|
| 856 | + } elseif ($overwrite['device_type'] == 'Desktop') { |
|
| 857 | 857 | $device_size = '-lg'; |
| 858 | 858 | } |
| 859 | 859 | } |
| 860 | 860 | $options = array( |
| 861 | - '' => __( "Default" ), |
|
| 861 | + '' => __("Default"), |
|
| 862 | 862 | 'd' . $device_size . '-none' => "none", |
| 863 | 863 | 'd' . $device_size . '-inline' => "inline", |
| 864 | 864 | 'd' . $device_size . '-inline-block' => "inline-block", |
@@ -872,15 +872,15 @@ discard block |
||
| 872 | 872 | |
| 873 | 873 | $defaults = array( |
| 874 | 874 | 'type' => 'select', |
| 875 | - 'title' => __( 'Display' ), |
|
| 875 | + 'title' => __('Display'), |
|
| 876 | 876 | 'options' => $options, |
| 877 | 877 | 'default' => '', |
| 878 | 878 | 'desc_tip' => true, |
| 879 | - 'group' => __( "Wrapper Styles" ) |
|
| 879 | + 'group' => __("Wrapper Styles") |
|
| 880 | 880 | ); |
| 881 | 881 | |
| 882 | 882 | |
| 883 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 883 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 884 | 884 | |
| 885 | 885 | |
| 886 | 886 | return $input; |
@@ -894,18 +894,18 @@ discard block |
||
| 894 | 894 | * |
| 895 | 895 | * @return array |
| 896 | 896 | */ |
| 897 | -function sd_get_text_justify_input( $type = 'text_justify', $overwrite = array() ) { |
|
| 897 | +function sd_get_text_justify_input($type = 'text_justify', $overwrite = array()) { |
|
| 898 | 898 | |
| 899 | 899 | $defaults = array( |
| 900 | 900 | 'type' => 'checkbox', |
| 901 | - 'title' => __( 'Text justify' ), |
|
| 901 | + 'title' => __('Text justify'), |
|
| 902 | 902 | 'default' => '', |
| 903 | 903 | 'desc_tip' => true, |
| 904 | - 'group' => __( "Typography" ) |
|
| 904 | + 'group' => __("Typography") |
|
| 905 | 905 | ); |
| 906 | 906 | |
| 907 | 907 | |
| 908 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 908 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 909 | 909 | |
| 910 | 910 | |
| 911 | 911 | return $input; |
@@ -920,52 +920,52 @@ discard block |
||
| 920 | 920 | * |
| 921 | 921 | * @return array |
| 922 | 922 | */ |
| 923 | -function sd_aui_colors( $include_branding = false, $include_outlines = false, $outline_button_only_text = false ) { |
|
| 923 | +function sd_aui_colors($include_branding = false, $include_outlines = false, $outline_button_only_text = false) { |
|
| 924 | 924 | $theme_colors = array(); |
| 925 | 925 | |
| 926 | - $theme_colors["primary"] = __( 'Primary' ); |
|
| 927 | - $theme_colors["secondary"] = __( 'Secondary' ); |
|
| 928 | - $theme_colors["success"] = __( 'Success' ); |
|
| 929 | - $theme_colors["danger"] = __( 'Danger' ); |
|
| 930 | - $theme_colors["warning"] = __( 'Warning' ); |
|
| 931 | - $theme_colors["info"] = __( 'Info' ); |
|
| 932 | - $theme_colors["light"] = __( 'Light' ); |
|
| 933 | - $theme_colors["dark"] = __( 'Dark' ); |
|
| 934 | - $theme_colors["white"] = __( 'White' ); |
|
| 935 | - $theme_colors["purple"] = __( 'Purple' ); |
|
| 936 | - $theme_colors["salmon"] = __( 'Salmon' ); |
|
| 937 | - $theme_colors["cyan"] = __( 'Cyan' ); |
|
| 938 | - $theme_colors["gray"] = __( 'Gray' ); |
|
| 939 | - $theme_colors["gray-dark"] = __( 'Gray dark' ); |
|
| 940 | - $theme_colors["indigo"] = __( 'Indigo' ); |
|
| 941 | - $theme_colors["orange"] = __( 'Orange' ); |
|
| 942 | - |
|
| 943 | - if ( $include_outlines ) { |
|
| 944 | - $button_only = $outline_button_only_text ? " " . __( "(button only)" ) : ''; |
|
| 945 | - $theme_colors["outline-primary"] = __( 'Primary outline' ) . $button_only; |
|
| 946 | - $theme_colors["outline-secondary"] = __( 'Secondary outline' ) . $button_only; |
|
| 947 | - $theme_colors["outline-success"] = __( 'Success outline' ) . $button_only; |
|
| 948 | - $theme_colors["outline-danger"] = __( 'Danger outline' ) . $button_only; |
|
| 949 | - $theme_colors["outline-warning"] = __( 'Warning outline' ) . $button_only; |
|
| 950 | - $theme_colors["outline-info"] = __( 'Info outline' ) . $button_only; |
|
| 951 | - $theme_colors["outline-light"] = __( 'Light outline' ) . $button_only; |
|
| 952 | - $theme_colors["outline-dark"] = __( 'Dark outline' ) . $button_only; |
|
| 953 | - $theme_colors["outline-white"] = __( 'White outline' ) . $button_only; |
|
| 954 | - $theme_colors["outline-purple"] = __( 'Purple outline' ) . $button_only; |
|
| 955 | - $theme_colors["outline-salmon"] = __( 'Salmon outline' ) . $button_only; |
|
| 956 | - $theme_colors["outline-cyan"] = __( 'Cyan outline' ) . $button_only; |
|
| 957 | - $theme_colors["outline-gray"] = __( 'Gray outline' ) . $button_only; |
|
| 958 | - $theme_colors["outline-gray-dark"] = __( 'Gray dark outline' ) . $button_only; |
|
| 959 | - $theme_colors["outline-indigo"] = __( 'Indigo outline' ) . $button_only; |
|
| 960 | - $theme_colors["outline-orange"] = __( 'Orange outline' ) . $button_only; |
|
| 961 | - } |
|
| 962 | - |
|
| 963 | - |
|
| 964 | - if ( $include_branding ) { |
|
| 926 | + $theme_colors["primary"] = __('Primary'); |
|
| 927 | + $theme_colors["secondary"] = __('Secondary'); |
|
| 928 | + $theme_colors["success"] = __('Success'); |
|
| 929 | + $theme_colors["danger"] = __('Danger'); |
|
| 930 | + $theme_colors["warning"] = __('Warning'); |
|
| 931 | + $theme_colors["info"] = __('Info'); |
|
| 932 | + $theme_colors["light"] = __('Light'); |
|
| 933 | + $theme_colors["dark"] = __('Dark'); |
|
| 934 | + $theme_colors["white"] = __('White'); |
|
| 935 | + $theme_colors["purple"] = __('Purple'); |
|
| 936 | + $theme_colors["salmon"] = __('Salmon'); |
|
| 937 | + $theme_colors["cyan"] = __('Cyan'); |
|
| 938 | + $theme_colors["gray"] = __('Gray'); |
|
| 939 | + $theme_colors["gray-dark"] = __('Gray dark'); |
|
| 940 | + $theme_colors["indigo"] = __('Indigo'); |
|
| 941 | + $theme_colors["orange"] = __('Orange'); |
|
| 942 | + |
|
| 943 | + if ($include_outlines) { |
|
| 944 | + $button_only = $outline_button_only_text ? " " . __("(button only)") : ''; |
|
| 945 | + $theme_colors["outline-primary"] = __('Primary outline') . $button_only; |
|
| 946 | + $theme_colors["outline-secondary"] = __('Secondary outline') . $button_only; |
|
| 947 | + $theme_colors["outline-success"] = __('Success outline') . $button_only; |
|
| 948 | + $theme_colors["outline-danger"] = __('Danger outline') . $button_only; |
|
| 949 | + $theme_colors["outline-warning"] = __('Warning outline') . $button_only; |
|
| 950 | + $theme_colors["outline-info"] = __('Info outline') . $button_only; |
|
| 951 | + $theme_colors["outline-light"] = __('Light outline') . $button_only; |
|
| 952 | + $theme_colors["outline-dark"] = __('Dark outline') . $button_only; |
|
| 953 | + $theme_colors["outline-white"] = __('White outline') . $button_only; |
|
| 954 | + $theme_colors["outline-purple"] = __('Purple outline') . $button_only; |
|
| 955 | + $theme_colors["outline-salmon"] = __('Salmon outline') . $button_only; |
|
| 956 | + $theme_colors["outline-cyan"] = __('Cyan outline') . $button_only; |
|
| 957 | + $theme_colors["outline-gray"] = __('Gray outline') . $button_only; |
|
| 958 | + $theme_colors["outline-gray-dark"] = __('Gray dark outline') . $button_only; |
|
| 959 | + $theme_colors["outline-indigo"] = __('Indigo outline') . $button_only; |
|
| 960 | + $theme_colors["outline-orange"] = __('Orange outline') . $button_only; |
|
| 961 | + } |
|
| 962 | + |
|
| 963 | + |
|
| 964 | + if ($include_branding) { |
|
| 965 | 965 | $theme_colors = $theme_colors + sd_aui_branding_colors(); |
| 966 | 966 | } |
| 967 | 967 | |
| 968 | - return apply_filters( 'sd_aui_colors', $theme_colors, $include_outlines, $include_branding ); |
|
| 968 | + return apply_filters('sd_aui_colors', $theme_colors, $include_outlines, $include_branding); |
|
| 969 | 969 | } |
| 970 | 970 | |
| 971 | 971 | /** |
@@ -975,17 +975,17 @@ discard block |
||
| 975 | 975 | */ |
| 976 | 976 | function sd_aui_branding_colors() { |
| 977 | 977 | return array( |
| 978 | - "facebook" => __( 'Facebook' ), |
|
| 979 | - "twitter" => __( 'Twitter' ), |
|
| 980 | - "instagram" => __( 'Instagram' ), |
|
| 981 | - "linkedin" => __( 'Linkedin' ), |
|
| 982 | - "flickr" => __( 'Flickr' ), |
|
| 983 | - "github" => __( 'GitHub' ), |
|
| 984 | - "youtube" => __( 'YouTube' ), |
|
| 985 | - "wordpress" => __( 'WordPress' ), |
|
| 986 | - "google" => __( 'Google' ), |
|
| 987 | - "yahoo" => __( 'Yahoo' ), |
|
| 988 | - "vkontakte" => __( 'Vkontakte' ), |
|
| 978 | + "facebook" => __('Facebook'), |
|
| 979 | + "twitter" => __('Twitter'), |
|
| 980 | + "instagram" => __('Instagram'), |
|
| 981 | + "linkedin" => __('Linkedin'), |
|
| 982 | + "flickr" => __('Flickr'), |
|
| 983 | + "github" => __('GitHub'), |
|
| 984 | + "youtube" => __('YouTube'), |
|
| 985 | + "wordpress" => __('WordPress'), |
|
| 986 | + "google" => __('Google'), |
|
| 987 | + "yahoo" => __('Yahoo'), |
|
| 988 | + "vkontakte" => __('Vkontakte'), |
|
| 989 | 989 | ); |
| 990 | 990 | } |
| 991 | 991 | |
@@ -998,11 +998,11 @@ discard block |
||
| 998 | 998 | * |
| 999 | 999 | * @return array |
| 1000 | 1000 | */ |
| 1001 | -function sd_get_container_class_input( $type = 'container', $overwrite = array() ) { |
|
| 1001 | +function sd_get_container_class_input($type = 'container', $overwrite = array()) { |
|
| 1002 | 1002 | |
| 1003 | 1003 | |
| 1004 | 1004 | $options = array( |
| 1005 | - "container" => __( 'container (default)' ), |
|
| 1005 | + "container" => __('container (default)'), |
|
| 1006 | 1006 | "container-sm" => 'container-sm', |
| 1007 | 1007 | "container-md" => 'container-md', |
| 1008 | 1008 | "container-lg" => 'container-lg', |
@@ -1021,15 +1021,15 @@ discard block |
||
| 1021 | 1021 | |
| 1022 | 1022 | $defaults = array( |
| 1023 | 1023 | 'type' => 'select', |
| 1024 | - 'title' => __( 'Type' ), |
|
| 1024 | + 'title' => __('Type'), |
|
| 1025 | 1025 | 'options' => $options, |
| 1026 | 1026 | 'default' => '', |
| 1027 | 1027 | 'desc_tip' => true, |
| 1028 | - 'group' => __( "Container" ) |
|
| 1028 | + 'group' => __("Container") |
|
| 1029 | 1029 | ); |
| 1030 | 1030 | |
| 1031 | 1031 | |
| 1032 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1032 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 1033 | 1033 | |
| 1034 | 1034 | |
| 1035 | 1035 | return $input; |
@@ -1043,11 +1043,11 @@ discard block |
||
| 1043 | 1043 | * |
| 1044 | 1044 | * @return array |
| 1045 | 1045 | */ |
| 1046 | -function sd_get_position_class_input( $type = 'position', $overwrite = array() ) { |
|
| 1046 | +function sd_get_position_class_input($type = 'position', $overwrite = array()) { |
|
| 1047 | 1047 | |
| 1048 | 1048 | |
| 1049 | 1049 | $options = array( |
| 1050 | - "" => __( 'Default' ), |
|
| 1050 | + "" => __('Default'), |
|
| 1051 | 1051 | "position-static" => 'static', |
| 1052 | 1052 | "position-relative" => 'relative', |
| 1053 | 1053 | "position-absolute" => 'absolute', |
@@ -1060,15 +1060,15 @@ discard block |
||
| 1060 | 1060 | |
| 1061 | 1061 | $defaults = array( |
| 1062 | 1062 | 'type' => 'select', |
| 1063 | - 'title' => __( 'Position' ), |
|
| 1063 | + 'title' => __('Position'), |
|
| 1064 | 1064 | 'options' => $options, |
| 1065 | 1065 | 'default' => '', |
| 1066 | 1066 | 'desc_tip' => true, |
| 1067 | - 'group' => __( "Wrapper Styles" ) |
|
| 1067 | + 'group' => __("Wrapper Styles") |
|
| 1068 | 1068 | ); |
| 1069 | 1069 | |
| 1070 | 1070 | |
| 1071 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1071 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 1072 | 1072 | |
| 1073 | 1073 | |
| 1074 | 1074 | return $input; |
@@ -1082,30 +1082,30 @@ discard block |
||
| 1082 | 1082 | * |
| 1083 | 1083 | * @return array |
| 1084 | 1084 | */ |
| 1085 | -function sd_get_sticky_offset_input( $type = 'top', $overwrite = array() ) { |
|
| 1085 | +function sd_get_sticky_offset_input($type = 'top', $overwrite = array()) { |
|
| 1086 | 1086 | |
| 1087 | 1087 | $defaults = array( |
| 1088 | 1088 | 'type' => 'number', |
| 1089 | - 'title' => __( 'Sticky offset' ), |
|
| 1089 | + 'title' => __('Sticky offset'), |
|
| 1090 | 1090 | //'desc' => __('Sticky offset'), |
| 1091 | 1091 | 'default' => '', |
| 1092 | 1092 | 'desc_tip' => true, |
| 1093 | - 'group' => __( "Wrapper Styles" ), |
|
| 1093 | + 'group' => __("Wrapper Styles"), |
|
| 1094 | 1094 | 'element_require' => '[%position%]=="sticky" || [%position%]=="sticky-top"' |
| 1095 | 1095 | ); |
| 1096 | 1096 | |
| 1097 | 1097 | // title |
| 1098 | - if ( $type == 'top' ) { |
|
| 1099 | - $defaults['title'] = __( 'Top offset' ); |
|
| 1098 | + if ($type == 'top') { |
|
| 1099 | + $defaults['title'] = __('Top offset'); |
|
| 1100 | 1100 | $defaults['icon'] = 'box-top'; |
| 1101 | 1101 | $defaults['row'] = array( |
| 1102 | - 'title' => __( 'Sticky offset' ), |
|
| 1102 | + 'title' => __('Sticky offset'), |
|
| 1103 | 1103 | 'key' => 'sticky-offset', |
| 1104 | 1104 | 'open' => true, |
| 1105 | 1105 | 'class' => 'text-center', |
| 1106 | 1106 | ); |
| 1107 | - } elseif ( $type == 'bottom' ) { |
|
| 1108 | - $defaults['title'] = __( 'Bottom offset' ); |
|
| 1107 | + } elseif ($type == 'bottom') { |
|
| 1108 | + $defaults['title'] = __('Bottom offset'); |
|
| 1109 | 1109 | $defaults['icon'] = 'box-bottom'; |
| 1110 | 1110 | $defaults['row'] = array( |
| 1111 | 1111 | 'key' => 'sticky-offset', |
@@ -1114,7 +1114,7 @@ discard block |
||
| 1114 | 1114 | } |
| 1115 | 1115 | |
| 1116 | 1116 | |
| 1117 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1117 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 1118 | 1118 | |
| 1119 | 1119 | |
| 1120 | 1120 | return $input; |
@@ -1128,11 +1128,11 @@ discard block |
||
| 1128 | 1128 | * |
| 1129 | 1129 | * @return array |
| 1130 | 1130 | */ |
| 1131 | -function sd_get_font_size_input( $type = 'font_size', $overwrite = array(), $has_custom = false ) { |
|
| 1131 | +function sd_get_font_size_input($type = 'font_size', $overwrite = array(), $has_custom = false) { |
|
| 1132 | 1132 | |
| 1133 | 1133 | |
| 1134 | 1134 | $options = array( |
| 1135 | - "" => __( 'Inherit from parent' ), |
|
| 1135 | + "" => __('Inherit from parent'), |
|
| 1136 | 1136 | "h6" => 'h6', |
| 1137 | 1137 | "h5" => 'h5', |
| 1138 | 1138 | "h4" => 'h4', |
@@ -1145,21 +1145,21 @@ discard block |
||
| 1145 | 1145 | "display-4" => "display-4", |
| 1146 | 1146 | ); |
| 1147 | 1147 | |
| 1148 | - if ( $has_custom ) { |
|
| 1149 | - $options['custom'] = __( 'Custom size' ); |
|
| 1148 | + if ($has_custom) { |
|
| 1149 | + $options['custom'] = __('Custom size'); |
|
| 1150 | 1150 | } |
| 1151 | 1151 | |
| 1152 | 1152 | $defaults = array( |
| 1153 | 1153 | 'type' => 'select', |
| 1154 | - 'title' => __( 'Font size' ), |
|
| 1154 | + 'title' => __('Font size'), |
|
| 1155 | 1155 | 'options' => $options, |
| 1156 | 1156 | 'default' => '', |
| 1157 | 1157 | 'desc_tip' => true, |
| 1158 | - 'group' => __( "Typography" ) |
|
| 1158 | + 'group' => __("Typography") |
|
| 1159 | 1159 | ); |
| 1160 | 1160 | |
| 1161 | 1161 | |
| 1162 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1162 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 1163 | 1163 | |
| 1164 | 1164 | |
| 1165 | 1165 | return $input; |
@@ -1173,12 +1173,12 @@ discard block |
||
| 1173 | 1173 | * |
| 1174 | 1174 | * @return array |
| 1175 | 1175 | */ |
| 1176 | -function sd_get_font_custom_size_input( $type = 'font_size_custom', $overwrite = array(), $parent_type = '' ) { |
|
| 1176 | +function sd_get_font_custom_size_input($type = 'font_size_custom', $overwrite = array(), $parent_type = '') { |
|
| 1177 | 1177 | |
| 1178 | 1178 | |
| 1179 | 1179 | $defaults = array( |
| 1180 | 1180 | 'type' => 'number', |
| 1181 | - 'title' => __( 'Font size (rem)' ), |
|
| 1181 | + 'title' => __('Font size (rem)'), |
|
| 1182 | 1182 | 'default' => '', |
| 1183 | 1183 | 'placeholder' => '1.25', |
| 1184 | 1184 | 'custom_attributes' => array( |
@@ -1187,15 +1187,15 @@ discard block |
||
| 1187 | 1187 | 'max' => '100', |
| 1188 | 1188 | ), |
| 1189 | 1189 | 'desc_tip' => true, |
| 1190 | - 'group' => __( "Typography" ) |
|
| 1190 | + 'group' => __("Typography") |
|
| 1191 | 1191 | ); |
| 1192 | 1192 | |
| 1193 | - if ( $parent_type ) { |
|
| 1193 | + if ($parent_type) { |
|
| 1194 | 1194 | $defaults['element_require'] = '[%' . $parent_type . '%]=="custom"'; |
| 1195 | 1195 | } |
| 1196 | 1196 | |
| 1197 | 1197 | |
| 1198 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1198 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 1199 | 1199 | |
| 1200 | 1200 | |
| 1201 | 1201 | return $input; |
@@ -1209,18 +1209,18 @@ discard block |
||
| 1209 | 1209 | * |
| 1210 | 1210 | * @return array |
| 1211 | 1211 | */ |
| 1212 | -function sd_get_font_size_input_group( $type = 'font_size', $overwrite = array(), $overwrite_custom = array() ) { |
|
| 1212 | +function sd_get_font_size_input_group($type = 'font_size', $overwrite = array(), $overwrite_custom = array()) { |
|
| 1213 | 1213 | |
| 1214 | 1214 | |
| 1215 | 1215 | $inputs = array(); |
| 1216 | 1216 | |
| 1217 | - if ( $overwrite !== false ) { |
|
| 1218 | - $inputs[ $type ] = sd_get_font_size_input( $type, $overwrite, true ); |
|
| 1217 | + if ($overwrite !== false) { |
|
| 1218 | + $inputs[$type] = sd_get_font_size_input($type, $overwrite, true); |
|
| 1219 | 1219 | } |
| 1220 | 1220 | |
| 1221 | - if ( $overwrite_custom !== false ) { |
|
| 1221 | + if ($overwrite_custom !== false) { |
|
| 1222 | 1222 | $custom = $type . "_custom"; |
| 1223 | - $inputs[ $custom ] = sd_get_font_custom_size_input( $custom, $overwrite_custom, $type ); |
|
| 1223 | + $inputs[$custom] = sd_get_font_custom_size_input($custom, $overwrite_custom, $type); |
|
| 1224 | 1224 | } |
| 1225 | 1225 | |
| 1226 | 1226 | |
@@ -1235,11 +1235,11 @@ discard block |
||
| 1235 | 1235 | * |
| 1236 | 1236 | * @return array |
| 1237 | 1237 | */ |
| 1238 | -function sd_get_font_weight_input( $type = 'font_weight', $overwrite = array() ) { |
|
| 1238 | +function sd_get_font_weight_input($type = 'font_weight', $overwrite = array()) { |
|
| 1239 | 1239 | |
| 1240 | 1240 | |
| 1241 | 1241 | $options = array( |
| 1242 | - "" => __( 'Inherit' ), |
|
| 1242 | + "" => __('Inherit'), |
|
| 1243 | 1243 | "font-weight-bold" => 'bold', |
| 1244 | 1244 | "font-weight-bolder" => 'bolder', |
| 1245 | 1245 | "font-weight-normal" => 'normal', |
@@ -1255,15 +1255,15 @@ discard block |
||
| 1255 | 1255 | |
| 1256 | 1256 | $defaults = array( |
| 1257 | 1257 | 'type' => 'select', |
| 1258 | - 'title' => __( 'Appearance' ), |
|
| 1258 | + 'title' => __('Appearance'), |
|
| 1259 | 1259 | 'options' => $options, |
| 1260 | 1260 | 'default' => '', |
| 1261 | 1261 | 'desc_tip' => true, |
| 1262 | - 'group' => __( "Typography" ) |
|
| 1262 | + 'group' => __("Typography") |
|
| 1263 | 1263 | ); |
| 1264 | 1264 | |
| 1265 | 1265 | |
| 1266 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1266 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 1267 | 1267 | |
| 1268 | 1268 | |
| 1269 | 1269 | return $input; |
@@ -1277,27 +1277,27 @@ discard block |
||
| 1277 | 1277 | * |
| 1278 | 1278 | * @return array |
| 1279 | 1279 | */ |
| 1280 | -function sd_get_font_case_input( $type = 'font_weight', $overwrite = array() ) { |
|
| 1280 | +function sd_get_font_case_input($type = 'font_weight', $overwrite = array()) { |
|
| 1281 | 1281 | |
| 1282 | 1282 | |
| 1283 | 1283 | $options = array( |
| 1284 | - "" => __( 'Default' ), |
|
| 1285 | - "text-lowercase" => __( 'lowercase' ), |
|
| 1286 | - "text-uppercase" => __( 'UPPERCASE' ), |
|
| 1287 | - "text-capitalize" => __( 'Capitalize' ), |
|
| 1284 | + "" => __('Default'), |
|
| 1285 | + "text-lowercase" => __('lowercase'), |
|
| 1286 | + "text-uppercase" => __('UPPERCASE'), |
|
| 1287 | + "text-capitalize" => __('Capitalize'), |
|
| 1288 | 1288 | ); |
| 1289 | 1289 | |
| 1290 | 1290 | $defaults = array( |
| 1291 | 1291 | 'type' => 'select', |
| 1292 | - 'title' => __( 'Letter case' ), |
|
| 1292 | + 'title' => __('Letter case'), |
|
| 1293 | 1293 | 'options' => $options, |
| 1294 | 1294 | 'default' => '', |
| 1295 | 1295 | 'desc_tip' => true, |
| 1296 | - 'group' => __( "Typography" ) |
|
| 1296 | + 'group' => __("Typography") |
|
| 1297 | 1297 | ); |
| 1298 | 1298 | |
| 1299 | 1299 | |
| 1300 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1300 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 1301 | 1301 | |
| 1302 | 1302 | |
| 1303 | 1303 | return $input; |
@@ -1312,24 +1312,24 @@ discard block |
||
| 1312 | 1312 | * A helper function for font size |
| 1313 | 1313 | * |
| 1314 | 1314 | */ |
| 1315 | -function sd_get_font_italic_input( $type = 'font_italic', $overwrite = array() ) { |
|
| 1315 | +function sd_get_font_italic_input($type = 'font_italic', $overwrite = array()) { |
|
| 1316 | 1316 | |
| 1317 | 1317 | |
| 1318 | 1318 | $options = array( |
| 1319 | - "" => __( 'No' ), |
|
| 1320 | - "font-italic" => __( 'Yes' ) |
|
| 1319 | + "" => __('No'), |
|
| 1320 | + "font-italic" => __('Yes') |
|
| 1321 | 1321 | ); |
| 1322 | 1322 | |
| 1323 | 1323 | $defaults = array( |
| 1324 | 1324 | 'type' => 'select', |
| 1325 | - 'title' => __( 'Font italic' ), |
|
| 1325 | + 'title' => __('Font italic'), |
|
| 1326 | 1326 | 'options' => $options, |
| 1327 | 1327 | 'default' => '', |
| 1328 | 1328 | 'desc_tip' => true, |
| 1329 | - 'group' => __( "Typography" ) |
|
| 1329 | + 'group' => __("Typography") |
|
| 1330 | 1330 | ); |
| 1331 | 1331 | |
| 1332 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1332 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 1333 | 1333 | |
| 1334 | 1334 | |
| 1335 | 1335 | return $input; |
@@ -1343,19 +1343,19 @@ discard block |
||
| 1343 | 1343 | * |
| 1344 | 1344 | * @return array |
| 1345 | 1345 | */ |
| 1346 | -function sd_get_anchor_input( $type = 'anchor', $overwrite = array() ) { |
|
| 1346 | +function sd_get_anchor_input($type = 'anchor', $overwrite = array()) { |
|
| 1347 | 1347 | |
| 1348 | 1348 | |
| 1349 | 1349 | $defaults = array( |
| 1350 | 1350 | 'type' => 'text', |
| 1351 | - 'title' => __( 'HTML anchor' ), |
|
| 1352 | - 'desc' => __( 'Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.' ), |
|
| 1351 | + 'title' => __('HTML anchor'), |
|
| 1352 | + 'desc' => __('Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.'), |
|
| 1353 | 1353 | 'default' => '', |
| 1354 | 1354 | 'desc_tip' => true, |
| 1355 | - 'group' => __( "Advanced" ) |
|
| 1355 | + 'group' => __("Advanced") |
|
| 1356 | 1356 | ); |
| 1357 | 1357 | |
| 1358 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1358 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 1359 | 1359 | |
| 1360 | 1360 | |
| 1361 | 1361 | return $input; |
@@ -1369,18 +1369,18 @@ discard block |
||
| 1369 | 1369 | * |
| 1370 | 1370 | * @return array |
| 1371 | 1371 | */ |
| 1372 | -function sd_get_class_input( $type = 'css_class', $overwrite = array() ) { |
|
| 1372 | +function sd_get_class_input($type = 'css_class', $overwrite = array()) { |
|
| 1373 | 1373 | |
| 1374 | 1374 | $defaults = array( |
| 1375 | 1375 | 'type' => 'text', |
| 1376 | - 'title' => __( 'Additional CSS class(es)' ), |
|
| 1377 | - 'desc' => __( 'Separate multiple classes with spaces.' ), |
|
| 1376 | + 'title' => __('Additional CSS class(es)'), |
|
| 1377 | + 'desc' => __('Separate multiple classes with spaces.'), |
|
| 1378 | 1378 | 'default' => '', |
| 1379 | 1379 | 'desc_tip' => true, |
| 1380 | - 'group' => __( "Advanced" ) |
|
| 1380 | + 'group' => __("Advanced") |
|
| 1381 | 1381 | ); |
| 1382 | 1382 | |
| 1383 | - $input = wp_parse_args( $overwrite, $defaults ); |
|
| 1383 | + $input = wp_parse_args($overwrite, $defaults); |
|
| 1384 | 1384 | |
| 1385 | 1385 | |
| 1386 | 1386 | return $input; |
@@ -1395,236 +1395,236 @@ discard block |
||
| 1395 | 1395 | * @return string |
| 1396 | 1396 | * @todo find best way to use px- py- or general p- |
| 1397 | 1397 | */ |
| 1398 | -function sd_build_aui_class( $args ) { |
|
| 1398 | +function sd_build_aui_class($args) { |
|
| 1399 | 1399 | |
| 1400 | 1400 | $classes = array(); |
| 1401 | 1401 | |
| 1402 | 1402 | // margins. |
| 1403 | - if ( isset( $args['mt'] ) && $args['mt'] !== '' ) { |
|
| 1404 | - $classes[] = "mt-" . sanitize_html_class( $args['mt'] ); |
|
| 1403 | + if (isset($args['mt']) && $args['mt'] !== '') { |
|
| 1404 | + $classes[] = "mt-" . sanitize_html_class($args['mt']); |
|
| 1405 | 1405 | $mt = $args['mt']; |
| 1406 | 1406 | } else { |
| 1407 | 1407 | $mt = null; |
| 1408 | 1408 | } |
| 1409 | - if ( isset( $args['mr'] ) && $args['mr'] !== '' ) { |
|
| 1410 | - $classes[] = "mr-" . sanitize_html_class( $args['mr'] ); |
|
| 1409 | + if (isset($args['mr']) && $args['mr'] !== '') { |
|
| 1410 | + $classes[] = "mr-" . sanitize_html_class($args['mr']); |
|
| 1411 | 1411 | $mr = $args['mr']; |
| 1412 | 1412 | } else { |
| 1413 | 1413 | $mr = null; |
| 1414 | 1414 | } |
| 1415 | - if ( isset( $args['mb'] ) && $args['mb'] !== '' ) { |
|
| 1416 | - $classes[] = "mb-" . sanitize_html_class( $args['mb'] ); |
|
| 1415 | + if (isset($args['mb']) && $args['mb'] !== '') { |
|
| 1416 | + $classes[] = "mb-" . sanitize_html_class($args['mb']); |
|
| 1417 | 1417 | $mb = $args['mb']; |
| 1418 | 1418 | } else { |
| 1419 | 1419 | $mb = null; |
| 1420 | 1420 | } |
| 1421 | - if ( isset( $args['ml'] ) && $args['ml'] !== '' ) { |
|
| 1422 | - $classes[] = "ml-" . sanitize_html_class( $args['ml'] ); |
|
| 1421 | + if (isset($args['ml']) && $args['ml'] !== '') { |
|
| 1422 | + $classes[] = "ml-" . sanitize_html_class($args['ml']); |
|
| 1423 | 1423 | $ml = $args['ml']; |
| 1424 | 1424 | } else { |
| 1425 | 1425 | $ml = null; |
| 1426 | 1426 | } |
| 1427 | 1427 | |
| 1428 | 1428 | // margins tablet. |
| 1429 | - if ( isset( $args['mt_md'] ) && $args['mt_md'] !== '' ) { |
|
| 1430 | - $classes[] = "mt-md-" . sanitize_html_class( $args['mt_md'] ); |
|
| 1429 | + if (isset($args['mt_md']) && $args['mt_md'] !== '') { |
|
| 1430 | + $classes[] = "mt-md-" . sanitize_html_class($args['mt_md']); |
|
| 1431 | 1431 | $mt_md = $args['mt_md']; |
| 1432 | 1432 | } else { |
| 1433 | 1433 | $mt_md = null; |
| 1434 | 1434 | } |
| 1435 | - if ( isset( $args['mr_md'] ) && $args['mr_md'] !== '' ) { |
|
| 1436 | - $classes[] = "mr-md-" . sanitize_html_class( $args['mr_md'] ); |
|
| 1435 | + if (isset($args['mr_md']) && $args['mr_md'] !== '') { |
|
| 1436 | + $classes[] = "mr-md-" . sanitize_html_class($args['mr_md']); |
|
| 1437 | 1437 | $mt_md = $args['mr_md']; |
| 1438 | 1438 | } else { |
| 1439 | 1439 | $mr_md = null; |
| 1440 | 1440 | } |
| 1441 | - if ( isset( $args['mb_md'] ) && $args['mb_md'] !== '' ) { |
|
| 1442 | - $classes[] = "mb-md-" . sanitize_html_class( $args['mb_md'] ); |
|
| 1441 | + if (isset($args['mb_md']) && $args['mb_md'] !== '') { |
|
| 1442 | + $classes[] = "mb-md-" . sanitize_html_class($args['mb_md']); |
|
| 1443 | 1443 | $mt_md = $args['mb_md']; |
| 1444 | 1444 | } else { |
| 1445 | 1445 | $mb_md = null; |
| 1446 | 1446 | } |
| 1447 | - if ( isset( $args['ml_md'] ) && $args['ml_md'] !== '' ) { |
|
| 1448 | - $classes[] = "ml-md-" . sanitize_html_class( $args['ml_md'] ); |
|
| 1447 | + if (isset($args['ml_md']) && $args['ml_md'] !== '') { |
|
| 1448 | + $classes[] = "ml-md-" . sanitize_html_class($args['ml_md']); |
|
| 1449 | 1449 | $mt_md = $args['ml_md']; |
| 1450 | 1450 | } else { |
| 1451 | 1451 | $ml_md = null; |
| 1452 | 1452 | } |
| 1453 | 1453 | |
| 1454 | 1454 | // margins desktop. |
| 1455 | - if ( isset( $args['mt_lg'] ) && $args['mt_lg'] !== '' ) { |
|
| 1456 | - if ( $mt == null && $mt_md == null ) { |
|
| 1457 | - $classes[] = "mt-" . sanitize_html_class( $args['mt_lg'] ); |
|
| 1455 | + if (isset($args['mt_lg']) && $args['mt_lg'] !== '') { |
|
| 1456 | + if ($mt == null && $mt_md == null) { |
|
| 1457 | + $classes[] = "mt-" . sanitize_html_class($args['mt_lg']); |
|
| 1458 | 1458 | } else { |
| 1459 | - $classes[] = "mt-lg-" . sanitize_html_class( $args['mt_lg'] ); |
|
| 1459 | + $classes[] = "mt-lg-" . sanitize_html_class($args['mt_lg']); |
|
| 1460 | 1460 | } |
| 1461 | 1461 | } |
| 1462 | - if ( isset( $args['mr_lg'] ) && $args['mr_lg'] !== '' ) { |
|
| 1463 | - if ( $mr == null && $mr_md == null ) { |
|
| 1464 | - $classes[] = "mr-" . sanitize_html_class( $args['mr_lg'] ); |
|
| 1462 | + if (isset($args['mr_lg']) && $args['mr_lg'] !== '') { |
|
| 1463 | + if ($mr == null && $mr_md == null) { |
|
| 1464 | + $classes[] = "mr-" . sanitize_html_class($args['mr_lg']); |
|
| 1465 | 1465 | } else { |
| 1466 | - $classes[] = "mr-lg-" . sanitize_html_class( $args['mr_lg'] ); |
|
| 1466 | + $classes[] = "mr-lg-" . sanitize_html_class($args['mr_lg']); |
|
| 1467 | 1467 | } |
| 1468 | 1468 | } |
| 1469 | - if ( isset( $args['mb_lg'] ) && $args['mb_lg'] !== '' ) { |
|
| 1470 | - if ( $mb == null && $mb_md == null ) { |
|
| 1471 | - $classes[] = "mb-" . sanitize_html_class( $args['mb_lg'] ); |
|
| 1469 | + if (isset($args['mb_lg']) && $args['mb_lg'] !== '') { |
|
| 1470 | + if ($mb == null && $mb_md == null) { |
|
| 1471 | + $classes[] = "mb-" . sanitize_html_class($args['mb_lg']); |
|
| 1472 | 1472 | } else { |
| 1473 | - $classes[] = "mb-lg-" . sanitize_html_class( $args['mb_lg'] ); |
|
| 1473 | + $classes[] = "mb-lg-" . sanitize_html_class($args['mb_lg']); |
|
| 1474 | 1474 | } |
| 1475 | 1475 | } |
| 1476 | - if ( isset( $args['ml_lg'] ) && $args['ml_lg'] !== '' ) { |
|
| 1477 | - if ( $ml == null && $ml_md == null ) { |
|
| 1478 | - $classes[] = "ml-" . sanitize_html_class( $args['ml_lg'] ); |
|
| 1476 | + if (isset($args['ml_lg']) && $args['ml_lg'] !== '') { |
|
| 1477 | + if ($ml == null && $ml_md == null) { |
|
| 1478 | + $classes[] = "ml-" . sanitize_html_class($args['ml_lg']); |
|
| 1479 | 1479 | } else { |
| 1480 | - $classes[] = "ml-lg-" . sanitize_html_class( $args['ml_lg'] ); |
|
| 1480 | + $classes[] = "ml-lg-" . sanitize_html_class($args['ml_lg']); |
|
| 1481 | 1481 | } |
| 1482 | 1482 | } |
| 1483 | 1483 | |
| 1484 | 1484 | |
| 1485 | 1485 | // padding. |
| 1486 | - if ( isset( $args['pt'] ) && $args['pt'] !== '' ) { |
|
| 1487 | - $classes[] = "pt-" . sanitize_html_class( $args['pt'] ); |
|
| 1486 | + if (isset($args['pt']) && $args['pt'] !== '') { |
|
| 1487 | + $classes[] = "pt-" . sanitize_html_class($args['pt']); |
|
| 1488 | 1488 | $pt = $args['pt']; |
| 1489 | 1489 | } else { |
| 1490 | 1490 | $pt = null; |
| 1491 | 1491 | } |
| 1492 | - if ( isset( $args['pr'] ) && $args['pr'] !== '' ) { |
|
| 1493 | - $classes[] = "pr-" . sanitize_html_class( $args['pr'] ); |
|
| 1492 | + if (isset($args['pr']) && $args['pr'] !== '') { |
|
| 1493 | + $classes[] = "pr-" . sanitize_html_class($args['pr']); |
|
| 1494 | 1494 | $pr = $args['pr']; |
| 1495 | 1495 | } else { |
| 1496 | 1496 | $pr = null; |
| 1497 | 1497 | } |
| 1498 | - if ( isset( $args['pb'] ) && $args['pb'] !== '' ) { |
|
| 1499 | - $classes[] = "pb-" . sanitize_html_class( $args['pb'] ); |
|
| 1498 | + if (isset($args['pb']) && $args['pb'] !== '') { |
|
| 1499 | + $classes[] = "pb-" . sanitize_html_class($args['pb']); |
|
| 1500 | 1500 | $pb = $args['pb']; |
| 1501 | 1501 | } else { |
| 1502 | 1502 | $pb = null; |
| 1503 | 1503 | } |
| 1504 | - if ( isset( $args['pl'] ) && $args['pl'] !== '' ) { |
|
| 1505 | - $classes[] = "pl-" . sanitize_html_class( $args['pl'] ); |
|
| 1504 | + if (isset($args['pl']) && $args['pl'] !== '') { |
|
| 1505 | + $classes[] = "pl-" . sanitize_html_class($args['pl']); |
|
| 1506 | 1506 | $pl = $args['pl']; |
| 1507 | 1507 | } else { |
| 1508 | 1508 | $pl = null; |
| 1509 | 1509 | } |
| 1510 | 1510 | |
| 1511 | 1511 | // padding tablet. |
| 1512 | - if ( isset( $args['pt_md'] ) && $args['pt_md'] !== '' ) { |
|
| 1513 | - $classes[] = "pt-md-" . sanitize_html_class( $args['pt_md'] ); |
|
| 1512 | + if (isset($args['pt_md']) && $args['pt_md'] !== '') { |
|
| 1513 | + $classes[] = "pt-md-" . sanitize_html_class($args['pt_md']); |
|
| 1514 | 1514 | $pt_md = $args['pt_md']; |
| 1515 | 1515 | } else { |
| 1516 | 1516 | $pt_md = null; |
| 1517 | 1517 | } |
| 1518 | - if ( isset( $args['pr_md'] ) && $args['pr_md'] !== '' ) { |
|
| 1519 | - $classes[] = "pr-md-" . sanitize_html_class( $args['pr_md'] ); |
|
| 1518 | + if (isset($args['pr_md']) && $args['pr_md'] !== '') { |
|
| 1519 | + $classes[] = "pr-md-" . sanitize_html_class($args['pr_md']); |
|
| 1520 | 1520 | $pt_md = $args['pr_md']; |
| 1521 | 1521 | } else { |
| 1522 | 1522 | $pr_md = null; |
| 1523 | 1523 | } |
| 1524 | - if ( isset( $args['pb_md'] ) && $args['pb_md'] !== '' ) { |
|
| 1525 | - $classes[] = "pb-md-" . sanitize_html_class( $args['pb_md'] ); |
|
| 1524 | + if (isset($args['pb_md']) && $args['pb_md'] !== '') { |
|
| 1525 | + $classes[] = "pb-md-" . sanitize_html_class($args['pb_md']); |
|
| 1526 | 1526 | $pt_md = $args['pb_md']; |
| 1527 | 1527 | } else { |
| 1528 | 1528 | $pb_md = null; |
| 1529 | 1529 | } |
| 1530 | - if ( isset( $args['pl_md'] ) && $args['pl_md'] !== '' ) { |
|
| 1531 | - $classes[] = "pl-md-" . sanitize_html_class( $args['pl_md'] ); |
|
| 1530 | + if (isset($args['pl_md']) && $args['pl_md'] !== '') { |
|
| 1531 | + $classes[] = "pl-md-" . sanitize_html_class($args['pl_md']); |
|
| 1532 | 1532 | $pt_md = $args['pl_md']; |
| 1533 | 1533 | } else { |
| 1534 | 1534 | $pl_md = null; |
| 1535 | 1535 | } |
| 1536 | 1536 | |
| 1537 | 1537 | // padding desktop. |
| 1538 | - if ( isset( $args['pt_lg'] ) && $args['pt_lg'] !== '' ) { |
|
| 1539 | - if ( $pt == null && $pt_md == null ) { |
|
| 1540 | - $classes[] = "pt-" . sanitize_html_class( $args['pt_lg'] ); |
|
| 1538 | + if (isset($args['pt_lg']) && $args['pt_lg'] !== '') { |
|
| 1539 | + if ($pt == null && $pt_md == null) { |
|
| 1540 | + $classes[] = "pt-" . sanitize_html_class($args['pt_lg']); |
|
| 1541 | 1541 | } else { |
| 1542 | - $classes[] = "pt-lg-" . sanitize_html_class( $args['pt_lg'] ); |
|
| 1542 | + $classes[] = "pt-lg-" . sanitize_html_class($args['pt_lg']); |
|
| 1543 | 1543 | } |
| 1544 | 1544 | } |
| 1545 | - if ( isset( $args['pr_lg'] ) && $args['pr_lg'] !== '' ) { |
|
| 1546 | - if ( $pr == null && $pr_md == null ) { |
|
| 1547 | - $classes[] = "pr-" . sanitize_html_class( $args['pr_lg'] ); |
|
| 1545 | + if (isset($args['pr_lg']) && $args['pr_lg'] !== '') { |
|
| 1546 | + if ($pr == null && $pr_md == null) { |
|
| 1547 | + $classes[] = "pr-" . sanitize_html_class($args['pr_lg']); |
|
| 1548 | 1548 | } else { |
| 1549 | - $classes[] = "pr-lg-" . sanitize_html_class( $args['pr_lg'] ); |
|
| 1549 | + $classes[] = "pr-lg-" . sanitize_html_class($args['pr_lg']); |
|
| 1550 | 1550 | } |
| 1551 | 1551 | } |
| 1552 | - if ( isset( $args['pb_lg'] ) && $args['pb_lg'] !== '' ) { |
|
| 1553 | - if ( $pb == null && $pb_md == null ) { |
|
| 1554 | - $classes[] = "pb-" . sanitize_html_class( $args['pb_lg'] ); |
|
| 1552 | + if (isset($args['pb_lg']) && $args['pb_lg'] !== '') { |
|
| 1553 | + if ($pb == null && $pb_md == null) { |
|
| 1554 | + $classes[] = "pb-" . sanitize_html_class($args['pb_lg']); |
|
| 1555 | 1555 | } else { |
| 1556 | - $classes[] = "pb-lg-" . sanitize_html_class( $args['pb_lg'] ); |
|
| 1556 | + $classes[] = "pb-lg-" . sanitize_html_class($args['pb_lg']); |
|
| 1557 | 1557 | } |
| 1558 | 1558 | } |
| 1559 | - if ( isset( $args['pl_lg'] ) && $args['pl_lg'] !== '' ) { |
|
| 1560 | - if ( $pl == null && $pl_md == null ) { |
|
| 1561 | - $classes[] = "pl-" . sanitize_html_class( $args['pl_lg'] ); |
|
| 1559 | + if (isset($args['pl_lg']) && $args['pl_lg'] !== '') { |
|
| 1560 | + if ($pl == null && $pl_md == null) { |
|
| 1561 | + $classes[] = "pl-" . sanitize_html_class($args['pl_lg']); |
|
| 1562 | 1562 | } else { |
| 1563 | - $classes[] = "pl-lg-" . sanitize_html_class( $args['pl_lg'] ); |
|
| 1563 | + $classes[] = "pl-lg-" . sanitize_html_class($args['pl_lg']); |
|
| 1564 | 1564 | } |
| 1565 | 1565 | } |
| 1566 | 1566 | |
| 1567 | 1567 | // row cols, mobile, tablet, desktop |
| 1568 | - if ( ! empty( $args['row_cols'] ) && $args['row_cols'] !== '' ) { |
|
| 1569 | - $classes[] = sanitize_html_class( "row-cols-" . $args['row_cols'] ); |
|
| 1568 | + if (!empty($args['row_cols']) && $args['row_cols'] !== '') { |
|
| 1569 | + $classes[] = sanitize_html_class("row-cols-" . $args['row_cols']); |
|
| 1570 | 1570 | $row_cols = $args['row_cols']; |
| 1571 | 1571 | } else { |
| 1572 | 1572 | $row_cols = null; |
| 1573 | 1573 | } |
| 1574 | - if ( ! empty( $args['row_cols_md'] ) && $args['row_cols_md'] !== '' ) { |
|
| 1575 | - $classes[] = sanitize_html_class( "row-cols-md-" . $args['row_cols_md'] ); |
|
| 1574 | + if (!empty($args['row_cols_md']) && $args['row_cols_md'] !== '') { |
|
| 1575 | + $classes[] = sanitize_html_class("row-cols-md-" . $args['row_cols_md']); |
|
| 1576 | 1576 | $row_cols_md = $args['row_cols_md']; |
| 1577 | 1577 | } else { |
| 1578 | 1578 | $row_cols_md = null; |
| 1579 | 1579 | } |
| 1580 | - if ( ! empty( $args['row_cols_lg'] ) && $args['row_cols_lg'] !== '' ) { |
|
| 1581 | - if ( $row_cols == null && $row_cols_md == null ) { |
|
| 1582 | - $classes[] = sanitize_html_class( "row-cols-" . $args['row_cols_lg'] ); |
|
| 1580 | + if (!empty($args['row_cols_lg']) && $args['row_cols_lg'] !== '') { |
|
| 1581 | + if ($row_cols == null && $row_cols_md == null) { |
|
| 1582 | + $classes[] = sanitize_html_class("row-cols-" . $args['row_cols_lg']); |
|
| 1583 | 1583 | } else { |
| 1584 | - $classes[] = sanitize_html_class( "row-cols-lg-" . $args['row_cols_lg'] ); |
|
| 1584 | + $classes[] = sanitize_html_class("row-cols-lg-" . $args['row_cols_lg']); |
|
| 1585 | 1585 | } |
| 1586 | 1586 | } |
| 1587 | 1587 | |
| 1588 | 1588 | // columns , mobile, tablet, desktop |
| 1589 | - if ( ! empty( $args['col'] ) && $args['col'] !== '' ) { |
|
| 1590 | - $classes[] = sanitize_html_class( "col-" . $args['col'] ); |
|
| 1589 | + if (!empty($args['col']) && $args['col'] !== '') { |
|
| 1590 | + $classes[] = sanitize_html_class("col-" . $args['col']); |
|
| 1591 | 1591 | $col = $args['col']; |
| 1592 | 1592 | } else { |
| 1593 | 1593 | $col = null; |
| 1594 | 1594 | } |
| 1595 | - if ( ! empty( $args['col_md'] ) && $args['col_md'] !== '' ) { |
|
| 1596 | - $classes[] = sanitize_html_class( "col-md-" . $args['col_md'] ); |
|
| 1595 | + if (!empty($args['col_md']) && $args['col_md'] !== '') { |
|
| 1596 | + $classes[] = sanitize_html_class("col-md-" . $args['col_md']); |
|
| 1597 | 1597 | $col_md = $args['col_md']; |
| 1598 | 1598 | } else { |
| 1599 | 1599 | $col_md = null; |
| 1600 | 1600 | } |
| 1601 | - if ( ! empty( $args['col_lg'] ) && $args['col_lg'] !== '' ) { |
|
| 1602 | - if ( $col == null && $col_md == null ) { |
|
| 1603 | - $classes[] = sanitize_html_class( "col-" . $args['col_lg'] ); |
|
| 1601 | + if (!empty($args['col_lg']) && $args['col_lg'] !== '') { |
|
| 1602 | + if ($col == null && $col_md == null) { |
|
| 1603 | + $classes[] = sanitize_html_class("col-" . $args['col_lg']); |
|
| 1604 | 1604 | } else { |
| 1605 | - $classes[] = sanitize_html_class( "col-lg-" . $args['col_lg'] ); |
|
| 1605 | + $classes[] = sanitize_html_class("col-lg-" . $args['col_lg']); |
|
| 1606 | 1606 | } |
| 1607 | 1607 | } |
| 1608 | 1608 | |
| 1609 | 1609 | |
| 1610 | 1610 | // border |
| 1611 | - if ( ! empty( $args['border'] ) && ( $args['border'] == 'none' || $args['border'] === '0' ) ) { |
|
| 1611 | + if (!empty($args['border']) && ($args['border'] == 'none' || $args['border'] === '0')) { |
|
| 1612 | 1612 | $classes[] = "border-0"; |
| 1613 | - } elseif ( ! empty( $args['border'] ) ) { |
|
| 1614 | - $classes[] = "border border-" . sanitize_html_class( $args['border'] ); |
|
| 1613 | + } elseif (!empty($args['border'])) { |
|
| 1614 | + $classes[] = "border border-" . sanitize_html_class($args['border']); |
|
| 1615 | 1615 | } |
| 1616 | 1616 | |
| 1617 | 1617 | // border radius type |
| 1618 | - if ( ! empty( $args['rounded'] ) ) { |
|
| 1619 | - $classes[] = sanitize_html_class( $args['rounded'] ); |
|
| 1618 | + if (!empty($args['rounded'])) { |
|
| 1619 | + $classes[] = sanitize_html_class($args['rounded']); |
|
| 1620 | 1620 | } |
| 1621 | 1621 | |
| 1622 | 1622 | // border radius size |
| 1623 | - if ( ! empty( $args['rounded_size'] ) ) { |
|
| 1624 | - $classes[] = "rounded-" . sanitize_html_class( $args['rounded_size'] ); |
|
| 1623 | + if (!empty($args['rounded_size'])) { |
|
| 1624 | + $classes[] = "rounded-" . sanitize_html_class($args['rounded_size']); |
|
| 1625 | 1625 | // if we set a size then we need to remove "rounded" if set |
| 1626 | - if ( ( $key = array_search( "rounded", $classes ) ) !== false ) { |
|
| 1627 | - unset( $classes[ $key ] ); |
|
| 1626 | + if (($key = array_search("rounded", $classes)) !== false) { |
|
| 1627 | + unset($classes[$key]); |
|
| 1628 | 1628 | } |
| 1629 | 1629 | } |
| 1630 | 1630 | |
@@ -1632,83 +1632,83 @@ discard block |
||
| 1632 | 1632 | //if ( !empty( $args['shadow'] ) ) { $classes[] = sanitize_html_class($args['shadow']); } |
| 1633 | 1633 | |
| 1634 | 1634 | // background |
| 1635 | - if ( ! empty( $args['bg'] ) ) { |
|
| 1636 | - $classes[] = "bg-" . sanitize_html_class( $args['bg'] ); |
|
| 1635 | + if (!empty($args['bg'])) { |
|
| 1636 | + $classes[] = "bg-" . sanitize_html_class($args['bg']); |
|
| 1637 | 1637 | } |
| 1638 | 1638 | |
| 1639 | 1639 | // text_color |
| 1640 | - if ( ! empty( $args['text_color'] ) ) { |
|
| 1641 | - $classes[] = "text-" . sanitize_html_class( $args['text_color'] ); |
|
| 1640 | + if (!empty($args['text_color'])) { |
|
| 1641 | + $classes[] = "text-" . sanitize_html_class($args['text_color']); |
|
| 1642 | 1642 | } |
| 1643 | 1643 | |
| 1644 | 1644 | // text_align |
| 1645 | - if ( ! empty( $args['text_justify'] ) ) { |
|
| 1645 | + if (!empty($args['text_justify'])) { |
|
| 1646 | 1646 | $classes[] = 'text-justify'; |
| 1647 | 1647 | } else { |
| 1648 | - if ( ! empty( $args['text_align'] ) ) { |
|
| 1649 | - $classes[] = sanitize_html_class( $args['text_align'] ); |
|
| 1648 | + if (!empty($args['text_align'])) { |
|
| 1649 | + $classes[] = sanitize_html_class($args['text_align']); |
|
| 1650 | 1650 | $text_align = $args['text_align']; |
| 1651 | 1651 | } else { |
| 1652 | 1652 | $text_align = null; |
| 1653 | 1653 | } |
| 1654 | - if ( ! empty( $args['text_align_md'] ) && $args['text_align_md'] !== '' ) { |
|
| 1655 | - $classes[] = sanitize_html_class( $args['text_align_md'] ); |
|
| 1654 | + if (!empty($args['text_align_md']) && $args['text_align_md'] !== '') { |
|
| 1655 | + $classes[] = sanitize_html_class($args['text_align_md']); |
|
| 1656 | 1656 | $text_align_md = $args['text_align_md']; |
| 1657 | 1657 | } else { |
| 1658 | 1658 | $text_align_md = null; |
| 1659 | 1659 | } |
| 1660 | - if ( ! empty( $args['text_align_lg'] ) && $args['text_align_lg'] !== '' ) { |
|
| 1661 | - if ( $text_align == null && $text_align_md == null ) { |
|
| 1662 | - $classes[] = sanitize_html_class( str_replace( "-lg", "", $args['text_align_lg'] ) ); |
|
| 1660 | + if (!empty($args['text_align_lg']) && $args['text_align_lg'] !== '') { |
|
| 1661 | + if ($text_align == null && $text_align_md == null) { |
|
| 1662 | + $classes[] = sanitize_html_class(str_replace("-lg", "", $args['text_align_lg'])); |
|
| 1663 | 1663 | } else { |
| 1664 | - $classes[] = sanitize_html_class( $args['text_align_lg'] ); |
|
| 1664 | + $classes[] = sanitize_html_class($args['text_align_lg']); |
|
| 1665 | 1665 | } |
| 1666 | 1666 | } |
| 1667 | 1667 | } |
| 1668 | 1668 | |
| 1669 | 1669 | // display |
| 1670 | - if ( ! empty( $args['display'] ) ) { |
|
| 1671 | - $classes[] = sanitize_html_class( $args['display'] ); |
|
| 1670 | + if (!empty($args['display'])) { |
|
| 1671 | + $classes[] = sanitize_html_class($args['display']); |
|
| 1672 | 1672 | $display = $args['display']; |
| 1673 | 1673 | } else { |
| 1674 | 1674 | $display = null; |
| 1675 | 1675 | } |
| 1676 | - if ( ! empty( $args['display_md'] ) && $args['display_md'] !== '' ) { |
|
| 1677 | - $classes[] = sanitize_html_class( $args['display_md'] ); |
|
| 1676 | + if (!empty($args['display_md']) && $args['display_md'] !== '') { |
|
| 1677 | + $classes[] = sanitize_html_class($args['display_md']); |
|
| 1678 | 1678 | $display_md = $args['display_md']; |
| 1679 | 1679 | } else { |
| 1680 | 1680 | $display_md = null; |
| 1681 | 1681 | } |
| 1682 | - if ( ! empty( $args['display_lg'] ) && $args['display_lg'] !== '' ) { |
|
| 1683 | - if ( $display == null && $display_md == null ) { |
|
| 1684 | - $classes[] = sanitize_html_class( str_replace( "-lg", "", $args['display_lg'] ) ); |
|
| 1682 | + if (!empty($args['display_lg']) && $args['display_lg'] !== '') { |
|
| 1683 | + if ($display == null && $display_md == null) { |
|
| 1684 | + $classes[] = sanitize_html_class(str_replace("-lg", "", $args['display_lg'])); |
|
| 1685 | 1685 | } else { |
| 1686 | - $classes[] = sanitize_html_class( $args['display_lg'] ); |
|
| 1686 | + $classes[] = sanitize_html_class($args['display_lg']); |
|
| 1687 | 1687 | } |
| 1688 | 1688 | } |
| 1689 | 1689 | |
| 1690 | 1690 | |
| 1691 | 1691 | // bgtus - background transparent until scroll |
| 1692 | - if ( ! empty( $args['bgtus'] ) ) { |
|
| 1693 | - $classes[] = sanitize_html_class( "bg-transparent-until-scroll" ); |
|
| 1692 | + if (!empty($args['bgtus'])) { |
|
| 1693 | + $classes[] = sanitize_html_class("bg-transparent-until-scroll"); |
|
| 1694 | 1694 | } |
| 1695 | 1695 | |
| 1696 | 1696 | |
| 1697 | 1697 | // build classes from build keys |
| 1698 | 1698 | $build_keys = sd_get_class_build_keys(); |
| 1699 | - if ( ! empty( $build_keys ) ) { |
|
| 1700 | - foreach ( $build_keys as $key ) { |
|
| 1701 | - if ( $key == 'font_size' && ! empty( $args[ $key ] ) && $args[ $key ] == 'custom' ) { |
|
| 1699 | + if (!empty($build_keys)) { |
|
| 1700 | + foreach ($build_keys as $key) { |
|
| 1701 | + if ($key == 'font_size' && !empty($args[$key]) && $args[$key] == 'custom') { |
|
| 1702 | 1702 | continue; |
| 1703 | 1703 | } |
| 1704 | - if ( ! empty( $args[ $key ] ) ) { |
|
| 1705 | - $classes[] = sd_sanitize_html_classes( $args[ $key ] ); |
|
| 1704 | + if (!empty($args[$key])) { |
|
| 1705 | + $classes[] = sd_sanitize_html_classes($args[$key]); |
|
| 1706 | 1706 | } |
| 1707 | 1707 | } |
| 1708 | 1708 | } |
| 1709 | 1709 | |
| 1710 | 1710 | |
| 1711 | - return implode( " ", $classes ); |
|
| 1711 | + return implode(" ", $classes); |
|
| 1712 | 1712 | } |
| 1713 | 1713 | |
| 1714 | 1714 | /** |
@@ -1718,19 +1718,19 @@ discard block |
||
| 1718 | 1718 | * |
| 1719 | 1719 | * @return array |
| 1720 | 1720 | */ |
| 1721 | -function sd_build_aui_styles( $args ) { |
|
| 1721 | +function sd_build_aui_styles($args) { |
|
| 1722 | 1722 | |
| 1723 | 1723 | $styles = array(); |
| 1724 | 1724 | |
| 1725 | 1725 | // background color |
| 1726 | - if ( ! empty( $args['bg'] ) && $args['bg'] !== '' ) { |
|
| 1727 | - if ( $args['bg'] == 'custom-color' ) { |
|
| 1726 | + if (!empty($args['bg']) && $args['bg'] !== '') { |
|
| 1727 | + if ($args['bg'] == 'custom-color') { |
|
| 1728 | 1728 | $styles['background-color'] = $args['bg_color']; |
| 1729 | - } else if ( $args['bg'] == 'custom-gradient' ) { |
|
| 1729 | + } else if ($args['bg'] == 'custom-gradient') { |
|
| 1730 | 1730 | $styles['background-image'] = $args['bg_gradient']; |
| 1731 | 1731 | |
| 1732 | 1732 | // use background on text. |
| 1733 | - if ( ! empty( $args['bg_on_text'] ) && $args['bg_on_text'] ) { |
|
| 1733 | + if (!empty($args['bg_on_text']) && $args['bg_on_text']) { |
|
| 1734 | 1734 | $styles['background-clip'] = "text"; |
| 1735 | 1735 | $styles['-webkit-background-clip'] = "text"; |
| 1736 | 1736 | $styles['text-fill-color'] = "transparent"; |
@@ -1739,57 +1739,57 @@ discard block |
||
| 1739 | 1739 | } |
| 1740 | 1740 | } |
| 1741 | 1741 | |
| 1742 | - if ( ! empty( $args['bg_image'] ) && $args['bg_image'] !== '' ) { |
|
| 1742 | + if (!empty($args['bg_image']) && $args['bg_image'] !== '') { |
|
| 1743 | 1743 | $hasImage = true; |
| 1744 | - if ( $styles['background-color'] !== undefined && $args['bg'] == 'custom-color' ) { |
|
| 1744 | + if ($styles['background-color'] !== undefined && $args['bg'] == 'custom-color') { |
|
| 1745 | 1745 | $styles['background-image'] = "url(" . $args['bg_image'] . ")"; |
| 1746 | 1746 | $styles['background-blend-mode'] = "overlay"; |
| 1747 | - } else if ( $styles['background-image'] !== undefined && $args['bg'] == 'custom-gradient' ) { |
|
| 1747 | + } else if ($styles['background-image'] !== undefined && $args['bg'] == 'custom-gradient') { |
|
| 1748 | 1748 | $styles['background-image'] .= ",url(" . $args['bg_image'] . ")"; |
| 1749 | - } else if ( ! empty( $args['bg'] ) && $args['bg'] != '' && $args['bg'] != 'transparent' ) { |
|
| 1749 | + } else if (!empty($args['bg']) && $args['bg'] != '' && $args['bg'] != 'transparent') { |
|
| 1750 | 1750 | // do nothing as we alreay have a preset |
| 1751 | 1751 | $hasImage = false; |
| 1752 | 1752 | } else { |
| 1753 | 1753 | $styles['background-image'] = "url(" . $args['bg_image'] . ")"; |
| 1754 | 1754 | } |
| 1755 | 1755 | |
| 1756 | - if ( $hasImage ) { |
|
| 1756 | + if ($hasImage) { |
|
| 1757 | 1757 | $styles['background-size'] = "cover"; |
| 1758 | 1758 | |
| 1759 | - if ( ! empty( $args['bg_image_fixed'] ) && $args['bg_image_fixed'] ) { |
|
| 1759 | + if (!empty($args['bg_image_fixed']) && $args['bg_image_fixed']) { |
|
| 1760 | 1760 | $styles['background-attachment'] = "fixed"; |
| 1761 | 1761 | } |
| 1762 | 1762 | } |
| 1763 | 1763 | |
| 1764 | - if ( $hasImage && ! empty( $args['bg_image_xy'] ) && $args['bg_image_xy'] . x . length ) { |
|
| 1765 | - $styles['background-position'] = ( $args['bg_image_xy'] . x * 100 ) . "% " . ( $args['bg_image_xy'] . y * 100 ) . "%"; |
|
| 1764 | + if ($hasImage && !empty($args['bg_image_xy']) && $args['bg_image_xy'] . x . length) { |
|
| 1765 | + $styles['background-position'] = ($args['bg_image_xy'] . x * 100) . "% " . ($args['bg_image_xy'] . y * 100) . "%"; |
|
| 1766 | 1766 | } |
| 1767 | 1767 | } |
| 1768 | 1768 | |
| 1769 | 1769 | // sticky offset top |
| 1770 | - if ( ! empty( $args['sticky_offset_top'] ) && $args['sticky_offset_top'] !== '' ) { |
|
| 1771 | - $styles['top'] = absint( $args['sticky_offset_top'] ); |
|
| 1770 | + if (!empty($args['sticky_offset_top']) && $args['sticky_offset_top'] !== '') { |
|
| 1771 | + $styles['top'] = absint($args['sticky_offset_top']); |
|
| 1772 | 1772 | } |
| 1773 | 1773 | |
| 1774 | 1774 | // sticky offset bottom |
| 1775 | - if ( ! empty( $args['sticky_offset_bottom'] ) && $args['sticky_offset_bottom'] !== '' ) { |
|
| 1776 | - $styles['bottom'] = absint( $args['sticky_offset_bottom'] ); |
|
| 1775 | + if (!empty($args['sticky_offset_bottom']) && $args['sticky_offset_bottom'] !== '') { |
|
| 1776 | + $styles['bottom'] = absint($args['sticky_offset_bottom']); |
|
| 1777 | 1777 | } |
| 1778 | 1778 | |
| 1779 | 1779 | // font size |
| 1780 | - if ( ! empty( $args['font_size_custom'] ) && $args['font_size_custom'] !== '' ) { |
|
| 1780 | + if (!empty($args['font_size_custom']) && $args['font_size_custom'] !== '') { |
|
| 1781 | 1781 | $styles['font-size'] = (float) $args['font_size_custom'] . "rem"; |
| 1782 | 1782 | } |
| 1783 | 1783 | |
| 1784 | 1784 | // font color |
| 1785 | - if ( ! empty( $args['text_color_custom'] ) && $args['text_color_custom'] !== '' ) { |
|
| 1786 | - $styles['color'] = esc_attr( $args['text_color_custom'] ); |
|
| 1785 | + if (!empty($args['text_color_custom']) && $args['text_color_custom'] !== '') { |
|
| 1786 | + $styles['color'] = esc_attr($args['text_color_custom']); |
|
| 1787 | 1787 | } |
| 1788 | 1788 | |
| 1789 | 1789 | $style_string = ''; |
| 1790 | - if ( ! empty( $styles ) ) { |
|
| 1791 | - foreach ( $styles as $key => $val ) { |
|
| 1792 | - $style_string .= esc_attr( $key ) . ':' . esc_attr( $val ) . ';'; |
|
| 1790 | + if (!empty($styles)) { |
|
| 1791 | + foreach ($styles as $key => $val) { |
|
| 1792 | + $style_string .= esc_attr($key) . ':' . esc_attr($val) . ';'; |
|
| 1793 | 1793 | } |
| 1794 | 1794 | } |
| 1795 | 1795 | |
@@ -1805,16 +1805,16 @@ discard block |
||
| 1805 | 1805 | * |
| 1806 | 1806 | * @return string |
| 1807 | 1807 | */ |
| 1808 | -function sd_sanitize_html_classes( $classes, $sep = " " ) { |
|
| 1808 | +function sd_sanitize_html_classes($classes, $sep = " ") { |
|
| 1809 | 1809 | $return = ""; |
| 1810 | 1810 | |
| 1811 | - if ( ! is_array( $classes ) ) { |
|
| 1812 | - $classes = explode( $sep, $classes ); |
|
| 1811 | + if (!is_array($classes)) { |
|
| 1812 | + $classes = explode($sep, $classes); |
|
| 1813 | 1813 | } |
| 1814 | 1814 | |
| 1815 | - if ( ! empty( $classes ) ) { |
|
| 1816 | - foreach ( $classes as $class ) { |
|
| 1817 | - $return .= sanitize_html_class( $class ) . " "; |
|
| 1815 | + if (!empty($classes)) { |
|
| 1816 | + foreach ($classes as $class) { |
|
| 1817 | + $return .= sanitize_html_class($class) . " "; |
|
| 1818 | 1818 | } |
| 1819 | 1819 | } |
| 1820 | 1820 | |
@@ -1844,5 +1844,5 @@ discard block |
||
| 1844 | 1844 | 'css_class', |
| 1845 | 1845 | ); |
| 1846 | 1846 | |
| 1847 | - return apply_filters( "sd_class_build_keys", $keys ); |
|
| 1847 | + return apply_filters("sd_class_build_keys", $keys); |
|
| 1848 | 1848 | } |