@@ -10,24 +10,24 @@ |
||
| 10 | 10 | defined( 'ABSPATH' ) || exit; |
| 11 | 11 | |
| 12 | 12 | Redux::set_section( |
| 13 | - $opt_name, |
|
| 14 | - array( |
|
| 15 | - 'title' => esc_html__( 'Disable Field', 'your-textdomain-here' ), |
|
| 16 | - 'id' => 'basic-checkbox-disable', |
|
| 17 | - 'subsection' => true, |
|
| 18 | - 'customizer_width' => '450px', |
|
| 19 | - 'desc' => esc_html__( 'For full documentation on this field, visit: ', 'your-textdomain-here' ) . '<a href="https://devs.redux.io/core-fields/checkbox.html" target="_blank">https://devs.redux.io/core-fields/checkbox.html</a>', |
|
| 20 | - 'fields' => array( |
|
| 21 | - array( |
|
| 22 | - 'id' => 'opt-checkbox-disable', |
|
| 23 | - 'type' => 'checkbox', |
|
| 24 | - 'title' => esc_html__( 'Checkbox Option', 'your-textdomain-here' ), |
|
| 25 | - 'subtitle' => esc_html__( 'No validation can be done on this field type', 'your-textdomain-here' ), |
|
| 26 | - 'desc' => esc_html__( 'This is the description field, again good for additional info.', 'your-textdomain-here' ), |
|
| 27 | - 'disabled' => true, |
|
| 28 | - 'default' => '1', // 1 = on | 0 = off. |
|
| 29 | - ), |
|
| 30 | - ), |
|
| 31 | - ) |
|
| 13 | + $opt_name, |
|
| 14 | + array( |
|
| 15 | + 'title' => esc_html__( 'Disable Field', 'your-textdomain-here' ), |
|
| 16 | + 'id' => 'basic-checkbox-disable', |
|
| 17 | + 'subsection' => true, |
|
| 18 | + 'customizer_width' => '450px', |
|
| 19 | + 'desc' => esc_html__( 'For full documentation on this field, visit: ', 'your-textdomain-here' ) . '<a href="https://devs.redux.io/core-fields/checkbox.html" target="_blank">https://devs.redux.io/core-fields/checkbox.html</a>', |
|
| 20 | + 'fields' => array( |
|
| 21 | + array( |
|
| 22 | + 'id' => 'opt-checkbox-disable', |
|
| 23 | + 'type' => 'checkbox', |
|
| 24 | + 'title' => esc_html__( 'Checkbox Option', 'your-textdomain-here' ), |
|
| 25 | + 'subtitle' => esc_html__( 'No validation can be done on this field type', 'your-textdomain-here' ), |
|
| 26 | + 'desc' => esc_html__( 'This is the description field, again good for additional info.', 'your-textdomain-here' ), |
|
| 27 | + 'disabled' => true, |
|
| 28 | + 'default' => '1', // 1 = on | 0 = off. |
|
| 29 | + ), |
|
| 30 | + ), |
|
| 31 | + ) |
|
| 32 | 32 | ); |
| 33 | 33 | // phpcs:enable |
@@ -10,52 +10,52 @@ |
||
| 10 | 10 | defined( 'ABSPATH' ) || exit; |
| 11 | 11 | |
| 12 | 12 | Redux::set_section( |
| 13 | - $opt_name, |
|
| 14 | - array( |
|
| 15 | - 'title' => esc_html__( 'Sorter', 'your-textdomain-here' ), |
|
| 16 | - 'id' => 'additional-sorter', |
|
| 17 | - 'desc' => esc_html__( 'For full documentation on this field, visit: ', 'your-textdomain-here' ) . '<a href="https://devs.redux.io/core-fields/sorter.html" target="_blank">https://devs.redux.io/core-fields/sorter.html</a>', |
|
| 18 | - 'subsection' => true, |
|
| 19 | - 'fields' => array( |
|
| 20 | - array( |
|
| 21 | - 'id' => 'opt-homepage-layout', |
|
| 22 | - 'type' => 'sorter', |
|
| 23 | - 'title' => 'Layout Manager Advanced', |
|
| 24 | - 'subtitle' => 'You can add multiple drop areas or columns.', |
|
| 25 | - 'compiler' => 'true', |
|
| 26 | - 'options' => array( |
|
| 27 | - 'enabled' => array( |
|
| 28 | - 'highlights' => 'Highlights', |
|
| 29 | - 'slider' => 'Slider', |
|
| 30 | - 'staticpage' => 'Static Page', |
|
| 31 | - 'services' => 'Services', |
|
| 32 | - ), |
|
| 33 | - 'disabled' => array(), |
|
| 34 | - 'backup' => array(), |
|
| 35 | - ), |
|
| 36 | - 'limits' => array( |
|
| 37 | - 'disabled' => 1, |
|
| 38 | - 'backup' => 2, |
|
| 39 | - ), |
|
| 40 | - ), |
|
| 41 | - array( |
|
| 42 | - 'id' => 'opt-homepage-layout-2', |
|
| 43 | - 'type' => 'sorter', |
|
| 44 | - 'title' => 'Homepage Layout Manager', |
|
| 45 | - 'desc' => 'Organize how you want the layout to appear on the homepage', |
|
| 46 | - 'compiler' => 'true', |
|
| 47 | - 'options' => array( |
|
| 48 | - 'disabled' => array( |
|
| 49 | - 'highlights' => 'Highlights', |
|
| 50 | - 'slider' => 'Slider', |
|
| 51 | - ), |
|
| 52 | - 'enabled' => array( |
|
| 53 | - 'staticpage' => 'Static Page', |
|
| 54 | - 'services' => 'Services', |
|
| 55 | - ), |
|
| 56 | - ), |
|
| 57 | - ), |
|
| 58 | - ), |
|
| 59 | - ) |
|
| 13 | + $opt_name, |
|
| 14 | + array( |
|
| 15 | + 'title' => esc_html__( 'Sorter', 'your-textdomain-here' ), |
|
| 16 | + 'id' => 'additional-sorter', |
|
| 17 | + 'desc' => esc_html__( 'For full documentation on this field, visit: ', 'your-textdomain-here' ) . '<a href="https://devs.redux.io/core-fields/sorter.html" target="_blank">https://devs.redux.io/core-fields/sorter.html</a>', |
|
| 18 | + 'subsection' => true, |
|
| 19 | + 'fields' => array( |
|
| 20 | + array( |
|
| 21 | + 'id' => 'opt-homepage-layout', |
|
| 22 | + 'type' => 'sorter', |
|
| 23 | + 'title' => 'Layout Manager Advanced', |
|
| 24 | + 'subtitle' => 'You can add multiple drop areas or columns.', |
|
| 25 | + 'compiler' => 'true', |
|
| 26 | + 'options' => array( |
|
| 27 | + 'enabled' => array( |
|
| 28 | + 'highlights' => 'Highlights', |
|
| 29 | + 'slider' => 'Slider', |
|
| 30 | + 'staticpage' => 'Static Page', |
|
| 31 | + 'services' => 'Services', |
|
| 32 | + ), |
|
| 33 | + 'disabled' => array(), |
|
| 34 | + 'backup' => array(), |
|
| 35 | + ), |
|
| 36 | + 'limits' => array( |
|
| 37 | + 'disabled' => 1, |
|
| 38 | + 'backup' => 2, |
|
| 39 | + ), |
|
| 40 | + ), |
|
| 41 | + array( |
|
| 42 | + 'id' => 'opt-homepage-layout-2', |
|
| 43 | + 'type' => 'sorter', |
|
| 44 | + 'title' => 'Homepage Layout Manager', |
|
| 45 | + 'desc' => 'Organize how you want the layout to appear on the homepage', |
|
| 46 | + 'compiler' => 'true', |
|
| 47 | + 'options' => array( |
|
| 48 | + 'disabled' => array( |
|
| 49 | + 'highlights' => 'Highlights', |
|
| 50 | + 'slider' => 'Slider', |
|
| 51 | + ), |
|
| 52 | + 'enabled' => array( |
|
| 53 | + 'staticpage' => 'Static Page', |
|
| 54 | + 'services' => 'Services', |
|
| 55 | + ), |
|
| 56 | + ), |
|
| 57 | + ), |
|
| 58 | + ), |
|
| 59 | + ) |
|
| 60 | 60 | ); |
| 61 | 61 | // phpcs:enable |
@@ -10,21 +10,21 @@ |
||
| 10 | 10 | defined( 'ABSPATH' ) || exit; |
| 11 | 11 | |
| 12 | 12 | Redux::set_section( |
| 13 | - $opt_name, |
|
| 14 | - array( |
|
| 15 | - 'title' => esc_html__( 'Date', 'your-textdomain-here' ), |
|
| 16 | - 'id' => 'additional-date', |
|
| 17 | - 'desc' => esc_html__( 'For full documentation on this field, visit: ', 'your-textdomain-here' ) . '<a href="https://devs.redux.io/core-fields/date.html" target="_blank">https://devs.redux.io/core-fields/date.html</a>', |
|
| 18 | - 'subsection' => true, |
|
| 19 | - 'fields' => array( |
|
| 20 | - array( |
|
| 21 | - 'id' => 'opt-datepicker', |
|
| 22 | - 'type' => 'date', |
|
| 23 | - 'title' => esc_html__( 'Date Option', 'your-textdomain-here' ), |
|
| 24 | - 'subtitle' => esc_html__( 'No validation can be done on this field type', 'your-textdomain-here' ), |
|
| 25 | - 'desc' => esc_html__( 'This is the description field, again good for additional info.', 'your-textdomain-here' ), |
|
| 26 | - ), |
|
| 27 | - ), |
|
| 28 | - ) |
|
| 13 | + $opt_name, |
|
| 14 | + array( |
|
| 15 | + 'title' => esc_html__( 'Date', 'your-textdomain-here' ), |
|
| 16 | + 'id' => 'additional-date', |
|
| 17 | + 'desc' => esc_html__( 'For full documentation on this field, visit: ', 'your-textdomain-here' ) . '<a href="https://devs.redux.io/core-fields/date.html" target="_blank">https://devs.redux.io/core-fields/date.html</a>', |
|
| 18 | + 'subsection' => true, |
|
| 19 | + 'fields' => array( |
|
| 20 | + array( |
|
| 21 | + 'id' => 'opt-datepicker', |
|
| 22 | + 'type' => 'date', |
|
| 23 | + 'title' => esc_html__( 'Date Option', 'your-textdomain-here' ), |
|
| 24 | + 'subtitle' => esc_html__( 'No validation can be done on this field type', 'your-textdomain-here' ), |
|
| 25 | + 'desc' => esc_html__( 'This is the description field, again good for additional info.', 'your-textdomain-here' ), |
|
| 26 | + ), |
|
| 27 | + ), |
|
| 28 | + ) |
|
| 29 | 29 | ); |
| 30 | 30 | // phpcs:enable |
@@ -11,37 +11,37 @@ |
||
| 11 | 11 | |
| 12 | 12 | $sample_html = ''; |
| 13 | 13 | if ( file_exists( $dir . 'info-html.html' ) ) { |
| 14 | - $fs = Redux_Filesystem::get_instance(); |
|
| 14 | + $fs = Redux_Filesystem::get_instance(); |
|
| 15 | 15 | |
| 16 | - $sample_html = $fs->get_contents( $dir . 'info-html.html' ); |
|
| 16 | + $sample_html = $fs->get_contents( $dir . 'info-html.html' ); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | Redux::set_section( |
| 20 | - $opt_name, |
|
| 21 | - array( |
|
| 22 | - 'title' => esc_html__( 'Raw', 'your-textdomain-here' ), |
|
| 23 | - 'id' => 'additional-raw', |
|
| 24 | - 'desc' => esc_html__( 'For full documentation on this field, visit: ', 'your-textdomain-here' ) . '<a href="https://devs.redux.io/core-fields/raw.html" target="_blank">https://devs.redux.io/core-fields/raw.html</a>', |
|
| 25 | - 'subsection' => true, |
|
| 26 | - 'fields' => array( |
|
| 27 | - array( |
|
| 28 | - 'id' => 'opt-raw_info_4', |
|
| 29 | - 'type' => 'raw', |
|
| 30 | - 'title' => esc_html__( 'Standard Raw Field', 'your-textdomain-here' ), |
|
| 31 | - 'subtitle' => esc_html__( 'Subtitle', 'your-textdomain-here' ), |
|
| 32 | - 'desc' => esc_html__( 'Description', 'your-textdomain-here' ), |
|
| 33 | - 'content' => $sample_html, |
|
| 34 | - ), |
|
| 35 | - array( |
|
| 36 | - 'id' => 'opt-raw_info_5', |
|
| 37 | - 'type' => 'raw', |
|
| 38 | - 'full_width' => false, |
|
| 39 | - 'title' => wp_kses_post( __( 'Raw Field <code>full_width</code> set to <code>false</code>', 'your-textdomain-here' ) ), |
|
| 40 | - 'subtitle' => esc_html__( 'Subtitle', 'your-textdomain-here' ), |
|
| 41 | - 'desc' => esc_html__( 'Description', 'your-textdomain-here' ), |
|
| 42 | - 'content' => $sample_html, |
|
| 43 | - ), |
|
| 44 | - ), |
|
| 45 | - ) |
|
| 20 | + $opt_name, |
|
| 21 | + array( |
|
| 22 | + 'title' => esc_html__( 'Raw', 'your-textdomain-here' ), |
|
| 23 | + 'id' => 'additional-raw', |
|
| 24 | + 'desc' => esc_html__( 'For full documentation on this field, visit: ', 'your-textdomain-here' ) . '<a href="https://devs.redux.io/core-fields/raw.html" target="_blank">https://devs.redux.io/core-fields/raw.html</a>', |
|
| 25 | + 'subsection' => true, |
|
| 26 | + 'fields' => array( |
|
| 27 | + array( |
|
| 28 | + 'id' => 'opt-raw_info_4', |
|
| 29 | + 'type' => 'raw', |
|
| 30 | + 'title' => esc_html__( 'Standard Raw Field', 'your-textdomain-here' ), |
|
| 31 | + 'subtitle' => esc_html__( 'Subtitle', 'your-textdomain-here' ), |
|
| 32 | + 'desc' => esc_html__( 'Description', 'your-textdomain-here' ), |
|
| 33 | + 'content' => $sample_html, |
|
| 34 | + ), |
|
| 35 | + array( |
|
| 36 | + 'id' => 'opt-raw_info_5', |
|
| 37 | + 'type' => 'raw', |
|
| 38 | + 'full_width' => false, |
|
| 39 | + 'title' => wp_kses_post( __( 'Raw Field <code>full_width</code> set to <code>false</code>', 'your-textdomain-here' ) ), |
|
| 40 | + 'subtitle' => esc_html__( 'Subtitle', 'your-textdomain-here' ), |
|
| 41 | + 'desc' => esc_html__( 'Description', 'your-textdomain-here' ), |
|
| 42 | + 'content' => $sample_html, |
|
| 43 | + ), |
|
| 44 | + ), |
|
| 45 | + ) |
|
| 46 | 46 | ); |
| 47 | 47 | // phpcs:enable |
@@ -11,84 +11,84 @@ |
||
| 11 | 11 | defined( 'ABSPATH' ) || exit; |
| 12 | 12 | |
| 13 | 13 | Redux::set_section( |
| 14 | - $opt_name, |
|
| 15 | - array( |
|
| 16 | - 'title' => esc_html__( 'Date / Time Picker', 'your-textdomain-here' ), |
|
| 17 | - 'desc' => esc_html__( 'For full documentation on this field, visit: ', 'your-textdomain-here' ) . '<a href="https://devs.redux.io/core-extensions/date-time-picker.html" target="_blank">https://devs.redux.io/core-extensions/date-time-picker.html</a>', |
|
| 18 | - 'subsection' => true, |
|
| 19 | - 'fields' => array( |
|
| 20 | - array( |
|
| 21 | - 'id' => 'opt-date-time-single', |
|
| 22 | - 'type' => 'datetime', |
|
| 23 | - 'title' => esc_html__( 'Single Date / Time input', 'your-textdomain-here' ), |
|
| 24 | - 'subtitle' => esc_html__( 'Display when the split argument is set to false', 'your-textdomain-here' ), |
|
| 25 | - 'desc' => 'The separator argument is set to the @ symbol. Control-type is set to \'slider\'', |
|
| 26 | - 'split' => false, |
|
| 27 | - 'control-type' => 'slider', |
|
| 28 | - 'separator' => ' @ ', |
|
| 29 | - ), |
|
| 30 | - array( |
|
| 31 | - 'id' => 'opt-date-time-split', |
|
| 32 | - 'type' => 'datetime', |
|
| 33 | - 'title' => esc_html__( 'Split Date / Time input', 'your-textdomain-here' ), |
|
| 34 | - 'subtitle' => esc_html__( 'Display when the split argument is set to true.', 'your-textdomain-here' ), |
|
| 35 | - 'desc' => 'The \'timezone-list\' argument is set to display labels instead of time offsets.', |
|
| 36 | - 'split' => true, |
|
| 37 | - 'control-type' => 'slider', |
|
| 38 | - 'timezone-list' => array( |
|
| 39 | - array( |
|
| 40 | - 'value' => '-300', |
|
| 41 | - 'label' => 'Eastern', |
|
| 42 | - ), |
|
| 43 | - array( |
|
| 44 | - 'value' => '-360', |
|
| 45 | - 'label' => 'Central', |
|
| 46 | - ), |
|
| 47 | - array( |
|
| 48 | - 'value' => '-420', |
|
| 49 | - 'label' => 'Mountain', |
|
| 50 | - ), |
|
| 51 | - array( |
|
| 52 | - 'value' => '-480', |
|
| 53 | - 'label' => 'Pacific', |
|
| 54 | - ), |
|
| 55 | - ), |
|
| 56 | - ), |
|
| 57 | - array( |
|
| 58 | - 'id' => 'opt-date-time-date-only', |
|
| 59 | - 'type' => 'datetime', |
|
| 60 | - 'title' => esc_html__( 'Date only input', 'your-textdomain-here' ), |
|
| 61 | - 'subtitle' => esc_html__( 'Popup shows only the date picker.', 'your-textdomain-here' ), |
|
| 62 | - 'desc' => 'The \'time-picker\' argument is set to false.', |
|
| 63 | - 'time-picker' => false, |
|
| 64 | - 'placeholder' => 'Date only', |
|
| 65 | - ), |
|
| 66 | - array( |
|
| 67 | - 'id' => 'opt-date-time-time-only', |
|
| 68 | - 'type' => 'datetime', |
|
| 69 | - 'title' => esc_html__( 'Time only input', 'your-textdomain-here' ), |
|
| 70 | - 'subtitle' => esc_html__( 'Popup shows only the time picker.', 'your-textdomain-here' ), |
|
| 71 | - 'desc' => 'The \'date-picker\' argument is set to false.', |
|
| 72 | - 'date-picker' => false, |
|
| 73 | - 'placeholder' => 'Time only', |
|
| 74 | - ), |
|
| 75 | - array( |
|
| 76 | - 'id' => 'opt-date-time-minmax', |
|
| 77 | - 'type' => 'datetime', |
|
| 78 | - 'title' => esc_html__( 'Min Max demo', 'your-textdomain-here' ), |
|
| 79 | - 'subtitle' => esc_html__( 'Both time and date have min and max values.', 'your-textdomain-here' ), |
|
| 80 | - 'desc' => 'The selectable date range is 30 days from the current day. The selectable time range is between 8:20 AM and 4:40 PM', |
|
| 81 | - 'split' => true, |
|
| 82 | - 'time-format' => 'hh:mm TT', |
|
| 83 | - 'hour-min' => 8, |
|
| 84 | - 'hour-max' => 16, |
|
| 85 | - 'minute-min' => 20, |
|
| 86 | - 'minute-max' => 40, |
|
| 87 | - 'num-of-months' => 2, |
|
| 88 | - 'date-min' => 0, |
|
| 89 | - 'date-max' => 30, |
|
| 90 | - ), |
|
| 91 | - ), |
|
| 92 | - ) |
|
| 14 | + $opt_name, |
|
| 15 | + array( |
|
| 16 | + 'title' => esc_html__( 'Date / Time Picker', 'your-textdomain-here' ), |
|
| 17 | + 'desc' => esc_html__( 'For full documentation on this field, visit: ', 'your-textdomain-here' ) . '<a href="https://devs.redux.io/core-extensions/date-time-picker.html" target="_blank">https://devs.redux.io/core-extensions/date-time-picker.html</a>', |
|
| 18 | + 'subsection' => true, |
|
| 19 | + 'fields' => array( |
|
| 20 | + array( |
|
| 21 | + 'id' => 'opt-date-time-single', |
|
| 22 | + 'type' => 'datetime', |
|
| 23 | + 'title' => esc_html__( 'Single Date / Time input', 'your-textdomain-here' ), |
|
| 24 | + 'subtitle' => esc_html__( 'Display when the split argument is set to false', 'your-textdomain-here' ), |
|
| 25 | + 'desc' => 'The separator argument is set to the @ symbol. Control-type is set to \'slider\'', |
|
| 26 | + 'split' => false, |
|
| 27 | + 'control-type' => 'slider', |
|
| 28 | + 'separator' => ' @ ', |
|
| 29 | + ), |
|
| 30 | + array( |
|
| 31 | + 'id' => 'opt-date-time-split', |
|
| 32 | + 'type' => 'datetime', |
|
| 33 | + 'title' => esc_html__( 'Split Date / Time input', 'your-textdomain-here' ), |
|
| 34 | + 'subtitle' => esc_html__( 'Display when the split argument is set to true.', 'your-textdomain-here' ), |
|
| 35 | + 'desc' => 'The \'timezone-list\' argument is set to display labels instead of time offsets.', |
|
| 36 | + 'split' => true, |
|
| 37 | + 'control-type' => 'slider', |
|
| 38 | + 'timezone-list' => array( |
|
| 39 | + array( |
|
| 40 | + 'value' => '-300', |
|
| 41 | + 'label' => 'Eastern', |
|
| 42 | + ), |
|
| 43 | + array( |
|
| 44 | + 'value' => '-360', |
|
| 45 | + 'label' => 'Central', |
|
| 46 | + ), |
|
| 47 | + array( |
|
| 48 | + 'value' => '-420', |
|
| 49 | + 'label' => 'Mountain', |
|
| 50 | + ), |
|
| 51 | + array( |
|
| 52 | + 'value' => '-480', |
|
| 53 | + 'label' => 'Pacific', |
|
| 54 | + ), |
|
| 55 | + ), |
|
| 56 | + ), |
|
| 57 | + array( |
|
| 58 | + 'id' => 'opt-date-time-date-only', |
|
| 59 | + 'type' => 'datetime', |
|
| 60 | + 'title' => esc_html__( 'Date only input', 'your-textdomain-here' ), |
|
| 61 | + 'subtitle' => esc_html__( 'Popup shows only the date picker.', 'your-textdomain-here' ), |
|
| 62 | + 'desc' => 'The \'time-picker\' argument is set to false.', |
|
| 63 | + 'time-picker' => false, |
|
| 64 | + 'placeholder' => 'Date only', |
|
| 65 | + ), |
|
| 66 | + array( |
|
| 67 | + 'id' => 'opt-date-time-time-only', |
|
| 68 | + 'type' => 'datetime', |
|
| 69 | + 'title' => esc_html__( 'Time only input', 'your-textdomain-here' ), |
|
| 70 | + 'subtitle' => esc_html__( 'Popup shows only the time picker.', 'your-textdomain-here' ), |
|
| 71 | + 'desc' => 'The \'date-picker\' argument is set to false.', |
|
| 72 | + 'date-picker' => false, |
|
| 73 | + 'placeholder' => 'Time only', |
|
| 74 | + ), |
|
| 75 | + array( |
|
| 76 | + 'id' => 'opt-date-time-minmax', |
|
| 77 | + 'type' => 'datetime', |
|
| 78 | + 'title' => esc_html__( 'Min Max demo', 'your-textdomain-here' ), |
|
| 79 | + 'subtitle' => esc_html__( 'Both time and date have min and max values.', 'your-textdomain-here' ), |
|
| 80 | + 'desc' => 'The selectable date range is 30 days from the current day. The selectable time range is between 8:20 AM and 4:40 PM', |
|
| 81 | + 'split' => true, |
|
| 82 | + 'time-format' => 'hh:mm TT', |
|
| 83 | + 'hour-min' => 8, |
|
| 84 | + 'hour-max' => 16, |
|
| 85 | + 'minute-min' => 20, |
|
| 86 | + 'minute-max' => 40, |
|
| 87 | + 'num-of-months' => 2, |
|
| 88 | + 'date-min' => 0, |
|
| 89 | + 'date-max' => 30, |
|
| 90 | + ), |
|
| 91 | + ), |
|
| 92 | + ) |
|
| 93 | 93 | ); |
| 94 | 94 | // phpcs:enable |
@@ -10,27 +10,27 @@ |
||
| 10 | 10 | defined( 'ABSPATH' ) || exit; |
| 11 | 11 | |
| 12 | 12 | Redux::set_section( |
| 13 | - $opt_name, |
|
| 14 | - array( |
|
| 15 | - 'title' => esc_html__( 'Spinner', 'your-textdomain-here' ), |
|
| 16 | - 'id' => 'slider_spinner-spinner', |
|
| 17 | - 'desc' => esc_html__( 'For full documentation on this field, visit: ', 'your-textdomain-here' ) . '<a href="https://devs.redux.io/core-fields/spinner.html" target="_blank">https://devs.redux.io/core-fields/spinner.html</a>', |
|
| 18 | - 'subsection' => true, |
|
| 19 | - 'fields' => array( |
|
| 20 | - array( |
|
| 21 | - 'id' => 'opt-spinner', |
|
| 22 | - 'type' => 'spinner', |
|
| 23 | - 'title' => esc_html__( 'JQuery UI Spinner Example 1', 'your-textdomain-here' ), |
|
| 24 | - 'desc' => esc_html__( 'JQuery UI spinner description. Min:20, max: 100, step:20, default value: 100', 'your-textdomain-here' ), |
|
| 25 | - 'default' => '100', |
|
| 26 | - 'min' => '20', |
|
| 27 | - 'step' => '20', |
|
| 28 | - 'max' => '100', |
|
| 29 | - 'suffix' => '', |
|
| 30 | - 'output_unit' => 'px', |
|
| 31 | - 'output' => array( '.content-area' => 'max-width' ), |
|
| 32 | - ), |
|
| 33 | - ), |
|
| 34 | - ) |
|
| 13 | + $opt_name, |
|
| 14 | + array( |
|
| 15 | + 'title' => esc_html__( 'Spinner', 'your-textdomain-here' ), |
|
| 16 | + 'id' => 'slider_spinner-spinner', |
|
| 17 | + 'desc' => esc_html__( 'For full documentation on this field, visit: ', 'your-textdomain-here' ) . '<a href="https://devs.redux.io/core-fields/spinner.html" target="_blank">https://devs.redux.io/core-fields/spinner.html</a>', |
|
| 18 | + 'subsection' => true, |
|
| 19 | + 'fields' => array( |
|
| 20 | + array( |
|
| 21 | + 'id' => 'opt-spinner', |
|
| 22 | + 'type' => 'spinner', |
|
| 23 | + 'title' => esc_html__( 'JQuery UI Spinner Example 1', 'your-textdomain-here' ), |
|
| 24 | + 'desc' => esc_html__( 'JQuery UI spinner description. Min:20, max: 100, step:20, default value: 100', 'your-textdomain-here' ), |
|
| 25 | + 'default' => '100', |
|
| 26 | + 'min' => '20', |
|
| 27 | + 'step' => '20', |
|
| 28 | + 'max' => '100', |
|
| 29 | + 'suffix' => '', |
|
| 30 | + 'output_unit' => 'px', |
|
| 31 | + 'output' => array( '.content-area' => 'max-width' ), |
|
| 32 | + ), |
|
| 33 | + ), |
|
| 34 | + ) |
|
| 35 | 35 | ); |
| 36 | 36 | // phpcs:enable |
@@ -10,72 +10,72 @@ |
||
| 10 | 10 | defined( 'ABSPATH' ) || exit; |
| 11 | 11 | |
| 12 | 12 | Redux::set_section( |
| 13 | - $opt_name, |
|
| 14 | - array( |
|
| 15 | - 'title' => esc_html__( 'Slider', 'your-textdomain-here' ), |
|
| 16 | - 'id' => 'slider_spinner-slider', |
|
| 17 | - 'desc' => esc_html__( 'For full documentation on this field, visit: ', 'your-textdomain-here' ) . '<a href="https://devs.redux.io/core-fields/slider.html" target="_blank">https://devs.redux.io/core-fields/slider.html</a>', |
|
| 18 | - 'fields' => array( |
|
| 19 | - array( |
|
| 20 | - 'id' => 'opt-slider-label', |
|
| 21 | - 'type' => 'slider', |
|
| 22 | - 'title' => esc_html__( 'Slider Example 1', 'your-textdomain-here' ), |
|
| 23 | - 'subtitle' => esc_html__( 'This slider displays the value as a label.', 'your-textdomain-here' ), |
|
| 24 | - 'desc' => esc_html__( 'Slider description. Min: 1, max: 500, step: 1, default value: 250', 'your-textdomain-here' ), |
|
| 25 | - 'default' => 250, |
|
| 26 | - 'min' => 1, |
|
| 27 | - 'step' => 1, |
|
| 28 | - 'max' => 500, |
|
| 29 | - 'display_value' => 'label', |
|
| 30 | - ), |
|
| 31 | - array( |
|
| 32 | - 'id' => 'opt-slider-text', |
|
| 33 | - 'type' => 'slider', |
|
| 34 | - 'title' => esc_html__( 'Slider Example 2 with Steps (5)', 'your-textdomain-here' ), |
|
| 35 | - 'subtitle' => esc_html__( 'This example displays the value in a text box', 'your-textdomain-here' ), |
|
| 36 | - 'desc' => esc_html__( 'Slider description. Min: 0, max: 800, step: 5, default value: 75', 'your-textdomain-here' ), |
|
| 37 | - 'default' => 750, |
|
| 38 | - 'min' => 0, |
|
| 39 | - 'step' => 5, |
|
| 40 | - 'max' => 800, |
|
| 41 | - 'display_value' => 'text', |
|
| 42 | - 'output' => array( '.site-content' => 'max-width' ), |
|
| 43 | - ), |
|
| 44 | - array( |
|
| 45 | - 'id' => 'opt-slider-select', |
|
| 46 | - 'type' => 'slider', |
|
| 47 | - 'title' => esc_html__( 'Slider Example 3 with two sliders', 'your-textdomain-here' ), |
|
| 48 | - 'subtitle' => esc_html__( 'This example displays the values in select boxes', 'your-textdomain-here' ), |
|
| 49 | - 'desc' => esc_html__( 'Slider description. Min: 0, max: 500, step: 5, slider 1 default value: 100, slider 2 default value: 300', 'your-textdomain-here' ), |
|
| 50 | - 'default' => array( |
|
| 51 | - 1 => 100, |
|
| 52 | - 2 => 300, |
|
| 53 | - ), |
|
| 54 | - 'min' => 0, |
|
| 55 | - 'step' => 5, |
|
| 56 | - 'max' => '500', |
|
| 57 | - 'display_value' => 'select', |
|
| 58 | - 'handles' => 2, |
|
| 59 | - 'output' => array( |
|
| 60 | - 1 => array( '.site-footer' => 'max-width' ), |
|
| 61 | - 2 => array( '.site-footer' => 'min-width' ), |
|
| 62 | - ), |
|
| 63 | - ), |
|
| 64 | - array( |
|
| 65 | - 'id' => 'opt-slider-float', |
|
| 66 | - 'type' => 'slider', |
|
| 67 | - 'title' => esc_html__( 'Slider Example 4 with float values', 'your-textdomain-here' ), |
|
| 68 | - 'subtitle' => esc_html__( 'This example displays float values', 'your-textdomain-here' ), |
|
| 69 | - 'desc' => esc_html__( 'Slider description. Min: 0, max: 1, step: .1, default value: .5', 'your-textdomain-here' ), |
|
| 70 | - 'default' => .5, |
|
| 71 | - 'min' => 0, |
|
| 72 | - 'step' => .1, |
|
| 73 | - 'max' => 1, |
|
| 74 | - 'resolution' => 0.1, |
|
| 75 | - 'display_value' => 'text', |
|
| 76 | - ), |
|
| 77 | - ), |
|
| 78 | - 'subsection' => true, |
|
| 79 | - ) |
|
| 13 | + $opt_name, |
|
| 14 | + array( |
|
| 15 | + 'title' => esc_html__( 'Slider', 'your-textdomain-here' ), |
|
| 16 | + 'id' => 'slider_spinner-slider', |
|
| 17 | + 'desc' => esc_html__( 'For full documentation on this field, visit: ', 'your-textdomain-here' ) . '<a href="https://devs.redux.io/core-fields/slider.html" target="_blank">https://devs.redux.io/core-fields/slider.html</a>', |
|
| 18 | + 'fields' => array( |
|
| 19 | + array( |
|
| 20 | + 'id' => 'opt-slider-label', |
|
| 21 | + 'type' => 'slider', |
|
| 22 | + 'title' => esc_html__( 'Slider Example 1', 'your-textdomain-here' ), |
|
| 23 | + 'subtitle' => esc_html__( 'This slider displays the value as a label.', 'your-textdomain-here' ), |
|
| 24 | + 'desc' => esc_html__( 'Slider description. Min: 1, max: 500, step: 1, default value: 250', 'your-textdomain-here' ), |
|
| 25 | + 'default' => 250, |
|
| 26 | + 'min' => 1, |
|
| 27 | + 'step' => 1, |
|
| 28 | + 'max' => 500, |
|
| 29 | + 'display_value' => 'label', |
|
| 30 | + ), |
|
| 31 | + array( |
|
| 32 | + 'id' => 'opt-slider-text', |
|
| 33 | + 'type' => 'slider', |
|
| 34 | + 'title' => esc_html__( 'Slider Example 2 with Steps (5)', 'your-textdomain-here' ), |
|
| 35 | + 'subtitle' => esc_html__( 'This example displays the value in a text box', 'your-textdomain-here' ), |
|
| 36 | + 'desc' => esc_html__( 'Slider description. Min: 0, max: 800, step: 5, default value: 75', 'your-textdomain-here' ), |
|
| 37 | + 'default' => 750, |
|
| 38 | + 'min' => 0, |
|
| 39 | + 'step' => 5, |
|
| 40 | + 'max' => 800, |
|
| 41 | + 'display_value' => 'text', |
|
| 42 | + 'output' => array( '.site-content' => 'max-width' ), |
|
| 43 | + ), |
|
| 44 | + array( |
|
| 45 | + 'id' => 'opt-slider-select', |
|
| 46 | + 'type' => 'slider', |
|
| 47 | + 'title' => esc_html__( 'Slider Example 3 with two sliders', 'your-textdomain-here' ), |
|
| 48 | + 'subtitle' => esc_html__( 'This example displays the values in select boxes', 'your-textdomain-here' ), |
|
| 49 | + 'desc' => esc_html__( 'Slider description. Min: 0, max: 500, step: 5, slider 1 default value: 100, slider 2 default value: 300', 'your-textdomain-here' ), |
|
| 50 | + 'default' => array( |
|
| 51 | + 1 => 100, |
|
| 52 | + 2 => 300, |
|
| 53 | + ), |
|
| 54 | + 'min' => 0, |
|
| 55 | + 'step' => 5, |
|
| 56 | + 'max' => '500', |
|
| 57 | + 'display_value' => 'select', |
|
| 58 | + 'handles' => 2, |
|
| 59 | + 'output' => array( |
|
| 60 | + 1 => array( '.site-footer' => 'max-width' ), |
|
| 61 | + 2 => array( '.site-footer' => 'min-width' ), |
|
| 62 | + ), |
|
| 63 | + ), |
|
| 64 | + array( |
|
| 65 | + 'id' => 'opt-slider-float', |
|
| 66 | + 'type' => 'slider', |
|
| 67 | + 'title' => esc_html__( 'Slider Example 4 with float values', 'your-textdomain-here' ), |
|
| 68 | + 'subtitle' => esc_html__( 'This example displays float values', 'your-textdomain-here' ), |
|
| 69 | + 'desc' => esc_html__( 'Slider description. Min: 0, max: 1, step: .1, default value: .5', 'your-textdomain-here' ), |
|
| 70 | + 'default' => .5, |
|
| 71 | + 'min' => 0, |
|
| 72 | + 'step' => .1, |
|
| 73 | + 'max' => 1, |
|
| 74 | + 'resolution' => 0.1, |
|
| 75 | + 'display_value' => 'text', |
|
| 76 | + ), |
|
| 77 | + ), |
|
| 78 | + 'subsection' => true, |
|
| 79 | + ) |
|
| 80 | 80 | ); |
| 81 | 81 | // phpcs:enable |
@@ -11,56 +11,56 @@ |
||
| 11 | 11 | |
| 12 | 12 | if ( ! class_exists( 'Redux_Class', false ) ) { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Class Redux_Class |
|
| 16 | - */ |
|
| 17 | - class Redux_Class { |
|
| 14 | + /** |
|
| 15 | + * Class Redux_Class |
|
| 16 | + */ |
|
| 17 | + class Redux_Class { |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Pointer to ReduxFramework object. |
|
| 21 | - * |
|
| 22 | - * @var null|ReduxFramework |
|
| 23 | - */ |
|
| 24 | - public ?ReduxFramework $parent = null; |
|
| 19 | + /** |
|
| 20 | + * Pointer to ReduxFramework object. |
|
| 21 | + * |
|
| 22 | + * @var null|ReduxFramework |
|
| 23 | + */ |
|
| 24 | + public ?ReduxFramework $parent = null; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Global arguments array. |
|
| 28 | - * |
|
| 29 | - * @var array|mixed|void |
|
| 30 | - */ |
|
| 31 | - public $args = array(); |
|
| 26 | + /** |
|
| 27 | + * Global arguments array. |
|
| 28 | + * |
|
| 29 | + * @var array|mixed|void |
|
| 30 | + */ |
|
| 31 | + public $args = array(); |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * Project opt_name |
|
| 35 | - * |
|
| 36 | - * @var mixed|string |
|
| 37 | - */ |
|
| 38 | - public $opt_name = ''; |
|
| 33 | + /** |
|
| 34 | + * Project opt_name |
|
| 35 | + * |
|
| 36 | + * @var mixed|string |
|
| 37 | + */ |
|
| 38 | + public $opt_name = ''; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Redux_Class constructor. |
|
| 42 | - * |
|
| 43 | - * @param ReduxFramework|null $redux Pointer to ReduxFramework object. |
|
| 44 | - */ |
|
| 45 | - public function __construct( ?ReduxFramework $redux = null ) { |
|
| 46 | - if ( is_object( $redux ) ) { |
|
| 47 | - $this->parent = $redux; |
|
| 48 | - $this->args = $redux->args; |
|
| 49 | - $this->opt_name = $this->args['opt_name']; |
|
| 50 | - } |
|
| 51 | - } |
|
| 40 | + /** |
|
| 41 | + * Redux_Class constructor. |
|
| 42 | + * |
|
| 43 | + * @param ReduxFramework|null $redux Pointer to ReduxFramework object. |
|
| 44 | + */ |
|
| 45 | + public function __construct( ?ReduxFramework $redux = null ) { |
|
| 46 | + if ( is_object( $redux ) ) { |
|
| 47 | + $this->parent = $redux; |
|
| 48 | + $this->args = $redux->args; |
|
| 49 | + $this->opt_name = $this->args['opt_name']; |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Pointer to a project-specific ReduxFramework object. |
|
| 55 | - * |
|
| 56 | - * @return null|object|ReduxFramework |
|
| 57 | - */ |
|
| 58 | - public function core() { |
|
| 59 | - if ( isset( $this->opt_name ) && '' !== $this->opt_name ) { |
|
| 60 | - return Redux::instance( $this->opt_name ); |
|
| 61 | - } |
|
| 53 | + /** |
|
| 54 | + * Pointer to a project-specific ReduxFramework object. |
|
| 55 | + * |
|
| 56 | + * @return null|object|ReduxFramework |
|
| 57 | + */ |
|
| 58 | + public function core() { |
|
| 59 | + if ( isset( $this->opt_name ) && '' !== $this->opt_name ) { |
|
| 60 | + return Redux::instance( $this->opt_name ); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - return null; |
|
| 64 | - } |
|
| 65 | - } |
|
| 63 | + return null; |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | 66 | } |
@@ -11,330 +11,330 @@ |
||
| 11 | 11 | |
| 12 | 12 | if ( ! class_exists( 'Redux_Social_Profiles_Functions' ) ) { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Class Redux_Social_Profiles_Functions |
|
| 16 | - */ |
|
| 17 | - class Redux_Social_Profiles_Functions { |
|
| 18 | - /** |
|
| 19 | - * ReduxFramework object pointer. |
|
| 20 | - * |
|
| 21 | - * @var ReduxFramework |
|
| 22 | - */ |
|
| 23 | - public static ReduxFramework $parent; |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * Field ID. |
|
| 27 | - * |
|
| 28 | - * @var null|string |
|
| 29 | - */ |
|
| 30 | - public static ?string $field_id; |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * Field array. |
|
| 34 | - * |
|
| 35 | - * @var array|null |
|
| 36 | - */ |
|
| 37 | - public static ?array $field; |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * WordPress upload directory. |
|
| 41 | - * |
|
| 42 | - * @var string |
|
| 43 | - */ |
|
| 44 | - public static string $upload_dir; |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * WordPress upload URI. |
|
| 48 | - * |
|
| 49 | - * @var string |
|
| 50 | - */ |
|
| 51 | - public static string $upload_url; |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * Init helper library. |
|
| 55 | - * |
|
| 56 | - * @param ReduxFramework $redux ReduxFramework object. |
|
| 57 | - */ |
|
| 58 | - public static function init( ReduxFramework $redux ) { |
|
| 59 | - self::$parent = $redux; |
|
| 60 | - |
|
| 61 | - if ( empty( self::$field_id ) ) { |
|
| 62 | - self::$field = self::get_field( $redux ); |
|
| 63 | - |
|
| 64 | - if ( ! is_array( self::$field ) ) { |
|
| 65 | - return; |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - self::$field_id = self::$field['id']; |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - // Make sanitized upload dir DIR. |
|
| 72 | - self::$upload_dir = Redux_Functions_Ex::wp_normalize_path( Redux_Core::$upload_dir . 'social-profiles/' ); |
|
| 73 | - |
|
| 74 | - // Make sanitized upload dir URL. |
|
| 75 | - self::$upload_url = Redux_Functions_Ex::wp_normalize_path( Redux_Core::$upload_url . 'social-profiles/' ); |
|
| 76 | - |
|
| 77 | - Redux_Functions::init_wp_filesystem(); |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * Read data file. |
|
| 82 | - * |
|
| 83 | - * @return array|bool|mixed|object |
|
| 84 | - */ |
|
| 85 | - public static function read_data_file() { |
|
| 86 | - $file = self::get_data_path(); |
|
| 87 | - |
|
| 88 | - if ( file_exists( $file ) ) { |
|
| 89 | - |
|
| 90 | - // Get the contents of the file and stuff it in a variable. |
|
| 91 | - $data = Redux_Core::$filesystem->execute( 'get_contents', $file ); |
|
| 92 | - |
|
| 93 | - // Error or null, set the result to false. |
|
| 94 | - if ( false === $data || null === $data ) { |
|
| 95 | - $arr_data = false; |
|
| 96 | - |
|
| 97 | - // Otherwise, decode the json object and return it. |
|
| 98 | - } else { |
|
| 99 | - $arr = json_decode( $data, true ); |
|
| 100 | - $arr_data = $arr; |
|
| 101 | - } |
|
| 102 | - } else { |
|
| 103 | - $arr_data = false; |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - return $arr_data; |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - /** |
|
| 110 | - * Write data file. |
|
| 111 | - * |
|
| 112 | - * @param array $arr_data Data. |
|
| 113 | - * @param string $file Filename. |
|
| 114 | - * |
|
| 115 | - * @return bool |
|
| 116 | - */ |
|
| 117 | - public static function write_data_file( array $arr_data, string $file = '' ): bool { |
|
| 118 | - if ( ! is_dir( self::$upload_dir ) ) { |
|
| 119 | - return false; |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - $file = ( '' === $file ) ? self::get_data_path() : self::$upload_dir . $file; |
|
| 123 | - |
|
| 124 | - // Encode the array data. |
|
| 125 | - $data = wp_json_encode( $arr_data ); |
|
| 126 | - |
|
| 127 | - // Write to its file on the server, return the return value |
|
| 128 | - // True on success, false on error. |
|
| 129 | - return Redux_Core::$filesystem->execute( 'put_contents', $file, array( 'content' => $data ) ); |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * Get the data path. |
|
| 134 | - * |
|
| 135 | - * @return mixed|Redux_Functions_Ex|string |
|
| 136 | - */ |
|
| 137 | - public static function get_data_path() { |
|
| 138 | - return Redux_Functions_Ex::wp_normalize_path( self::$upload_dir . '/' . self::$parent->args['opt_name'] . '-' . self::$field_id . '.json' ); |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * Get field. |
|
| 143 | - * |
|
| 144 | - * @param array|ReduxFramework $redux ReduxFramework object. |
|
| 145 | - * |
|
| 146 | - * @return mixed |
|
| 147 | - */ |
|
| 148 | - public static function get_field( $redux = array() ) { |
|
| 149 | - global $pagenow; |
|
| 150 | - |
|
| 151 | - if ( is_admin() && ( 'post-new.php' === $pagenow || 'post.php' === $pagenow ) ) { |
|
| 152 | - $inst = Redux_Instances::get_instance( self::$parent->args['opt_name'] ); |
|
| 153 | - |
|
| 154 | - $ext = $inst->extensions; |
|
| 155 | - |
|
| 156 | - if ( isset( $ext['metaboxes'] ) ) { |
|
| 157 | - $obj = $ext['metaboxes']; |
|
| 158 | - $boxes = ( $obj->boxes ); |
|
| 159 | - |
|
| 160 | - foreach ( $boxes as $sections ) { |
|
| 161 | - foreach ( $sections['sections'] as $fields ) { |
|
| 162 | - if ( isset( $fields['fields'] ) ) { |
|
| 163 | - foreach ( $fields['fields'] as $f ) { |
|
| 164 | - if ( 'social_profiles' === $f['type'] ) { |
|
| 165 | - return $f; |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - if ( 'repeater' === $f['type'] ) { |
|
| 169 | - foreach ( $f['fields'] as $r ) { |
|
| 170 | - if ( 'social_profiles' === $r['type'] ) { |
|
| 171 | - return $r; |
|
| 172 | - } |
|
| 173 | - } |
|
| 174 | - } |
|
| 175 | - } |
|
| 176 | - } |
|
| 177 | - } |
|
| 178 | - } |
|
| 179 | - } |
|
| 180 | - } else { |
|
| 181 | - if ( ! empty( $redux ) ) { |
|
| 182 | - self::$parent = $redux; |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - if ( isset( self::$parent->field_sections['social_profiles'] ) ) { |
|
| 186 | - return reset( self::$parent->field_sections['social_profiles'] ); |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - $arr = self::$parent; |
|
| 190 | - |
|
| 191 | - foreach ( $arr as $part => $bla ) { |
|
| 192 | - if ( 'sections' === $part ) { |
|
| 193 | - foreach ( $bla as $field ) { |
|
| 194 | - |
|
| 195 | - foreach ( $field as $arg => $val ) { |
|
| 196 | - if ( 'fields' === $arg ) { |
|
| 197 | - foreach ( $val as $v ) { |
|
| 198 | - if ( ! empty( $v ) ) { |
|
| 199 | - foreach ( $v as $id => $x ) { |
|
| 200 | - if ( 'type' === $id ) { |
|
| 201 | - if ( 'social_profiles' === $x ) { |
|
| 202 | - return $v; |
|
| 203 | - } |
|
| 204 | - } |
|
| 205 | - } |
|
| 206 | - } |
|
| 207 | - } |
|
| 208 | - } |
|
| 209 | - } |
|
| 210 | - } |
|
| 211 | - } |
|
| 212 | - } |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - return null; |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - /** |
|
| 219 | - * Add extra icons. |
|
| 220 | - * |
|
| 221 | - * @param array $defaults Default values. |
|
| 222 | - * |
|
| 223 | - * @return array |
|
| 224 | - */ |
|
| 225 | - public static function add_extra_icons( array $defaults ): array { |
|
| 226 | - if ( empty( self::$field ) ) { |
|
| 227 | - self::$field = self::get_field(); |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - if ( isset( self::$field['icons'] ) && ! empty( self::$field['icons'] ) ) { |
|
| 231 | - $cur_count = count( $defaults ); |
|
| 232 | - |
|
| 233 | - foreach ( self::$field['icons'] as $arr ) { |
|
| 234 | - |
|
| 235 | - $skip_add = false; |
|
| 236 | - foreach ( $defaults as $i => $v ) { |
|
| 237 | - if ( $arr['id'] === $v['id'] ) { |
|
| 238 | - |
|
| 239 | - $defaults[ $i ] = array_replace( $v, $arr ); |
|
| 240 | - $skip_add = true; |
|
| 241 | - break; |
|
| 242 | - } |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - if ( ! $skip_add ) { |
|
| 246 | - $arr['order'] = $cur_count; |
|
| 247 | - $arr['class'] = $arr['class'] ?? 'fa'; |
|
| 248 | - $defaults[ $cur_count ] = $arr; |
|
| 249 | - ++$cur_count; |
|
| 250 | - } |
|
| 251 | - } |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - return $defaults; |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - /** |
|
| 258 | - * Get Included files. |
|
| 259 | - * |
|
| 260 | - * @param array $val Value. |
|
| 261 | - * |
|
| 262 | - * @return array |
|
| 263 | - */ |
|
| 264 | - private static function get_includes( array $val ): array { |
|
| 265 | - if ( empty( self::$field ) ) { |
|
| 266 | - self::$field = self::get_field(); |
|
| 267 | - } |
|
| 268 | - |
|
| 269 | - if ( isset( self::$field['include'] ) && is_array( self::$field['include'] ) && ! empty( self::$field['include'] ) ) { |
|
| 270 | - $icons = self::$field['include']; |
|
| 271 | - |
|
| 272 | - $new_arr = array(); |
|
| 273 | - |
|
| 274 | - $idx = 0; |
|
| 275 | - foreach ( $val as $arr ) { |
|
| 276 | - foreach ( $icons as $icon ) { |
|
| 277 | - if ( $icon === $arr['id'] ) { |
|
| 278 | - $arr['order'] = $idx; |
|
| 279 | - $new_arr[ $idx ] = $arr; |
|
| 280 | - ++$idx; |
|
| 281 | - break; |
|
| 282 | - } |
|
| 283 | - } |
|
| 284 | - } |
|
| 285 | - } else { |
|
| 286 | - $new_arr = $val; |
|
| 287 | - } |
|
| 288 | - |
|
| 289 | - return $new_arr; |
|
| 290 | - } |
|
| 291 | - |
|
| 292 | - /** |
|
| 293 | - * Returns default data from config. |
|
| 294 | - * |
|
| 295 | - * @return array |
|
| 296 | - */ |
|
| 297 | - public static function get_default_data(): array { |
|
| 298 | - $data = Redux_Social_Profiles_Defaults::get_social_media_defaults(); |
|
| 299 | - $data = self::get_includes( $data ); |
|
| 300 | - |
|
| 301 | - return self::add_extra_icons( $data ); |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - /** |
|
| 305 | - * Static function to render the social icon. |
|
| 306 | - * |
|
| 307 | - * @param string $icon_class Icon class. |
|
| 308 | - * @param string $icon Icon css. |
|
| 309 | - * @param string $color Hex color. |
|
| 310 | - * @param string $background Background color. |
|
| 311 | - * @param string $title Icon title. |
|
| 312 | - * @param bool $output Print or echo. |
|
| 313 | - * |
|
| 314 | - * @return string|void |
|
| 315 | - */ |
|
| 316 | - public static function render_icon( string $icon_class, string $icon, string $color, string $background, string $title, bool $output = true ) { |
|
| 317 | - if ( $color || $background ) { |
|
| 318 | - if ( '' === $color ) { |
|
| 319 | - $color = 'transparent'; |
|
| 320 | - } |
|
| 321 | - |
|
| 322 | - if ( '' === $background ) { |
|
| 323 | - $background = 'transparent'; |
|
| 324 | - } |
|
| 325 | - |
|
| 326 | - $inline = 'style="color:' . esc_attr( $color ) . ';background-color:' . esc_attr( $background ) . ';"'; |
|
| 327 | - } else { |
|
| 328 | - $inline = ''; |
|
| 329 | - } |
|
| 330 | - |
|
| 331 | - $str = '<i class="' . $icon_class . ' ' . $icon . '" ' . $inline . ' title="' . $title . '"></i>'; |
|
| 332 | - |
|
| 333 | - if ( $output ) { |
|
| 334 | - echo $str; // phpcs:ignore WordPress.Security.EscapeOutput |
|
| 335 | - } else { |
|
| 336 | - return $str; |
|
| 337 | - } |
|
| 338 | - } |
|
| 339 | - } |
|
| 14 | + /** |
|
| 15 | + * Class Redux_Social_Profiles_Functions |
|
| 16 | + */ |
|
| 17 | + class Redux_Social_Profiles_Functions { |
|
| 18 | + /** |
|
| 19 | + * ReduxFramework object pointer. |
|
| 20 | + * |
|
| 21 | + * @var ReduxFramework |
|
| 22 | + */ |
|
| 23 | + public static ReduxFramework $parent; |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * Field ID. |
|
| 27 | + * |
|
| 28 | + * @var null|string |
|
| 29 | + */ |
|
| 30 | + public static ?string $field_id; |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * Field array. |
|
| 34 | + * |
|
| 35 | + * @var array|null |
|
| 36 | + */ |
|
| 37 | + public static ?array $field; |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * WordPress upload directory. |
|
| 41 | + * |
|
| 42 | + * @var string |
|
| 43 | + */ |
|
| 44 | + public static string $upload_dir; |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * WordPress upload URI. |
|
| 48 | + * |
|
| 49 | + * @var string |
|
| 50 | + */ |
|
| 51 | + public static string $upload_url; |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * Init helper library. |
|
| 55 | + * |
|
| 56 | + * @param ReduxFramework $redux ReduxFramework object. |
|
| 57 | + */ |
|
| 58 | + public static function init( ReduxFramework $redux ) { |
|
| 59 | + self::$parent = $redux; |
|
| 60 | + |
|
| 61 | + if ( empty( self::$field_id ) ) { |
|
| 62 | + self::$field = self::get_field( $redux ); |
|
| 63 | + |
|
| 64 | + if ( ! is_array( self::$field ) ) { |
|
| 65 | + return; |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + self::$field_id = self::$field['id']; |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + // Make sanitized upload dir DIR. |
|
| 72 | + self::$upload_dir = Redux_Functions_Ex::wp_normalize_path( Redux_Core::$upload_dir . 'social-profiles/' ); |
|
| 73 | + |
|
| 74 | + // Make sanitized upload dir URL. |
|
| 75 | + self::$upload_url = Redux_Functions_Ex::wp_normalize_path( Redux_Core::$upload_url . 'social-profiles/' ); |
|
| 76 | + |
|
| 77 | + Redux_Functions::init_wp_filesystem(); |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * Read data file. |
|
| 82 | + * |
|
| 83 | + * @return array|bool|mixed|object |
|
| 84 | + */ |
|
| 85 | + public static function read_data_file() { |
|
| 86 | + $file = self::get_data_path(); |
|
| 87 | + |
|
| 88 | + if ( file_exists( $file ) ) { |
|
| 89 | + |
|
| 90 | + // Get the contents of the file and stuff it in a variable. |
|
| 91 | + $data = Redux_Core::$filesystem->execute( 'get_contents', $file ); |
|
| 92 | + |
|
| 93 | + // Error or null, set the result to false. |
|
| 94 | + if ( false === $data || null === $data ) { |
|
| 95 | + $arr_data = false; |
|
| 96 | + |
|
| 97 | + // Otherwise, decode the json object and return it. |
|
| 98 | + } else { |
|
| 99 | + $arr = json_decode( $data, true ); |
|
| 100 | + $arr_data = $arr; |
|
| 101 | + } |
|
| 102 | + } else { |
|
| 103 | + $arr_data = false; |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + return $arr_data; |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * Write data file. |
|
| 111 | + * |
|
| 112 | + * @param array $arr_data Data. |
|
| 113 | + * @param string $file Filename. |
|
| 114 | + * |
|
| 115 | + * @return bool |
|
| 116 | + */ |
|
| 117 | + public static function write_data_file( array $arr_data, string $file = '' ): bool { |
|
| 118 | + if ( ! is_dir( self::$upload_dir ) ) { |
|
| 119 | + return false; |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + $file = ( '' === $file ) ? self::get_data_path() : self::$upload_dir . $file; |
|
| 123 | + |
|
| 124 | + // Encode the array data. |
|
| 125 | + $data = wp_json_encode( $arr_data ); |
|
| 126 | + |
|
| 127 | + // Write to its file on the server, return the return value |
|
| 128 | + // True on success, false on error. |
|
| 129 | + return Redux_Core::$filesystem->execute( 'put_contents', $file, array( 'content' => $data ) ); |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * Get the data path. |
|
| 134 | + * |
|
| 135 | + * @return mixed|Redux_Functions_Ex|string |
|
| 136 | + */ |
|
| 137 | + public static function get_data_path() { |
|
| 138 | + return Redux_Functions_Ex::wp_normalize_path( self::$upload_dir . '/' . self::$parent->args['opt_name'] . '-' . self::$field_id . '.json' ); |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * Get field. |
|
| 143 | + * |
|
| 144 | + * @param array|ReduxFramework $redux ReduxFramework object. |
|
| 145 | + * |
|
| 146 | + * @return mixed |
|
| 147 | + */ |
|
| 148 | + public static function get_field( $redux = array() ) { |
|
| 149 | + global $pagenow; |
|
| 150 | + |
|
| 151 | + if ( is_admin() && ( 'post-new.php' === $pagenow || 'post.php' === $pagenow ) ) { |
|
| 152 | + $inst = Redux_Instances::get_instance( self::$parent->args['opt_name'] ); |
|
| 153 | + |
|
| 154 | + $ext = $inst->extensions; |
|
| 155 | + |
|
| 156 | + if ( isset( $ext['metaboxes'] ) ) { |
|
| 157 | + $obj = $ext['metaboxes']; |
|
| 158 | + $boxes = ( $obj->boxes ); |
|
| 159 | + |
|
| 160 | + foreach ( $boxes as $sections ) { |
|
| 161 | + foreach ( $sections['sections'] as $fields ) { |
|
| 162 | + if ( isset( $fields['fields'] ) ) { |
|
| 163 | + foreach ( $fields['fields'] as $f ) { |
|
| 164 | + if ( 'social_profiles' === $f['type'] ) { |
|
| 165 | + return $f; |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + if ( 'repeater' === $f['type'] ) { |
|
| 169 | + foreach ( $f['fields'] as $r ) { |
|
| 170 | + if ( 'social_profiles' === $r['type'] ) { |
|
| 171 | + return $r; |
|
| 172 | + } |
|
| 173 | + } |
|
| 174 | + } |
|
| 175 | + } |
|
| 176 | + } |
|
| 177 | + } |
|
| 178 | + } |
|
| 179 | + } |
|
| 180 | + } else { |
|
| 181 | + if ( ! empty( $redux ) ) { |
|
| 182 | + self::$parent = $redux; |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + if ( isset( self::$parent->field_sections['social_profiles'] ) ) { |
|
| 186 | + return reset( self::$parent->field_sections['social_profiles'] ); |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + $arr = self::$parent; |
|
| 190 | + |
|
| 191 | + foreach ( $arr as $part => $bla ) { |
|
| 192 | + if ( 'sections' === $part ) { |
|
| 193 | + foreach ( $bla as $field ) { |
|
| 194 | + |
|
| 195 | + foreach ( $field as $arg => $val ) { |
|
| 196 | + if ( 'fields' === $arg ) { |
|
| 197 | + foreach ( $val as $v ) { |
|
| 198 | + if ( ! empty( $v ) ) { |
|
| 199 | + foreach ( $v as $id => $x ) { |
|
| 200 | + if ( 'type' === $id ) { |
|
| 201 | + if ( 'social_profiles' === $x ) { |
|
| 202 | + return $v; |
|
| 203 | + } |
|
| 204 | + } |
|
| 205 | + } |
|
| 206 | + } |
|
| 207 | + } |
|
| 208 | + } |
|
| 209 | + } |
|
| 210 | + } |
|
| 211 | + } |
|
| 212 | + } |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + return null; |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + /** |
|
| 219 | + * Add extra icons. |
|
| 220 | + * |
|
| 221 | + * @param array $defaults Default values. |
|
| 222 | + * |
|
| 223 | + * @return array |
|
| 224 | + */ |
|
| 225 | + public static function add_extra_icons( array $defaults ): array { |
|
| 226 | + if ( empty( self::$field ) ) { |
|
| 227 | + self::$field = self::get_field(); |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + if ( isset( self::$field['icons'] ) && ! empty( self::$field['icons'] ) ) { |
|
| 231 | + $cur_count = count( $defaults ); |
|
| 232 | + |
|
| 233 | + foreach ( self::$field['icons'] as $arr ) { |
|
| 234 | + |
|
| 235 | + $skip_add = false; |
|
| 236 | + foreach ( $defaults as $i => $v ) { |
|
| 237 | + if ( $arr['id'] === $v['id'] ) { |
|
| 238 | + |
|
| 239 | + $defaults[ $i ] = array_replace( $v, $arr ); |
|
| 240 | + $skip_add = true; |
|
| 241 | + break; |
|
| 242 | + } |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + if ( ! $skip_add ) { |
|
| 246 | + $arr['order'] = $cur_count; |
|
| 247 | + $arr['class'] = $arr['class'] ?? 'fa'; |
|
| 248 | + $defaults[ $cur_count ] = $arr; |
|
| 249 | + ++$cur_count; |
|
| 250 | + } |
|
| 251 | + } |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + return $defaults; |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + /** |
|
| 258 | + * Get Included files. |
|
| 259 | + * |
|
| 260 | + * @param array $val Value. |
|
| 261 | + * |
|
| 262 | + * @return array |
|
| 263 | + */ |
|
| 264 | + private static function get_includes( array $val ): array { |
|
| 265 | + if ( empty( self::$field ) ) { |
|
| 266 | + self::$field = self::get_field(); |
|
| 267 | + } |
|
| 268 | + |
|
| 269 | + if ( isset( self::$field['include'] ) && is_array( self::$field['include'] ) && ! empty( self::$field['include'] ) ) { |
|
| 270 | + $icons = self::$field['include']; |
|
| 271 | + |
|
| 272 | + $new_arr = array(); |
|
| 273 | + |
|
| 274 | + $idx = 0; |
|
| 275 | + foreach ( $val as $arr ) { |
|
| 276 | + foreach ( $icons as $icon ) { |
|
| 277 | + if ( $icon === $arr['id'] ) { |
|
| 278 | + $arr['order'] = $idx; |
|
| 279 | + $new_arr[ $idx ] = $arr; |
|
| 280 | + ++$idx; |
|
| 281 | + break; |
|
| 282 | + } |
|
| 283 | + } |
|
| 284 | + } |
|
| 285 | + } else { |
|
| 286 | + $new_arr = $val; |
|
| 287 | + } |
|
| 288 | + |
|
| 289 | + return $new_arr; |
|
| 290 | + } |
|
| 291 | + |
|
| 292 | + /** |
|
| 293 | + * Returns default data from config. |
|
| 294 | + * |
|
| 295 | + * @return array |
|
| 296 | + */ |
|
| 297 | + public static function get_default_data(): array { |
|
| 298 | + $data = Redux_Social_Profiles_Defaults::get_social_media_defaults(); |
|
| 299 | + $data = self::get_includes( $data ); |
|
| 300 | + |
|
| 301 | + return self::add_extra_icons( $data ); |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + /** |
|
| 305 | + * Static function to render the social icon. |
|
| 306 | + * |
|
| 307 | + * @param string $icon_class Icon class. |
|
| 308 | + * @param string $icon Icon css. |
|
| 309 | + * @param string $color Hex color. |
|
| 310 | + * @param string $background Background color. |
|
| 311 | + * @param string $title Icon title. |
|
| 312 | + * @param bool $output Print or echo. |
|
| 313 | + * |
|
| 314 | + * @return string|void |
|
| 315 | + */ |
|
| 316 | + public static function render_icon( string $icon_class, string $icon, string $color, string $background, string $title, bool $output = true ) { |
|
| 317 | + if ( $color || $background ) { |
|
| 318 | + if ( '' === $color ) { |
|
| 319 | + $color = 'transparent'; |
|
| 320 | + } |
|
| 321 | + |
|
| 322 | + if ( '' === $background ) { |
|
| 323 | + $background = 'transparent'; |
|
| 324 | + } |
|
| 325 | + |
|
| 326 | + $inline = 'style="color:' . esc_attr( $color ) . ';background-color:' . esc_attr( $background ) . ';"'; |
|
| 327 | + } else { |
|
| 328 | + $inline = ''; |
|
| 329 | + } |
|
| 330 | + |
|
| 331 | + $str = '<i class="' . $icon_class . ' ' . $icon . '" ' . $inline . ' title="' . $title . '"></i>'; |
|
| 332 | + |
|
| 333 | + if ( $output ) { |
|
| 334 | + echo $str; // phpcs:ignore WordPress.Security.EscapeOutput |
|
| 335 | + } else { |
|
| 336 | + return $str; |
|
| 337 | + } |
|
| 338 | + } |
|
| 339 | + } |
|
| 340 | 340 | } |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * |
| 35 | 35 | * @var array|null |
| 36 | 36 | */ |
| 37 | - public static ?array $field; |
|
| 37 | + public static ? array $field; |
|
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | 40 | * WordPress upload directory. |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | foreach ( $defaults as $i => $v ) { |
| 237 | 237 | if ( $arr['id'] === $v['id'] ) { |
| 238 | 238 | |
| 239 | - $defaults[ $i ] = array_replace( $v, $arr ); |
|
| 239 | + $defaults[$i] = array_replace( $v, $arr ); |
|
| 240 | 240 | $skip_add = true; |
| 241 | 241 | break; |
| 242 | 242 | } |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | if ( ! $skip_add ) { |
| 246 | 246 | $arr['order'] = $cur_count; |
| 247 | 247 | $arr['class'] = $arr['class'] ?? 'fa'; |
| 248 | - $defaults[ $cur_count ] = $arr; |
|
| 248 | + $defaults[$cur_count] = $arr; |
|
| 249 | 249 | ++$cur_count; |
| 250 | 250 | } |
| 251 | 251 | } |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | foreach ( $icons as $icon ) { |
| 277 | 277 | if ( $icon === $arr['id'] ) { |
| 278 | 278 | $arr['order'] = $idx; |
| 279 | - $new_arr[ $idx ] = $arr; |
|
| 279 | + $new_arr[$idx] = $arr; |
|
| 280 | 280 | ++$idx; |
| 281 | 281 | break; |
| 282 | 282 | } |