Supreme Modules Lite – Divi Theme, Extra Theme and Divi Builder - Version 1.1.2

Version Description

  • 07.10.2018 =
  • Added: Scheduled Content Visibility for Section and Row.
  • Added: Divi Supreme Option Page to the admin menu for enabling/disabling features.
  • Enhanced: Typing Effect will execute only when visitor scroll into view.
Download this release

Release Info

Developer divisupreme
Plugin Icon 128x128 Supreme Modules Lite – Divi Theme, Extra Theme and Divi Builder
Version 1.1.2
Comparing to
See all releases

Code changes from version 1.1.1 to 1.1.2

assets/css/{dsm-admin.css → dsm-et-admin.css} RENAMED
@@ -11,12 +11,13 @@
11
  .et-db #et-boc .et-fb-modules-list li.dsm_embed_twitter_timeline {
12
  background: #6b09eb;
13
  color: #fff;
14
- font-size:10px;
15
  }
 
16
  .et-db #et-boc .et-fb-modules-list li.dsm_typing_effect:before,
17
  .et-db #et-boc .et-fb-modules-list li.dsm_facebook_feed:before,
18
  .et-db #et-boc .et-fb-modules-list li.dsm_embed_twitter_timeline:before {
19
- font-family: ETmodules!important;
20
  }
21
 
22
  .et-db #et-boc .et-fb-modules-list li.dsm_flipbox:hover,
@@ -52,6 +53,6 @@
52
  .et-db #et-boc .et-fb-modules-list li.dsm_contact_form_7:focus,
53
  .et-db #et-boc .et-fb-modules-list li.dsm_embed_google_map:focus,
54
  .et-db #et-boc .et-fb-modules-list li.dsm_embed_twitter_timeline:focus {
55
- background: rgba(107,9,235,0.78);
56
  color: #fff;
57
  }
11
  .et-db #et-boc .et-fb-modules-list li.dsm_embed_twitter_timeline {
12
  background: #6b09eb;
13
  color: #fff;
14
+ font-size: 10px;
15
  }
16
+
17
  .et-db #et-boc .et-fb-modules-list li.dsm_typing_effect:before,
18
  .et-db #et-boc .et-fb-modules-list li.dsm_facebook_feed:before,
19
  .et-db #et-boc .et-fb-modules-list li.dsm_embed_twitter_timeline:before {
20
+ font-family: ETmodules !important;
21
  }
22
 
23
  .et-db #et-boc .et-fb-modules-list li.dsm_flipbox:hover,
53
  .et-db #et-boc .et-fb-modules-list li.dsm_contact_form_7:focus,
54
  .et-db #et-boc .et-fb-modules-list li.dsm_embed_google_map:focus,
55
  .et-db #et-boc .et-fb-modules-list li.dsm_embed_twitter_timeline:focus {
56
+ background: rgba(107, 9, 235, 0.78);
57
  color: #fff;
58
  }
