PluginProbe ʕ •ᴥ•ʔ
Shortcodes and extra features for Phlox theme / 2.5.8
Shortcodes and extra features for Phlox theme v2.5.8
2.17.21 2.17.20 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.6 1.0.9 1.1.0 1.3.0 1.3.1 1.3.10 1.3.14 1.3.2 1.3.3 1.3.6 1.4.0 1.4.1 1.4.2 1.5.0 1.5.2 1.6.0 1.6.2 1.6.4 1.7.0 1.7.2 2.10.0 2.10.1 2.10.3 2.10.5 2.10.7 2.10.8 2.10.9 2.11.0 2.11.1 2.11.2 2.12.0 2.14.0 2.15.0 2.15.2 2.15.4 2.15.5 2.15.6 2.15.7 2.15.8 2.15.9 2.16.0 2.16.1 2.16.2 2.16.3 2.16.4 2.17.0 2.17.1 2.17.12 2.17.13 2.17.14 2.17.15 2.17.16 2.17.2 2.17.3 2.17.4 2.17.5 2.17.6 2.17.8 2.17.9 2.4.12 2.4.13 2.4.14 2.4.16 2.4.18 2.4.19 2.4.9 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.14 2.5.15 2.5.16 2.5.17 2.5.19 2.5.2 2.5.20 2.5.3 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.10 2.6.12 2.6.13 2.6.14 2.6.15 2.6.16 2.6.17 2.6.19 2.6.2 2.6.20 2.6.4 2.6.5 2.6.7 2.7.0 2.7.1 2.7.10 2.7.11 2.7.12 2.7.13 2.7.14 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.8.0 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.9 2.9.0 2.9.12 2.9.14 2.9.15 2.9.16 2.9.17 2.9.18 2.9.19 2.9.2 2.9.20 2.9.21 2.9.22 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8
auxin-elements / includes / classes / class-auxin-siteorigin-widget.php
auxin-elements / includes / classes Last commit date
class-auxels-admin-assets.php 6 years ago class-auxels-archive-menu-links.php 6 years ago class-auxels-import-parser.php 8 years ago class-auxels-import.php 6 years ago class-auxels-search-post-type.php 6 years ago class-auxin-admin-dashboard.php 6 years ago class-auxin-demo-importer.php 6 years ago class-auxin-dependency-sorting.php 8 years ago class-auxin-import.php 6 years ago class-auxin-install.php 6 years ago class-auxin-master-nav-menu-admin.php 6 years ago class-auxin-page-template.php 6 years ago class-auxin-permalink.php 6 years ago class-auxin-plugin-requirements.php 6 years ago class-auxin-post-type-base.php 6 years ago class-auxin-siteorigin-widget.php 6 years ago class-auxin-svg-support-allowedattributes.php 7 years ago class-auxin-svg-support-allowedtags.php 7 years ago class-auxin-svg-support.php 7 years ago class-auxin-walker-nav-menu-back.php 6 years ago class-auxin-welcome-sections.php 6 years ago class-auxin-welcome.php 6 years ago class-auxin-whitelabel.php 6 years ago class-auxin-widget-indie.php 6 years ago class-auxin-widget-shortcode-map.php 6 years ago class-auxin-widget.php 6 years ago
class-auxin-siteorigin-widget.php
247 lines
1 <?php
2 /**
3 * A class for creating SiteOrigin widgets from the master widgets list
4 *
5 *
6 * @package Auxin
7 * @license LICENSE.txt
8 * @author averta
9 * @link http://phlox.pro/
10 * @copyright (c) 2010-2020 averta
11 */
12
13 // no direct access allowed
14 if ( ! defined('ABSPATH') ) exit;
15
16 /*--------------------------------*/
17
18 if( ! class_exists( 'Auxin_SiteOrigin_Widget' ) && class_exists( 'SiteOrigin_Widget') ) :
19
20 class Auxin_SiteOrigin_Widget extends SiteOrigin_Widget {
21
22
23 private $widget_info = array();
24 private $widget_fields = array();
25 public $widget_fun_name;
26
27 /**
28 * Setups new SiteOrigin Widget
29 * @param Array $widget_info
30 */
31 function __construct( $widget_info ) {
32
33 $this->widget_info = $widget_info;
34 $this->widget_fields = $widget_info['params'];
35 $this->widget_fun_name = $widget_info['auxin_output_callback'];
36
37 parent::__construct(
38 // The unique id for your widget.
39 $widget_info['base'],
40
41 // The name of the widget for display purposes.
42 $widget_info['name'],
43
44 // The $widget_options array, which is passed through to WP_Widget.
45 // It has a couple of extras like the optional help URL, which should link to your sites help or support page.
46 array(
47 'description' => $widget_info['description'],
48 'has_preview' => false
49 //'help' => 'http://example.com/hello-world-widget-docs',
50 ),
51
52 //The $control_options array, which is passed through to WP_Widget
53 array(
54 ),
55
56 //The $form_options array, which describes the form fields used to configure SiteOrigin widgets. We'll explain these in more detail later.
57 false,
58
59 //The $base_folder path string.
60 plugin_dir_path(__FILE__)
61 );
62
63 // we don't want to use template files for site origin widgets
64 add_filter( 'siteorigin_widgets_template_file_' . $widget_info['base'] , array( $this, 'get_widget_template_file' ) );
65 // override the widget template html
66 add_filter( 'siteorigin_widgets_template_html_' . $widget_info['base'] , array( $this, 'get_widget_html' ), 10, 2 );
67
68
69 }
70
71 function initialize_form(){
72
73 $so_fields = array();
74 $so_fields_sections = array();
75
76 foreach ( $this->widget_fields as $field ) {
77
78 $so_field = array(
79 'label' => $field['heading'],
80 'default' => ! empty( $field['value'] ) ? $field['value'] : '',
81 'description' => ! empty( $field['description'] ) ? $field['description'] : ''
82 );
83
84 switch ( $field['type'] ) {
85 case 'iconpicker':
86 case 'aux_iconpicker':
87 $so_field['type'] = 'iconpicker';
88 break;
89
90 case 'textarea_html':
91 $so_field['type'] = 'tinymce';
92 $so_field['rows'] = 20;
93 break;
94
95 case 'textbox':
96 case 'textfield':
97 $so_field['type'] = 'text';
98 break;
99
100 case 'dropdown':
101 case 'select':
102 $so_field['type'] = 'select';
103 $so_field['options'] = $field['value'];
104
105 if ( !empty( $field['def_value'] ) ) {
106 $so_field['default'] = $field['def_value'];
107 }
108 break;
109
110 case 'aux_select2_multiple' :
111 $so_field['type'] = 'select2_multiple';
112 $so_field['options'] = $field['value'];
113 $so_field['multiple'] = true;
114
115 if ( !empty( $field['def_value'] ) ) {
116 $so_field['default'] = $field['def_value'];
117 }
118
119 break;
120
121 case 'aux_visual_select':
122 $so_field['type'] = 'visualselect';
123 $so_field['options'] = $field['choices'];
124 break;
125
126 case 'checkbox':
127 case 'aux_switch':
128 // TODO: add switch box to so
129 $so_field['type'] = 'checkbox';
130 break;
131
132 case 'color':
133 case 'colorpicker':
134 // TODO: add color picker to so
135 $so_field['type'] = 'color';
136 break;
137
138 case 'aux_select_image':
139 case 'attach_image':
140 $so_field['type'] = 'media';
141 $so_field['library'] = 'image';
142 break;
143
144 case 'aux_select_images':
145 case 'attach_images':
146 $so_field['type'] = 'media';
147 $so_field['library'] = 'image';
148 break;
149
150 case 'aux_select_video':
151 case 'attach_video':
152 $so_field['type'] = 'media';
153 $so_field['library'] = 'video';
154 break;
155
156 case 'aux_select_audio':
157 case 'attach_audio':
158 $so_field['type'] = 'media';
159 $so_field['library'] = 'audio';
160 break;
161
162 default:
163 continue;
164 break;
165 }
166
167
168 if ( ! empty( $field['repeater'] ) ) {
169 $repeater_name = $this->sanitize_field_name( $field['repeater'] );
170
171 if ( ! isset( $so_fields[ $repeater_name ] ) ) {
172 $so_fields[ $repeater_name ] = array(
173 'type' => 'repeater',
174 'label' => (isset($field['repeater-label']))? $field['repeater-label'] : $field['repeater'],
175 'item_name' => (isset($field['section-name']))? $field['section-name'] : "Item",
176 'hide' => true,
177 'fields' => array()
178 );
179 }
180
181 $so_fields[ $repeater_name ]['fields'][ $field['param_name'] ] = $so_field;
182
183 } elseif ( ! empty( $field['group'] ) ) {
184 $section_name = $this->sanitize_field_name( $field['group'] );
185
186 if ( ! isset( $so_fields[ $section_name ] ) ) {
187 $so_fields[ $section_name ] = array(
188 'type' => 'section',
189 'label' => $field['group'],
190 'hide' => true,
191 'fields' => array()
192 );
193 }
194
195 $so_fields[ $section_name ]['fields'][ $field['param_name'] ] = $so_field;
196 } else {
197 $so_fields[$field['param_name']] = $so_field;
198 }
199
200 }
201
202 return $so_fields;
203 }
204
205 private function sanitize_field_name( $field_label ) {
206 return str_replace( ' ', '_', strtolower( $field_label ) );
207 }
208
209 /**
210 * get the widget output
211 */
212 function get_widget_html( $template_html, $instance ) {
213
214 $args = $this->widget_fields;
215 // make sure to pass same class name for wrapper to widget too
216 if( isset( $this->widget_info['base_class'] ) ){
217 $args['base_class'] = $this->widget_info['base_class'];
218 }
219
220 $instance['widget_info'] = $args;
221
222 if( function_exists( $this->widget_fun_name ) ){
223 return call_user_func( $this->widget_fun_name, $instance );
224 } else {
225 auxin_error( __('The callback for widget does not exists.', 'auxin-elements') );
226 }
227 }
228
229 /**
230 * Auxin elements doesn't support template files
231 */
232 function get_widget_template_file( $template_path ) {
233 return '';
234 }
235
236 function get_template_name( $instance ) {
237 return '';
238 }
239
240 function get_template_dir( $instance ) {
241 return '';
242 }
243
244 }
245
246 endif;
247