assets/css/dsm-plugin.css ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #toplevel_page_divi_supreme_settings .wp-menu-image img {
2
+ width: 20px;
3
+ height: 20px;
4
+ padding: 7px 0 0;
5
+ opacity: 1;
6
+ filter: alpha(opacity=100);
7
+ }
8
+
9
+ .dsm-section-subtitle th {
10
+ padding: 0;
11
+ }
12
+
13
+ .dsm-section-subtitle h3 {
14
+ margin: 0;
15
+ }
16
+ #dsm_general th {
17
+ white-space: nowrap;
18
+ }
19
+ #dsm_general .form-table {
20
+ padding: 23px 10px;
21
+ border: 1px solid #e5e5e5;
22
+ box-shadow: 0 1px 1px rgba(0, 0, 0, .04);
23
+ background: #fff;
24
+ margin-top: 2em;
25
+ border-collapse: initial;
26
+ }
27
+
28
+ .dsm-settings-checkbox fieldset label {
29
+ position: relative;
30
+ display: inline-block;
31
+ width: 50px;
32
+ height: 24px;
33
+ }
34
+
35
+ .dsm-settings-checkbox input {
36
+ display: none;
37
+ }
38
+
39
+ .dsm-settings-checkbox .slider {
40
+ position: absolute;
41
+ cursor: pointer;
42
+ top: 0;
43
+ left: 0;
44
+ right: 0;
45
+ bottom: 0;
46
+ background-color: #ccc;
47
+ -webkit-transition: .4s;
48
+ transition: .4s;
49
+ }
50
+
51
+ .dsm-settings-checkbox .slider:before {
52
+ position: absolute;
53
+ content: "";
54
+ height: 16px;
55
+ width: 16px;
56
+ left: 4px;
57
+ bottom: 4px;
58
+ background-color: white;
59
+ -webkit-transition: .4s;
60
+ transition: .4s;
61
+ }
62
+
63
+ .dsm-settings-checkbox input:checked+.slider {
64
+ background-color: #6b09eb;
65
+ }
66
+
67
+ .dsm-settings-checkbox input:focus+.slider {
68
+ box-shadow: 0 0 1px #6b09eb;
69
+ }
70
+
71
+ .dsm-settings-checkbox input:checked+.slider:before {
72
+ -webkit-transform: translateX(26px);
73
+ -ms-transform: translateX(26px);
74
+ transform: translateX(26px);
75
+ }
76
+
77
+
78
+ .dsm-settings-checkbox .round {
79
+ border-radius: 24px;
80
+ }
81
+
82
+ .dsm-settings-checkbox .round:before {
83
+ border-radius: 50%;
84
+ }
85
+
86
+ #dsm_general p.submit .button-primary {
87
+ color: #fff;
88
+ border-color: #25db92;
89
+ border-radius: 50px;
90
+ font-size: 14px;
91
+ background: #25db92;
92
+ text-shadow: none;
93
+ padding: 15px 30px;
94
+ line-height: 1;
95
+ box-shadow: none;
96
+ box-shadow: 0px 12px 18px -6px rgba(0, 0, 0, 0.19);
97
+ font-weight: 700;
98
+ height: initial;
99
+ transition: color 300ms ease 0ms, color 300ms ease 0ms, background-color 300ms ease 0ms, background-color 300ms ease 0ms, border 300ms ease 0ms, border 300ms ease 0ms, border-radius 300ms ease 0ms, border-radius 300ms ease 0ms;
100
+ }
101
+
102
+ #dsm_general p.submit .button-primary:hover,
103
+ #dsm_general p.submit .button-primary:focus {
104
+ background: #fff;
105
+ color: #30323d;
106
+ border-color: #fff;
107
+ border-radius: 4px;
108
+ }
assets/img/icon-128x128.png ADDED
Binary file
includes/SupremeModulesLoader.php CHANGED
@@ -1,4 +1,150 @@
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  // Load custom CF7
3
  if( ! function_exists( 'dsm_et_builder_load_actions' )) {
4
  function dsm_et_builder_load_actions( $actions ) {
@@ -169,4 +315,21 @@ function dsm_wpcf7_select_form_tag_handler( $tag ) {
169
 
170
  return $html;
171
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  //End
1
  <?php
2
+
3
+ require_once plugin_dir_path( __FILE__ ) . 'class.settings-api.php';
4
+ require_once plugin_dir_path( __FILE__ ) . 'class.page-settings.php';
5
+
6
+ function dsm_setting_get_option( $option, $section, $default = '' ) {
7
+
8
+ $options = get_option( $section );
9
+
10
+ if ( isset( $options[$option] ) ) {
11
+ return $options[$option];
12
+ }
13
+
14
+ return $default;
15
+ }
16
+
17
+ if ( dsm_setting_get_option( 'dsm_use_scheduled_content', 'dsm_general' ) == 'on' ) {
18
+ add_filter('et_pb_all_fields_unprocessed_et_pb_section', 'dsm_add_section_setting');
19
+ function dsm_add_section_setting($fields_unprocessed) {
20
+ $fields = [];
21
+ $fields['dsm_section_schedule_visibility'] = array(
22
+ 'label' => esc_html__( 'Use Scheduled Content Visibility', 'dsm-supreme-modules-for-divi' ),
23
+ 'type' => 'yes_no_button',
24
+ 'option_category' => 'configuration',
25
+ 'options' => array(
26
+ 'off' => esc_html__( 'No', 'dsm-supreme-modules-for-divi' ),
27
+ 'on' => esc_html__( 'Yes', 'dsm-supreme-modules-for-divi' ),
28
+ ),
29
+ 'default_on_front' => 'off',
30
+ 'tab_slug' => 'custom_css',
31
+ 'toggle_slug' => 'visibility',
32
+ 'description' => esc_html__( 'Here you can choose whether your Section will show or hide depending on the given date/time.', 'dsm-supreme-modules-for-divi' ),
33
+ );
34
+ $fields['dsm_section_schedule_show_hide'] = array(
35
+ 'label' => esc_html__( 'Show or Hide Section', 'dsm-supreme-modules-for-divi' ),
36
+ 'type' => 'select',
37
+ 'option_category' => 'configuration',
38
+ 'options' => array(
39
+ 'start' => esc_html__( 'Show', 'dsm-supreme-modules-for-divi' ),
40
+ 'end' => esc_html__( 'Hide', 'dsm-supreme-modules-for-divi' ),
41
+ ),
42
+ 'default_on_front' => 'start',
43
+ 'tab_slug' => 'custom_css',
44
+ 'toggle_slug' => 'visibility',
45
+ 'show_if' => array(
46
+ 'dsm_section_schedule_visibility' => 'on',
47
+ ),
48
+ );
49
+ $fields['dsm_section_schedule_after_datetime'] = array(
50
+ 'default' => '',
51
+ 'label' => esc_html__( 'Schedule a Date/Time', 'dsm-supreme-modules-for-divi' ),
52
+ 'type' => 'date_picker',
53
+ 'tab_slug' => 'custom_css',
54
+ 'toggle_slug' => 'visibility',
55
+ 'show_if' => array(
56
+ 'dsm_section_schedule_visibility' => 'on',
57
+ ),
58
+ );
59
+ return array_merge($fields_unprocessed, $fields);
60
+ }
61
+
62
+ add_filter( 'et_module_shortcode_output', 'output_section', 10, 3 );
63
+ function output_section( $output, $render_slug, $module ) {
64
+ if ('et_pb_section' !== $render_slug) {
65
+ return $output;
66
+ } else if ('on' !== $module->props['dsm_section_schedule_visibility']) {
67
+ return $output;
68
+ } else {
69
+ $dsm_section_schedule_visibility = $module->props['dsm_section_schedule_visibility'];
70
+ $dsm_section_schedule_show_hide = $module->props['dsm_section_schedule_show_hide'];
71
+ $dsm_section_schedule_after_datetime = $module->props['dsm_section_schedule_after_datetime'];
72
+
73
+ $dsm_section_class_output = '';
74
+ if ($dsm_section_schedule_visibility == 'on') {
75
+ $dsm_section_class_output .= ' dsm_schedule_visibility';
76
+ }
77
+ $output = str_replace('class="et_pb_section ', 'data-dsm-' . esc_html($dsm_section_schedule_show_hide) . '="' . esc_html($dsm_section_schedule_after_datetime) . '" class="et_pb_section'. $dsm_section_class_output .' ', $output);
78
+ return $output;
79
+ }
80
+ }
81
+
82
+ add_filter('et_pb_all_fields_unprocessed_et_pb_row', 'dsm_add_row_setting');
83
+ function dsm_add_row_setting($fields_unprocessed) {
84
+ $fields = [];
85
+ $fields['dsm_row_schedule_visibility'] = array(
86
+ 'label' => esc_html__( 'Use Scheduled Content Visibility', 'dsm-supreme-modules-for-divi' ),
87
+ 'type' => 'yes_no_button',
88
+ 'option_category' => 'configuration',
89
+ 'options' => array(
90
+ 'off' => esc_html__( 'No', 'dsm-supreme-modules-for-divi' ),
91
+ 'on' => esc_html__( 'Yes', 'dsm-supreme-modules-for-divi' ),
92
+ ),
93
+ 'default_on_front' => 'off',
94
+ 'tab_slug' => 'custom_css',
95
+ 'toggle_slug' => 'visibility',
96
+ 'description' => esc_html__( 'Here you can choose whether your Row will show/hide depending on the given date/time.', 'dsm-supreme-modules-for-divi' ),
97
+ );
98
+ $fields['dsm_row_schedule_show_hide'] = array(
99
+ 'label' => esc_html__( 'Show or Hide Row', 'dsm-supreme-modules-for-divi' ),
100
+ 'type' => 'select',
101
+ 'option_category' => 'configuration',
102
+ 'options' => array(
103
+ 'start' => esc_html__( 'Show', 'dsm-supreme-modules-for-divi' ),
104
+ 'end' => esc_html__( 'Hide', 'dsm-supreme-modules-for-divi' ),
105
+ ),
106
+ 'default_on_front' => 'start',
107
+ 'tab_slug' => 'custom_css',
108
+ 'toggle_slug' => 'visibility',
109
+ 'show_if' => array(
110
+ 'dsm_row_schedule_visibility' => 'on',
111
+ ),
112
+ );
113
+ $fields['dsm_row_schedule_after_datetime'] = array(
114
+ 'default' => '',
115
+ 'label' => esc_html__( 'Schedule a Date/Time', 'dsm-supreme-modules-for-divi' ),
116
+ 'type' => 'date_picker',
117
+ 'tab_slug' => 'custom_css',
118
+ 'toggle_slug' => 'visibility',
119
+ 'show_if' => array(
120
+ 'dsm_row_schedule_visibility' => 'on',
121
+ ),
122
+ );
123
+ return array_merge($fields_unprocessed, $fields);
124
+ }
125
+
126
+ add_filter( 'et_module_shortcode_output', 'output_row', 10, 3 );
127
+ function output_row( $output, $render_slug, $module ) {
128
+ if ('et_pb_row' !== $render_slug) {
129
+ return $output;
130
+ } else if ('on' !== $module->props['dsm_row_schedule_visibility']) {
131
+ return $output;
132
+ } else {
133
+ $dsm_row_schedule_visibility = $module->props['dsm_row_schedule_visibility'];
134
+ $dsm_row_schedule_show_hide = $module->props['dsm_row_schedule_show_hide'];
135
+ $dsm_row_schedule_after_datetime = $module->props['dsm_row_schedule_after_datetime'];
136
+
137
+ $dsm_row_class_output = '';
138
+ if ($dsm_row_schedule_visibility == 'on') {
139
+ $dsm_row_class_output .= ' dsm_schedule_visibility';
140
+ }
141
+ $output = str_replace('class="et_pb_row ', 'data-dsm-' . esc_html($dsm_row_schedule_show_hide) . '="' . esc_html($dsm_row_schedule_after_datetime) . '" class="et_pb_row'. $dsm_row_class_output .' ', $output);
142
+ return $output;
143
+ }
144
+ }
145
+
146
+ }
147
+
148
  // Load custom CF7
149
  if( ! function_exists( 'dsm_et_builder_load_actions' )) {
150
  function dsm_et_builder_load_actions( $actions ) {
315
 
316
  return $html;
317
  }
318
+
319
+ function dsm_admin_footer_text( $footer_text ) {
320
+ $current_screen = get_current_screen();
321
+ $is_divi_supreme_screen = ( $current_screen && false !== strpos( $current_screen->id, 'toplevel_page_divi_supreme_settings' ) );
322
+
323
+ if ( $is_divi_supreme_screen ) {
324
+ $footer_text = sprintf(
325
+ __( 'If you like %1$s please leave us a %2$s rating. A huge thanks in advance!', 'dsm-supreme-modules-for-divi' ),
326
+ sprintf( '<strong>%s</strong>', esc_html__( 'Divi Supreme', 'dsm-supreme-modules-for-divi' ) ),
327
+ '<a href="https://wordpress.org/support/plugin/supreme-modules-for-divi/reviews/?rate=5#new-post" target="_blank" class="dsm-rating-link" data-rated="' . esc_attr__( 'Thanks :)', 'dsm-supreme-modules-for-divi' ) . '">&#9733;&#9733;&#9733;&#9733;&#9733;</a>'
328
+ );
329
+ }
330
+
331
+ return $footer_text;
332
+ }
333
+
334
+ add_filter('admin_footer_text', 'dsm_admin_footer_text');
335
  //End
includes/class.page-settings.php ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * WordPress settings API
5
+ *
6
+ */
7
+ if ( !class_exists('DSM_Settings' ) ):
8
+ class DSM_Settings {
9
+
10
+ private $settings_api;
11
+
12
+ function __construct() {
13
+ $this->settings_api = new DSM_Settings_API;
14
+
15
+ add_action( 'admin_init', array($this, 'admin_init') );
16
+ add_action( 'admin_menu', array($this, 'admin_menu') );
17
+ }
18
+
19
+ function admin_init() {
20
+
21
+ //set the settings
22
+ $this->settings_api->set_sections( $this->get_settings_sections() );
23
+ $this->settings_api->set_fields( $this->get_settings_fields() );
24
+
25
+ //initialize settings
26
+ $this->settings_api->admin_init();
27
+ }
28
+
29
+ function admin_menu() {
30
+ add_menu_page( __( 'Divi Supreme', 'dsm-supreme-modules-for-divi' ), __( 'Divi Supreme', 'dsm-supreme-modules-for-divi' ), 'manage_options', 'divi_supreme_settings', array($this, 'plugin_page'), plugins_url( 'supreme-modules-for-divi/assets/img/icon-128x128.png' ), 99 );
31
+ // add_submenu_page( 'options-general.php', 'Divi Supreme', 'Divi Supreme', 'manage_options', 'dsm_settings', array($this, 'plugin_page') );
32
+ }
33
+
34
+ function get_settings_sections() {
35
+ $sections = array(
36
+ array(
37
+ 'id' => 'dsm_general',
38
+ 'title' => __( 'Divi Supreme General Settings', 'dsm-supreme-modules-for-divi' ),
39
+ 'desc' => __( 'Divi Supreme features a huge collection of custom creative modules and extensions that can be used in the Divi Theme, Extra Theme and the Divi Builder. This is really a premium plugin that you can get for free on WordPress plugin repository. Here&apos;s where you can find extra features for Divi to help you build better websites.', 'dsm-supreme-modules-for-divi' ),
40
+ ),
41
+ /*
42
+ array(
43
+ 'id' => 'dsm_advanced',
44
+ 'title' => __( 'Advanced', 'dsm-supreme-modules-for-divi' )
45
+ )*/
46
+ );
47
+ return $sections;
48
+ }
49
+
50
+ /**
51
+ * Returns all the settings fields
52
+ *
53
+ * @return array settings fields
54
+ */
55
+ function get_settings_fields() {
56
+ $settings_fields = array(
57
+ 'dsm_general' => array(
58
+ array(
59
+ 'name' => 'dsm_section_subtitle',
60
+ 'class' => 'dsm-section-subtitle',
61
+ 'label' => __( '<h3>Divi Supreme Extensions</h3>', 'dsm-supreme-modules-for-divi' ),
62
+ 'type' => 'html',
63
+ ),
64
+ array(
65
+ 'name' => 'dsm_use_scheduled_content',
66
+ 'class' => 'dsm-settings-checkbox',
67
+ 'label' => __( 'Enable Scheduled Content on Section & Row', 'dsm-supreme-modules-for-divi' ),
68
+ 'desc' => __( '<span class="slider round"></span>', 'dsm-supreme-modules-for-divi' ),
69
+ 'type' => 'checkbox',
70
+ 'default' => 'off'
71
+ ),
72
+ ),
73
+ /*
74
+ 'dsm_advanced' => array(
75
+ array(
76
+ 'name' => 'color',
77
+ 'label' => __( 'Color', 'wedevs' ),
78
+ 'desc' => __( 'Color description', 'wedevs' ),
79
+ 'type' => 'color',
80
+ 'default' => ''
81
+ ),
82
+ array(
83
+ 'name' => 'password',
84
+ 'label' => __( 'Password', 'wedevs' ),
85
+ 'desc' => __( 'Password description', 'wedevs' ),
86
+ 'type' => 'password',
87
+ 'default' => '123'
88
+ ),
89
+ array(
90
+ 'name' => 'wysiwyg',
91
+ 'label' => __( 'Advanced Editor', 'wedevs' ),
92
+ 'desc' => __( 'WP_Editor description', 'wedevs' ),
93
+ 'type' => 'wysiwyg',
94
+ 'default' => ''
95
+ ),
96
+ array(
97
+ 'name' => 'multicheck',
98
+ 'label' => __( 'Multile checkbox', 'wedevs' ),
99
+ 'desc' => __( 'Multi checkbox description', 'wedevs' ),
100
+ 'type' => 'multicheck',
101
+ 'default' => array('one' => 'one', 'four' => 'four'),
102
+ 'options' => array(
103
+ 'one' => 'One',
104
+ 'two' => 'Two',
105
+ 'three' => 'Three',
106
+ 'four' => 'Four'
107
+ )
108
+ ),
109
+ )*/
110
+ );
111
+
112
+ return $settings_fields;
113
+ }
114
+
115
+ function plugin_page() {
116
+ echo '<div class="wrap">';
117
+
118
+ $this->settings_api->show_navigation();
119
+ $this->settings_api->show_forms();
120
+
121
+ echo '</div>';
122
+ }
123
+
124
+ /**
125
+ * Get all the pages
126
+ *
127
+ * @return array page names with key value pairs
128
+ */
129
+ function get_pages() {
130
+ $pages = get_pages();
131
+ $pages_options = array();
132
+ if ( $pages ) {
133
+ foreach ($pages as $page) {
134
+ $pages_options[$page->ID] = $page->post_title;
135
+ }
136
+ }
137
+
138
+ return $pages_options;
139
+ }
140
+
141
+ }
142
+ endif;
143
+ new DSM_Settings();
includes/class.settings-api.php ADDED
@@ -0,0 +1,649 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !class_exists( 'DSM_Settings_API' ) ):
4
+ class DSM_Settings_API {
5
+
6
+ /**
7
+ * settings sections array
8
+ *
9
+ * @var array
10
+ */
11
+ protected $settings_sections = array();
12
+
13
+ /**
14
+ * Settings fields array
15
+ *
16
+ * @var array
17
+ */
18
+ protected $settings_fields = array();
19
+
20
+ public function __construct() {
21
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
22
+ }
23
+
24
+ /**
25
+ * Enqueue scripts and styles
26
+ */
27
+ function admin_enqueue_scripts() {
28
+ wp_enqueue_style( 'wp-color-picker' );
29
+
30
+ wp_enqueue_media();
31
+ wp_enqueue_script( 'wp-color-picker' );
32
+ wp_enqueue_script( 'jquery' );
33
+ }
34
+
35
+ /**
36
+ * Set settings sections
37
+ *
38
+ * @param array $sections setting sections array
39
+ */
40
+ function set_sections( $sections ) {
41
+ $this->settings_sections = $sections;
42
+
43
+ return $this;
44
+ }
45
+
46
+ /**
47
+ * Add a single section
48
+ *
49
+ * @param array $section
50
+ */
51
+ function add_section( $section ) {
52
+ $this->settings_sections[] = $section;
53
+
54
+ return $this;
55
+ }
56
+
57
+ /**
58
+ * Set settings fields
59
+ *
60
+ * @param array $fields settings fields array
61
+ */
62
+ function set_fields( $fields ) {
63
+ $this->settings_fields = $fields;
64
+
65
+ return $this;
66
+ }
67
+
68
+ function add_field( $section, $field ) {
69
+ $defaults = array(
70
+ 'name' => '',
71
+ 'label' => '',
72
+ 'desc' => '',
73
+ 'type' => 'text'
74
+ );
75
+
76
+ $arg = wp_parse_args( $field, $defaults );
77
+ $this->settings_fields[$section][] = $arg;
78
+
79
+ return $this;
80
+ }
81
+
82
+ /**
83
+ * Initialize and registers the settings sections and fileds to WordPress
84
+ *
85
+ * Usually this should be called at `admin_init` hook.
86
+ *
87
+ * This function gets the initiated settings sections and fields. Then
88
+ * registers them to WordPress and ready for use.
89
+ */
90
+ function admin_init() {
91
+ //register settings sections
92
+ foreach ( $this->settings_sections as $section ) {
93
+ if ( false == get_option( $section['id'] ) ) {
94
+ add_option( $section['id'] );
95
+ }
96
+
97
+ if ( isset($section['desc']) && !empty($section['desc']) ) {
98
+ $section['desc'] = '<div class="inside">' . $section['desc'] . '</div>';
99
+ $callback = function() use ( $section ) {
100
+ echo str_replace( '"', '\"', $section['desc'] );
101
+ };
102
+ } else if ( isset( $section['callback'] ) ) {
103
+ $callback = $section['callback'];
104
+ } else {
105
+ $callback = null;
106
+ }
107
+
108
+ add_settings_section( $section['id'], $section['title'], $callback, $section['id'] );
109
+ }
110
+
111
+ //register settings fields
112
+ foreach ( $this->settings_fields as $section => $field ) {
113
+ foreach ( $field as $option ) {
114
+
115
+ $name = $option['name'];
116
+ $type = isset( $option['type'] ) ? $option['type'] : 'text';
117
+ $label = isset( $option['label'] ) ? $option['label'] : '';
118
+ $callback = isset( $option['callback'] ) ? $option['callback'] : array( $this, 'callback_' . $type );
119
+
120
+ $args = array(
121
+ 'id' => $name,
122
+ 'class' => isset( $option['class'] ) ? $option['class'] : $name,
123
+ 'label_for' => "{$section}[{$name}]",
124
+ 'desc' => isset( $option['desc'] ) ? $option['desc'] : '',
125
+ 'name' => $label,
126
+ 'section' => $section,
127
+ 'size' => isset( $option['size'] ) ? $option['size'] : null,
128
+ 'options' => isset( $option['options'] ) ? $option['options'] : '',
129
+ 'std' => isset( $option['default'] ) ? $option['default'] : '',
130
+ 'sanitize_callback' => isset( $option['sanitize_callback'] ) ? $option['sanitize_callback'] : '',
131
+ 'type' => $type,
132
+ 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : '',
133
+ 'min' => isset( $option['min'] ) ? $option['min'] : '',
134
+ 'max' => isset( $option['max'] ) ? $option['max'] : '',
135
+ 'step' => isset( $option['step'] ) ? $option['step'] : '',
136
+ );
137
+
138
+ add_settings_field( "{$section}[{$name}]", $label, $callback, $section, $section, $args );
139
+ }
140
+ }
141
+
142
+ // creates our settings in the options table
143
+ foreach ( $this->settings_sections as $section ) {
144
+ register_setting( $section['id'], $section['id'], array( $this, 'sanitize_options' ) );
145
+ }
146
+ }
147
+
148
+ /**
149
+ * Get field description for display
150
+ *
151
+ * @param array $args settings field args
152
+ */
153
+ public function get_field_description( $args ) {
154
+ if ( ! empty( $args['desc'] ) ) {
155
+ $desc = sprintf( '<p class="description">%s</p>', $args['desc'] );
156
+ } else {
157
+ $desc = '';
158
+ }
159
+
160
+ return $desc;
161
+ }
162
+
163
+ /**
164
+ * Displays a text field for a settings field
165
+ *
166
+ * @param array $args settings field args
167
+ */
168
+ function callback_text( $args ) {
169
+
170
+ $value = esc_attr( $this->get_option( $args['id'], $args['section'], $args['std'] ) );
171
+ $size = isset( $args['size'] ) && !is_null( $args['size'] ) ? $args['size'] : 'regular';
172
+ $type = isset( $args['type'] ) ? $args['type'] : 'text';
173
+ $placeholder = empty( $args['placeholder'] ) ? '' : ' placeholder="' . $args['placeholder'] . '"';
174
+
175
+ $html = sprintf( '<input type="%1$s" class="%2$s-text" id="%3$s[%4$s]" name="%3$s[%4$s]" value="%5$s"%6$s/>', $type, $size, $args['section'], $args['id'], $value, $placeholder );
176
+ $html .= $this->get_field_description( $args );
177
+
178
+ echo $html;
179
+ }
180
+
181
+ /**
182
+ * Displays a url field for a settings field
183
+ *
184
+ * @param array $args settings field args
185
+ */
186
+ function callback_url( $args ) {
187
+ $this->callback_text( $args );
188
+ }
189
+
190
+ /**
191
+ * Displays a number field for a settings field
192
+ *
193
+ * @param array $args settings field args
194
+ */
195
+ function callback_number( $args ) {
196
+ $value = esc_attr( $this->get_option( $args['id'], $args['section'], $args['std'] ) );
197
+ $size = isset( $args['size'] ) && !is_null( $args['size'] ) ? $args['size'] : 'regular';
198
+ $type = isset( $args['type'] ) ? $args['type'] : 'number';
199
+ $placeholder = empty( $args['placeholder'] ) ? '' : ' placeholder="' . $args['placeholder'] . '"';
200
+ $min = ( $args['min'] == '' ) ? '' : ' min="' . $args['min'] . '"';
201
+ $max = ( $args['max'] == '' ) ? '' : ' max="' . $args['max'] . '"';
202
+ $step = ( $args['step'] == '' ) ? '' : ' step="' . $args['step'] . '"';
203
+
204
+ $html = sprintf( '<input type="%1$s" class="%2$s-number" id="%3$s[%4$s]" name="%3$s[%4$s]" value="%5$s"%6$s%7$s%8$s%9$s/>', $type, $size, $args['section'], $args['id'], $value, $placeholder, $min, $max, $step );
205
+ $html .= $this->get_field_description( $args );
206
+
207
+ echo $html;
208
+ }
209
+
210
+ /**
211
+ * Displays a checkbox for a settings field
212
+ *
213
+ * @param array $args settings field args
214
+ */
215
+ function callback_checkbox( $args ) {
216
+
217
+ $value = esc_attr( $this->get_option( $args['id'], $args['section'], $args['std'] ) );
218
+
219
+ $html = '<fieldset>';
220
+ $html .= sprintf( '<label for="wpuf-%1$s[%2$s]">', $args['section'], $args['id'] );
221
+ $html .= sprintf( '<input type="hidden" name="%1$s[%2$s]" value="off" />', $args['section'], $args['id'] );
222
+ $html .= sprintf( '<input type="checkbox" class="checkbox" id="wpuf-%1$s[%2$s]" name="%1$s[%2$s]" value="on" %3$s />', $args['section'], $args['id'], checked( $value, 'on', false ) );
223
+ $html .= sprintf( '%1$s</label>', $args['desc'] );
224
+ $html .= '</fieldset>';
225
+
226
+ echo $html;
227
+ }
228
+
229
+ /**
230
+ * Displays a multicheckbox for a settings field
231
+ *
232
+ * @param array $args settings field args
233
+ */
234
+ function callback_multicheck( $args ) {
235
+
236
+ $value = $this->get_option( $args['id'], $args['section'], $args['std'] );
237
+ $html = '<fieldset>';
238
+ $html .= sprintf( '<input type="hidden" name="%1$s[%2$s]" value="" />', $args['section'], $args['id'] );
239
+ foreach ( $args['options'] as $key => $label ) {
240
+ $checked = isset( $value[$key] ) ? $value[$key] : '0';
241
+ $html .= sprintf( '<label for="wpuf-%1$s[%2$s][%3$s]">', $args['section'], $args['id'], $key );
242
+ $html .= sprintf( '<input type="checkbox" class="checkbox" id="wpuf-%1$s[%2$s][%3$s]" name="%1$s[%2$s][%3$s]" value="%3$s" %4$s />', $args['section'], $args['id'], $key, checked( $checked, $key, false ) );
243
+ $html .= sprintf( '%1$s</label><br>', $label );
244
+ }
245
+
246
+ $html .= $this->get_field_description( $args );
247
+ $html .= '</fieldset>';
248
+
249
+ echo $html;
250
+ }
251
+
252
+ /**
253
+ * Displays a radio button for a settings field
254
+ *
255
+ * @param array $args settings field args
256
+ */
257
+ function callback_radio( $args ) {
258
+
259
+ $value = $this->get_option( $args['id'], $args['section'], $args['std'] );
260
+ $html = '<fieldset>';
261
+
262
+ foreach ( $args['options'] as $key => $label ) {
263
+ $html .= sprintf( '<label for="wpuf-%1$s[%2$s][%3$s]">', $args['section'], $args['id'], $key );
264
+ $html .= sprintf( '<input type="radio" class="radio" id="wpuf-%1$s[%2$s][%3$s]" name="%1$s[%2$s]" value="%3$s" %4$s />', $args['section'], $args['id'], $key, checked( $value, $key, false ) );
265
+ $html .= sprintf( '%1$s</label><br>', $label );
266
+ }
267
+
268
+ $html .= $this->get_field_description( $args );
269
+ $html .= '</fieldset>';
270
+
271
+ echo $html;
272
+ }
273
+
274
+ /**
275
+ * Displays a selectbox for a settings field
276
+ *
277
+ * @param array $args settings field args
278
+ */
279
+ function callback_select( $args ) {
280
+
281
+ $value = esc_attr( $this->get_option( $args['id'], $args['section'], $args['std'] ) );
282
+ $size = isset( $args['size'] ) && !is_null( $args['size'] ) ? $args['size'] : 'regular';
283
+ $html = sprintf( '<select class="%1$s" name="%2$s[%3$s]" id="%2$s[%3$s]">', $size, $args['section'], $args['id'] );
284
+
285
+ foreach ( $args['options'] as $key => $label ) {
286
+ $html .= sprintf( '<option value="%s"%s>%s</option>', $key, selected( $value, $key, false ), $label );
287
+ }
288
+
289
+ $html .= sprintf( '</select>' );
290
+ $html .= $this->get_field_description( $args );
291
+
292
+ echo $html;
293
+ }
294
+
295
+ /**
296
+ * Displays a textarea for a settings field
297
+ *
298
+ * @param array $args settings field args
299
+ */
300
+ function callback_textarea( $args ) {
301
+
302
+ $value = esc_textarea( $this->get_option( $args['id'], $args['section'], $args['std'] ) );
303
+ $size = isset( $args['size'] ) && !is_null( $args['size'] ) ? $args['size'] : 'regular';
304
+ $placeholder = empty( $args['placeholder'] ) ? '' : ' placeholder="'.$args['placeholder'].'"';
305
+
306
+ $html = sprintf( '<textarea rows="5" cols="55" class="%1$s-text" id="%2$s[%3$s]" name="%2$s[%3$s]"%4$s>%5$s</textarea>', $size, $args['section'], $args['id'], $placeholder, $value );
307
+ $html .= $this->get_field_description( $args );
308
+
309
+ echo $html;
310
+ }
311
+
312
+ /**
313
+ * Displays the html for a settings field
314
+ *
315
+ * @param array $args settings field args
316
+ * @return string
317
+ */
318
+ function callback_html( $args ) {
319
+ echo $this->get_field_description( $args );
320
+ }
321
+
322
+ /**
323
+ * Displays a rich text textarea for a settings field
324
+ *
325
+ * @param array $args settings field args
326
+ */
327
+ function callback_wysiwyg( $args ) {
328
+
329
+ $value = $this->get_option( $args['id'], $args['section'], $args['std'] );
330
+ $size = isset( $args['size'] ) && !is_null( $args['size'] ) ? $args['size'] : '500px';
331
+
332
+ echo '<div style="max-width: ' . $size . ';">';
333
+
334
+ $editor_settings = array(
335
+ 'teeny' => true,
336
+ 'textarea_name' => $args['section'] . '[' . $args['id'] . ']',
337
+ 'textarea_rows' => 10
338
+ );
339
+
340
+ if ( isset( $args['options'] ) && is_array( $args['options'] ) ) {
341
+ $editor_settings = array_merge( $editor_settings, $args['options'] );
342
+ }
343
+
344
+ wp_editor( $value, $args['section'] . '-' . $args['id'], $editor_settings );
345
+
346
+ echo '</div>';
347
+
348
+ echo $this->get_field_description( $args );
349
+ }
350
+
351
+ /**
352
+ * Displays a file upload field for a settings field
353
+ *
354
+ * @param array $args settings field args
355
+ */
356
+ function callback_file( $args ) {
357
+
358
+ $value = esc_attr( $this->get_option( $args['id'], $args['section'], $args['std'] ) );
359
+ $size = isset( $args['size'] ) && !is_null( $args['size'] ) ? $args['size'] : 'regular';
360
+ $id = $args['section'] . '[' . $args['id'] . ']';
361
+ $label = isset( $args['options']['button_label'] ) ? $args['options']['button_label'] : __( 'Choose File' );
362
+
363
+ $html = sprintf( '<input type="text" class="%1$s-text wpsa-url" id="%2$s[%3$s]" name="%2$s[%3$s]" value="%4$s"/>', $size, $args['section'], $args['id'], $value );
364
+ $html .= '<input type="button" class="button wpsa-browse" value="' . $label . '" />';
365
+ $html .= $this->get_field_description( $args );
366
+
367
+ echo $html;
368
+ }
369
+
370
+ /**
371
+ * Displays a password field for a settings field
372
+ *
373
+ * @param array $args settings field args
374
+ */
375
+ function callback_password( $args ) {
376
+
377
+ $value = esc_attr( $this->get_option( $args['id'], $args['section'], $args['std'] ) );
378
+ $size = isset( $args['size'] ) && !is_null( $args['size'] ) ? $args['size'] : 'regular';
379
+
380
+ $html = sprintf( '<input type="password" class="%1$s-text" id="%2$s[%3$s]" name="%2$s[%3$s]" value="%4$s"/>', $size, $args['section'], $args['id'], $value );
381
+ $html .= $this->get_field_description( $args );
382
+
383
+ echo $html;
384
+ }
385
+
386
+ /**
387
+ * Displays a color picker field for a settings field
388
+ *
389
+ * @param array $args settings field args
390
+ */
391
+ function callback_color( $args ) {
392
+
393
+ $value = esc_attr( $this->get_option( $args['id'], $args['section'], $args['std'] ) );
394
+ $size = isset( $args['size'] ) && !is_null( $args['size'] ) ? $args['size'] : 'regular';
395
+
396
+ $html = sprintf( '<input type="text" class="%1$s-text wp-color-picker-field" id="%2$s[%3$s]" name="%2$s[%3$s]" value="%4$s" data-default-color="%5$s" />', $size, $args['section'], $args['id'], $value, $args['std'] );
397
+ $html .= $this->get_field_description( $args );
398
+
399
+ echo $html;
400
+ }
401
+
402
+
403
+ /**
404
+ * Displays a select box for creating the pages select box
405
+ *
406
+ * @param array $args settings field args
407
+ */
408
+ function callback_pages( $args ) {
409
+
410
+ $dropdown_args = array(
411
+ 'selected' => esc_attr($this->get_option($args['id'], $args['section'], $args['std'] ) ),
412
+ 'name' => $args['section'] . '[' . $args['id'] . ']',
413
+ 'id' => $args['section'] . '[' . $args['id'] . ']',
414
+ 'echo' => 0
415
+ );
416
+ $html = wp_dropdown_pages( $dropdown_args );
417
+ echo $html;
418
+ }
419
+
420
+ /**
421
+ * Sanitize callback for Settings API
422
+ *
423
+ * @return mixed
424
+ */
425
+ function sanitize_options( $options ) {
426
+
427
+ if ( !$options ) {
428
+ return $options;
429
+ }
430
+
431
+ foreach( $options as $option_slug => $option_value ) {
432
+ $sanitize_callback = $this->get_sanitize_callback( $option_slug );
433
+
434
+ // If callback is set, call it
435
+ if ( $sanitize_callback ) {
436
+ $options[ $option_slug ] = call_user_func( $sanitize_callback, $option_value );
437
+ continue;
438
+ }
439
+ }
440
+
441
+ return $options;
442
+ }
443
+
444
+ /**
445
+ * Get sanitization callback for given option slug
446
+ *
447
+ * @param string $slug option slug
448
+ *
449
+ * @return mixed string or bool false
450
+ */
451
+ function get_sanitize_callback( $slug = '' ) {
452
+ if ( empty( $slug ) ) {
453
+ return false;
454
+ }
455
+
456
+ // Iterate over registered fields and see if we can find proper callback
457
+ foreach( $this->settings_fields as $section => $options ) {
458
+ foreach ( $options as $option ) {
459
+ if ( $option['name'] != $slug ) {
460
+ continue;
461
+ }
462
+
463
+ // Return the callback name
464
+ return isset( $option['sanitize_callback'] ) && is_callable( $option['sanitize_callback'] ) ? $option['sanitize_callback'] : false;
465
+ }
466
+ }
467
+
468
+ return false;
469
+ }
470
+
471
+ /**
472
+ * Get the value of a settings field
473
+ *
474
+ * @param string $option settings field name
475
+ * @param string $section the section name this field belongs to
476
+ * @param string $default default text if it's not found
477
+ * @return string
478
+ */
479
+ function get_option( $option, $section, $default = '' ) {
480
+
481
+ $options = get_option( $section );
482
+
483
+ if ( isset( $options[$option] ) ) {
484
+ return $options[$option];
485
+ }
486
+
487
+ return $default;
488
+ }
489
+
490
+ /**
491
+ * Show navigations as tab
492
+ *
493
+ * Shows all the settings section labels as tab
494
+ */
495
+ function show_navigation() {
496
+ $html = '<h2 class="nav-tab-wrapper">';
497
+
498
+ $count = count( $this->settings_sections );
499
+
500
+ // don't show the navigation if only one section exists
501
+ if ( $count === 1 ) {
502
+ return;
503
+ }
504
+
505
+ foreach ( $this->settings_sections as $tab ) {
506
+ $html .= sprintf( '<a href="#%1$s" class="nav-tab" id="%1$s-tab">%2$s</a>', $tab['id'], $tab['title'] );
507
+ }
508
+
509
+ $html .= '</h2>';
510
+
511
+ echo $html;
512
+ }
513
+
514
+ /**
515
+ * Show the section settings forms
516
+ *
517
+ * This function displays every sections in a different form
518
+ */
519
+ function show_forms() {
520
+ ?>
521
+ <div class="metabox-holder">
522
+ <?php foreach ( $this->settings_sections as $form ) { ?>
523
+ <div id="<?php echo $form['id']; ?>" class="group" style="display: none;">
524
+ <form method="post" action="options.php">
525
+ <?php
526
+ do_action( 'wsa_form_top_' . $form['id'], $form );
527
+ settings_fields( $form['id'] );
528
+ do_settings_sections( $form['id'] );
529
+ do_action( 'wsa_form_bottom_' . $form['id'], $form );
530
+ if ( isset( $this->settings_fields[ $form['id'] ] ) ):
531
+ ?>
532
+ <div style="padding-left: 10px">
533
+ <?php submit_button(); ?>
534
+ </div>
535
+ <?php endif; ?>
536
+ </form>
537
+ </div>
538
+ <?php } ?>
539
+ </div>
540
+ <?php
541
+ $this->script();
542
+ }
543
+
544
+ /**
545
+ * Tabbable JavaScript codes & Initiate Color Picker
546
+ *
547
+ * This code uses localstorage for displaying active tabs
548
+ */
549
+ function script() {
550
+ ?>
551
+ <script>
552
+ jQuery(document).ready(function($) {
553
+ //Initiate Color Picker
554
+ $('.wp-color-picker-field').wpColorPicker();
555
+
556
+ // Switches option sections
557
+ $('.group').hide();
558
+ var activetab = '';
559
+ if (typeof(localStorage) != 'undefined' ) {
560
+ activetab = localStorage.getItem("activetab");
561
+ }
562
+
563
+ //if url has section id as hash then set it as active or override the current local storage value
564
+ if(window.location.hash){
565
+ activetab = window.location.hash;
566
+ if (typeof(localStorage) != 'undefined' ) {
567
+ localStorage.setItem("activetab", activetab);
568
+ }
569
+ }
570
+
571
+ if (activetab != '' && $(activetab).length ) {
572
+ $(activetab).fadeIn();
573
+ } else {
574
+ $('.group:first').fadeIn();
575
+ }
576
+ $('.group .collapsed').each(function(){
577
+ $(this).find('input:checked').parent().parent().parent().nextAll().each(
578
+ function(){
579
+ if ($(this).hasClass('last')) {
580
+ $(this).removeClass('hidden');
581
+ return false;
582
+ }
583
+ $(this).filter('.hidden').removeClass('hidden');
584
+ });
585
+ });
586
+
587
+ if (activetab != '' && $(activetab + '-tab').length ) {
588
+ $(activetab + '-tab').addClass('nav-tab-active');
589
+ }
590
+ else {
591
+ $('.nav-tab-wrapper a:first').addClass('nav-tab-active');
592
+ }
593
+ $('.nav-tab-wrapper a').click(function(evt) {
594
+ $('.nav-tab-wrapper a').removeClass('nav-tab-active');
595
+ $(this).addClass('nav-tab-active').blur();
596
+ var clicked_group = $(this).attr('href');
597
+ if (typeof(localStorage) != 'undefined' ) {
598
+ localStorage.setItem("activetab", $(this).attr('href'));
599
+ }
600
+ $('.group').hide();
601
+ $(clicked_group).fadeIn();
602
+ evt.preventDefault();
603
+ });
604
+
605
+ $('.wpsa-browse').on('click', function (event) {
606
+ event.preventDefault();
607
+
608
+ var self = $(this);
609
+
610
+ // Create the media frame.
611
+ var file_frame = wp.media.frames.file_frame = wp.media({
612
+ title: self.data('uploader_title'),
613
+ button: {
614
+ text: self.data('uploader_button_text'),
615
+ },
616
+ multiple: false
617
+ });
618
+
619
+ file_frame.on('select', function () {
620
+ attachment = file_frame.state().get('selection').first().toJSON();
621
+ self.prev('.wpsa-url').val(attachment.url).change();
622
+ });
623
+
624
+ // Finally, open the modal
625
+ file_frame.open();
626
+ });
627
+ });
628
+ </script>
629
+ <?php
630
+ $this->_style_fix();
631
+ }
632
+
633
+ function _style_fix() {
634
+ global $wp_version;
635
+
636
+ if (version_compare($wp_version, '3.8', '<=')):
637
+ ?>
638
+ <style type="text/css">
639
+ /** WordPress 3.8 Fix **/
640
+ .form-table th { padding: 20px 10px; }
641
+ #wpbody-content .metabox-holder { padding-top: 5px; }
642
+ </style>
643
+ <?php
644
+ endif;
645
+ }
646
+
647
+ }
648
+
649
+ endif;
readme.txt CHANGED
@@ -5,7 +5,7 @@ Donate link: https://suprememodules.com/
5
  Requires at least: 4.5
6
  Tested up to: 4.9
7
  Requires PHP: 5.6
8
- Stable tag: 1.1.1
9
  License: GPLv2
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -29,7 +29,10 @@ Divi Supreme contains 11 Divi custom modules and more to come soon.
29
  - Supreme Contact Form 7 - Big fan of Contact Form 7 plugin? Now with Supreme Contact Form 7, you can select your contact Form from the dropdown list without having to go back and forth switching between Visual Builder and Contact Form 7 setting page copying the shortcode and adding to the Divi Code Module. Style your Input Fields, Button, Labels, Validation, Error Messages and more!
30
  - Supreme Embed Google Map - Embed Google Map right into your Divi's site easily without having to worry about anything else.
31
 
32
- Many more Divi Modules coming soon...
 
 
 
33
 
34
  View [Demo for Divi Supreme Modules](https://suprememodules.com/).
35
 
@@ -71,10 +74,15 @@ You must have Divi theme, Extra Theme or the Divi Builder installed in order for
71
 
72
  **Does it work with the Divi Visual Builder?**
73
 
74
- YES!
75
 
76
  == Changelog ==
77
 
 
 
 
 
 
78
  = 1.1.1 - 05.10.2018 =
79
  * Added: Supreme Embed Twitter Timeline Module.
80
  * Fixed: Supreme Facebook Feed height not rendering on frontend.
5
  Requires at least: 4.5
6
  Tested up to: 4.9
7
  Requires PHP: 5.6
8
+ Stable tag: 1.1.2
9
  License: GPLv2
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
29
  - Supreme Contact Form 7 - Big fan of Contact Form 7 plugin? Now with Supreme Contact Form 7, you can select your contact Form from the dropdown list without having to go back and forth switching between Visual Builder and Contact Form 7 setting page copying the shortcode and adding to the Divi Code Module. Style your Input Fields, Button, Labels, Validation, Error Messages and more!
30
  - Supreme Embed Google Map - Embed Google Map right into your Divi's site easily without having to worry about anything else.
31
 
32
+ Divi Supreme Extentions
33
+ - Scheduled Content Visibility - This will extend the Visibility option in the the Section/Row's custom setting to allow you to show or hide the section or row with a specify date/time.
34
+
35
+ Many more Divi Modules and Extensions coming soon...
36
 
37
  View [Demo for Divi Supreme Modules](https://suprememodules.com/).
38
 
74
 
75
  **Does it work with the Divi Visual Builder?**
76
 
77
+ YES! At least Divi 3.1 onwards where they introduced the Divi Developer API.
78
 
79
  == Changelog ==
80
 
81
+ = 1.1.2 - 07.10.2018 =
82
+ * Added: Scheduled Content Visibility for Section and Row.
83
+ * Added: Divi Supreme Option Page to the admin menu for enabling/disabling features.
84
+ * Enhanced: Typing Effect will execute only when visitor scroll into view.
85
+
86
  = 1.1.1 - 05.10.2018 =
87
  * Added: Supreme Embed Twitter Timeline Module.
88
  * Fixed: Supreme Facebook Feed height not rendering on frontend.
scripts/frontend-bundle.min.js CHANGED
@@ -1 +1 @@
1
- !function(t){var n={};function i(o){if(n[o])return n[o].exports;var e=n[o]={i:o,l:!1,exports:{}};return t[o].call(e.exports,e,e.exports,i),e.l=!0,e.exports}i.m=t,i.c=n,i.d=function(t,n,o){i.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:o})},i.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(n,"a",n),n},i.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},i.p="/",i(i.s=318)}({318:function(t,n,i){i(56),i(55),i(71),i(72),i(319),i(320),i(321),i(51),i(322),i(54),i(52),i(53),i(323),t.exports=i(324)},319:function(t,n){},320:function(t,n){},321:function(t,n){},322:function(t,n){},323:function(t,n){},324:function(t,n){jQuery(function(t){var n=t(".dsm-typing-effect .dsm-typing");t(".dsm-typing-effect").length&&t(n).each(function(n,i){var o=t(this).data("dsm-typing-strings").split("|"),e=t(this).data("dsm-typing-loop"),c=parseFloat(t(this).data("dsm-typing-speed"),10),a=parseFloat(t(this).data("dsm-typing-backdelay"),10),s=parseFloat(t(this).data("dsm-typing-backspeed"),10);new Typed(this,{strings:o,loop:e,typeSpeed:c,backSpeed:s,backDelay:a,contentType:"html"})}),t(".dsm_contact_form_7_btn_icon").length&&t(".dsm_contact_form_7_btn_icon").each(function(n,i){var o=t(this).attr("data-dsm-btn-icon");t(this).find(".wpcf7-submit").addClass("et_pb_custom_button_icon"),t(this).find(".wpcf7-submit").attr("data-icon",o)})})},51:function(t,n){},52:function(t,n){},53:function(t,n){},54:function(t,n){},55:function(t,n){},56:function(t,n){},71:function(t,n){},72:function(t,n){}});
1
+ !function(t){var n={};function e(i){if(n[i])return n[i].exports;var s=n[i]={i,l:!1,exports:{}};return t[i].call(s.exports,s,s.exports,e),s.l=!0,s.exports}e.m=t,e.c=n,e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},e.p="/",e(e.s=318)}({318:function(t,n,e){e(56),e(55),e(71),e(72),e(319),e(320),e(321),e(51),e(322),e(54),e(52),e(53),e(323),t.exports=e(324)},319:function(t,n){},320:function(t,n){},321:function(t,n){},322:function(t,n){},323:function(t,n){},324:function(t,n){jQuery(function(t){var n=t(".dsm-typing-effect .dsm-typing");t(".dsm-typing-effect").length&&t(n).each(function(n,e){var i=t(this).data("dsm-typing-strings").split("|"),s=t(this).data("dsm-typing-loop"),a=parseFloat(t(this).data("dsm-typing-speed"),10),r=parseFloat(t(this).data("dsm-typing-backdelay"),10),o=this,d={strings:i,loop:s,typeSpeed:a,backSpeed:parseFloat(t(this).data("dsm-typing-backspeed"),10),backDelay:r,contentType:"html"},c="";t(this).waypoint({handler:function(t){"down"===t?c=new Typed(o,d):c.destroy()},offset:"100%"})}),t(".dsm_contact_form_7_btn_icon").length&&t(".dsm_contact_form_7_btn_icon").each(function(n,e){var i=t(this).attr("data-dsm-btn-icon");t(this).find(".wpcf7-submit").addClass("et_pb_custom_button_icon"),t(this).find(".wpcf7-submit").attr("data-icon",i)}),function(){var n=[],e=new Date;Date.prototype.yyyymmdd=function(){var t=this.getMonth()+1,n=this.getDate();return[this.getFullYear(),(t>9?"":"0")+t,(n>9?"":"0")+n].join("-")};var i=e.yyyymmdd();if(t(".dsm_schedule_visibility").each(function(){var s=t(this).data("dsm-end"),a=d(t(this).data("dsm-start"),this),r=d(s,this);function o(t){var i=t-e;i<864e5&&i>1e3&&n.push(i)}function d(n,s){if(n){String(n).length<6&&String(n).indexOf(":")>-1&&(n=i+" "+String(n)),-1==String(n).indexOf(":")&&(n+=" 00:00");var a=n.split(":"),r=String(a.slice(0,1)),o=r.substr(r.length-2),d=a.slice(1),c=o<24&&d<60;if("Invalid Date"==(u=new Date(n)))var u=function(t){var n,e=new Date(NaN);return t.substr(0,t.indexOf(" ")),parts=/^\s*(\d{4})-(\d\d)-(\d\d)?.(\d\d)?.(\d\d)\s*$/.exec(t),parts&&(n=+parts[2],e.setFullYear(parts[1],n-1,parts[3]),n!=e.getMonth()+1&&e.setTime(NaN),e=new Date(parts[1],n-1,parts[3],parts[4],parts[5])),e}(n);return"Invalid Date"!=u&&c||t(s).addClass("error").attr("title",'"'+n+'" date is incorrect; please use YYYY-MM-DD HH:MM format'),u.getTime()}return e.getTime()}o(a),o(r),a<r&&(a>e||r<e)||a>r&&a>=e&&r<=e?(t(this).hide(),t(this).addClass("dsm-hidden")):(t(this).show(),t(this).removeClass("dsm-hidden"))}),n.length>0){var s=Math.min.apply(null,n);console.log("next run of timeit function is in "+s/1e3+"seconds"),setTimeout(function(){timeit()},s)}}()})},51:function(t,n){},52:function(t,n){},53:function(t,n){},54:function(t,n){},55:function(t,n){},56:function(t,n){},71:function(t,n){},72:function(t,n){}});
supreme-modules-for-divi.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Divi Supreme Modules
4
  Plugin URI: https://suprememodules.com
5
  Description: Supreme Modules enhances the experience and features found on Divi and extend with custom creative modules to help you build amazing websites.
6
- Version: 1.1.1
7
  Author: Supreme Modules
8
  Author URI: https://suprememodules.com/about-us/
9
  License: GPL2
@@ -44,8 +44,14 @@ function dsm_scripts(){
44
  wp_register_script('dsm-facebook', plugin_dir_url( __FILE__ ) . 'assets/js/dsm-facebook.js', array(), null, true );
45
  wp_register_script('dsm-twitter-embed', 'https://platform.twitter.com/widgets.js', array(), null, true );
46
  if ( et_core_is_fb_enabled() ) {
47
- wp_enqueue_style('dsm-admin', plugin_dir_url( __FILE__ ) . 'assets/css/dsm-admin.css' );
48
  }
49
  }
50
 
51
- add_action('wp_enqueue_scripts', 'dsm_scripts');
 
 
 
 
 
 
3
  Plugin Name: Divi Supreme Modules
4
  Plugin URI: https://suprememodules.com
5
  Description: Supreme Modules enhances the experience and features found on Divi and extend with custom creative modules to help you build amazing websites.
6
+ Version: 1.1.2
7
  Author: Supreme Modules
8
  Author URI: https://suprememodules.com/about-us/
9
  License: GPL2
44
  wp_register_script('dsm-facebook', plugin_dir_url( __FILE__ ) . 'assets/js/dsm-facebook.js', array(), null, true );
45
  wp_register_script('dsm-twitter-embed', 'https://platform.twitter.com/widgets.js', array(), null, true );
46
  if ( et_core_is_fb_enabled() ) {
47
+ wp_enqueue_style('dsm-et-admin', plugin_dir_url( __FILE__ ) . 'assets/css/dsm-et-admin.css' );
48
  }
49
  }
50
 
51
+ add_action('wp_enqueue_scripts', 'dsm_scripts');
52
+
53
+ function load_custom_wp_admin_style() {
54
+ wp_enqueue_style('dsm-plugin', plugin_dir_url( __FILE__ ) . 'assets/css/dsm-plugin.css' );
55
+ }
56
+
57
+ add_action('admin_enqueue_scripts', 'load_custom_wp_admin_style');