Orphans - Version 2.6.8

Version Description

  • 2017-05-23 =

  • Use WordPress Options Class to handle new options screen.

  • Added a taxonomies title and description to replacements.

  • Added author description to replacements.

  • Fixed a problem with preg_replace() "Compilation failed: range out of order".

Download this release

Release Info

Developer iworks
Plugin Icon 128x128 Orphans
Version 2.6.8
Comparing to
See all releases

Code changes from version 2.6.7 to 2.6.8

etc/options.php ADDED
@@ -0,0 +1,229 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function orphang_indicator_options() {
4
+ $options = array();
5
+ /**
6
+ * main settings
7
+ */
8
+ $options['index'] = array(
9
+ 'use_tabs' => true,
10
+ 'version' => '0.0',
11
+ 'page_title' => __( 'Orphans configuration', 'sierotki' ),
12
+ 'menu_title' => __( 'Orphans', 'sierotki' ),
13
+ 'menu' => 'theme',
14
+ 'enqueue_scripts' => array(),
15
+ 'enqueue_styles' => array(),
16
+ 'options' => array(
17
+ array(
18
+ 'type' => 'heading',
19
+ 'label' => __( 'Entries', 'sierotki' ),
20
+ ),
21
+ /**
22
+ * Since 2.6.8
23
+ */
24
+ array(
25
+ 'name' => 'post_type',
26
+ 'type' => 'select2',
27
+ 'th' => __( 'Post types', 'sierotki' ),
28
+ 'default' => array( 'post', 'page' ),
29
+ 'options' => iworks_orphan_post_types(),
30
+ 'multiple' => true,
31
+ ),
32
+ array(
33
+ 'name' => 'the_title',
34
+ 'th' => __( 'Title:', 'sierotki' ),
35
+ 'type' => 'checkbox',
36
+ 'description' => __( 'Enabled the substitution of orphans in the post_title.', 'sierotki' ),
37
+ 'sanitize_callback' => 'absint',
38
+ 'dafault' => 1,
39
+ 'classes' => array( 'switch-button' ),
40
+ ),
41
+ array(
42
+ 'name' => 'the_excerpt',
43
+ 'th' => __( 'Excerpt', 'sierotki' ),
44
+ 'type' => 'checkbox',
45
+ 'description' => __( 'Enabled the substitution of orphans in the excerpt.', 'sierotki' ),
46
+ 'sanitize_callback' => 'absint',
47
+ 'classes' => array( 'switch-button' ),
48
+ 'dafault' => 1,
49
+ ),
50
+ array(
51
+ 'name' => 'the_content',
52
+ 'th' => __( 'Content', 'sierotki' ),
53
+ 'type' => 'checkbox',
54
+ 'description' => __( 'Enabled the substitution of orphans in the content.', 'sierotki' ),
55
+ 'sanitize_callback' => 'absint',
56
+ 'classes' => array( 'switch-button' ),
57
+ 'dafault' => 1,
58
+ ),
59
+ array(
60
+ 'name' => 'comment_text',
61
+ 'type' => 'checkbox',
62
+ 'th' => __( 'Comments', 'sierotki' ),
63
+ 'description' => __( 'Enabled the substitution of orphans in the comments.', 'sierotki' ),
64
+ 'sanitize_callback' => 'absint',
65
+ 'dafault' => 1,
66
+ 'classes' => array( 'switch-button' ),
67
+ ),
68
+ array(
69
+ 'type' => 'heading',
70
+ 'label' => __( 'Widgets', 'sierotki' ),
71
+ ),
72
+ /**
73
+ * Since 2.6.6
74
+ */
75
+ array(
76
+ 'name' => 'widget_title',
77
+ 'th' => __( 'Widget title', 'sierotki' ),
78
+ 'type' => 'checkbox',
79
+ 'description' => __( 'Enabled the substitution of orphans in the widget title.', 'sierotki' ),
80
+ 'sanitize_callback' => 'absint',
81
+ 'classes' => array( 'switch-button' ),
82
+ 'dafault' => 1,
83
+ ),
84
+ /**
85
+ * Since 2.6.6
86
+ */
87
+ array(
88
+ 'name' => 'widget_text',
89
+ 'th' => __( 'Widget text', 'sierotki' ),
90
+ 'type' => 'checkbox',
91
+ 'description' => __( 'Enabled the substitution of orphans in the widget text.', 'sierotki' ),
92
+ 'sanitize_callback' => 'absint',
93
+ 'classes' => array( 'switch-button' ),
94
+ 'dafault' => 1,
95
+ ),
96
+ /**
97
+ * Since 2.6.6
98
+ */
99
+ array(
100
+ 'type' => 'heading',
101
+ 'label' => __( 'Taxonomies', 'sierotki' ),
102
+ ),
103
+ array(
104
+ 'name' => 'taxonomies',
105
+ 'type' => 'select2',
106
+ 'th' => __( 'Taxonomies', 'sierotki' ),
107
+ 'default' => array( 'category', 'post_tag', 'post_format' ),
108
+ 'options' => iworks_orphan_taxonomies(),
109
+ 'multiple' => true,
110
+ ),
111
+ array(
112
+ 'name' => 'taxonomy_title',
113
+ 'th' => __( 'Title', 'sierotki' ),
114
+ 'type' => 'checkbox',
115
+ 'description' => __( 'Enabled the substitution of orphans in the taxonomy title.', 'sierotki' ),
116
+ 'sanitize_callback' => 'absint',
117
+ 'classes' => array( 'switch-button' ),
118
+ 'default' => 1,
119
+ ),
120
+ array(
121
+ 'name' => 'term_description',
122
+ 'th' => __( 'Description', 'sierotki' ),
123
+ 'type' => 'checkbox',
124
+ 'description' => __( 'Enabled the substitution of orphans in the taxonomy description.', 'sierotki' ),
125
+ 'sanitize_callback' => 'absint',
126
+ 'classes' => array( 'switch-button' ),
127
+ 'default' => 1,
128
+ ),
129
+ array(
130
+ 'type' => 'heading',
131
+ 'label' => __( 'Miscellaneous', 'sierotki' ),
132
+ ),
133
+ /**
134
+ * Since 2.6.8
135
+ */
136
+ array(
137
+ 'name' => 'get_the_author_description',
138
+ 'type' => 'checkbox',
139
+ 'th' => __( 'Author description', 'sierotki' ),
140
+ 'description' => __( 'Enabled the substitution of orphans in the author description.', 'sierotki' ),
141
+ 'sanitize_callback' => 'absint',
142
+ 'dafault' => 1,
143
+ 'classes' => array( 'switch-button' ),
144
+ ),
145
+ array(
146
+ 'name' => 'ignore_language',
147
+ 'th' => __( 'Ignore language', 'sierotki' ),
148
+ 'type' => 'checkbox',
149
+ 'description' => __( 'Allow to use plugin with another languages then Polish.', 'sierotki' ),
150
+ 'sanitize_callback' => 'absint',
151
+ 'classes' => array( 'switch-button' ),
152
+ 'default' => 0,
153
+ ),
154
+ array(
155
+ 'name' => 'numbers',
156
+ 'th' => __( 'Keep numbers together:', 'sierotki' ),
157
+ 'type' => 'checkbox',
158
+ 'description' => __( 'Allow to keep together phone number or strings with space between numbers.', 'sierotki' ),
159
+ 'sanitize_callback' => 'absint',
160
+ 'classes' => array( 'switch-button' ),
161
+ ),
162
+ array(
163
+ 'name' => 'own_orphans',
164
+ 'th' => __( 'User definied orphans:', 'sierotki' ),
165
+ 'type' => 'textarea',
166
+ 'description' => __( 'Use a comma to separate orphans.', 'sierotki' ),
167
+ 'sanitize_callback' => 'esc_html',
168
+ 'classes' => array( 'large-text' ),
169
+ 'rows' => 10,
170
+ ),
171
+ ),
172
+ 'metaboxes' => array(
173
+ 'loved_this_plugin' => array(
174
+ 'title' => __( 'Loved this Plugin?', 'sierotki' ),
175
+ 'callback' => 'iworks_orphan_options_loved_this_plugin',
176
+ 'context' => 'side',
177
+ 'priority' => 'core',
178
+ ),
179
+ 'need_assistance' => array(
180
+ 'title' => __( 'Need Assistance?', 'sierotki' ),
181
+ 'callback' => 'iworks_orphans_options_need_assistance',
182
+ 'context' => 'side',
183
+ 'priority' => 'core',
184
+ ),
185
+ ),
186
+ );
187
+ return $options;
188
+ }
189
+
190
+ function iworks_orphan_options_loved_this_plugin( $iworks_orphan ) {
191
+
192
+ ?>
193
+ <p><?php _e( 'Below are some links to help spread this plugin to other users', 'sierotki' ); ?></p>
194
+ <ul>
195
+ <li><a href="https://wordpress.org/support/plugin/sierotki/reviews/#new-post"><?php _e( 'Give it a five stars on WordPress.org', 'sierotki' ); ?></a></li>
196
+ <li><a href="<?php _ex( 'https://wordpress.org/plugins/sierotki/', 'plugin home page on WordPress.org', 'sierotki' ); ?>"><?php _e( 'Link to it so others can easily find it', 'sierotki' ); ?></a></li>
197
+ </ul>
198
+ <?php
199
+ }
200
+ function iworks_orphan_taxonomies() {
201
+ $data = array();
202
+ $taxonomies = get_taxonomies( array( 'public' => true ), 'objects' );
203
+ foreach ( $taxonomies as $taxonomy ) {
204
+ $data[ $taxonomy->name ] = $taxonomy->labels->name;
205
+ }
206
+ return $data;
207
+ }
208
+ function iworks_orphan_post_types() {
209
+ $args = array(
210
+ 'public' => true,
211
+ );
212
+ $p = array();
213
+ $post_types = get_post_types( $args, 'names' );
214
+ foreach ( $post_types as $post_type ) {
215
+ $a = get_post_type_object( $post_type );
216
+ $p[ $post_type ] = $a->labels->name;
217
+ }
218
+ return $p;
219
+ }
220
+
221
+ function iworks_orphans_options_need_assistance( $iworks_orphans ) {
222
+
223
+ ?>
224
+ <p><?php _e( 'Problems? The links bellow can be very helpful to you', 'sierotki' ); ?></p>
225
+ <ul>
226
+ <li><a href="<?php _ex( 'https://wordpress.org/support/plugin/sierotki/', 'link to support forum on WordPress.org', 'sierotki' ); ?>"><?php _e( 'WordPress Help Forum', 'sierotki' ); ?></a></li>
227
+ </ul>
228
+ <?php
229
+ }
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: iworks
3
  Donate link: http://iworks.pl/donate/sierotki.php
4
  Tags: sierotka, sierotki, spójniki, twarda spacja
5
  Requires at least: 3.5
6
- Tested up to: 4.7.4
7
- Stable tag: 2.6.7
8
 
9
  Plugin supports some of the grammatical rules of the Polish language.
10
 
@@ -88,7 +88,6 @@ function my_orphans_capability($capability)
88
  return 'unfiltered_html';
89
  }
90
  `
91
-
92
  == Screenshots ==
93
 
94
  1. Orphan Options (Polish).
@@ -96,6 +95,13 @@ function my_orphans_capability($capability)
96
 
97
  == Changelog ==
98
 
 
 
 
 
 
 
 
99
  = 2.6.7 - 2017-05-09 =
100
 
101
  * Allow to apply replacement to all languages by using filter `iworks_orphan_apply_to_all_languages' set on true.
3
  Donate link: http://iworks.pl/donate/sierotki.php
4
  Tags: sierotka, sierotki, spójniki, twarda spacja
5
  Requires at least: 3.5
6
+ Tested up to: 4.7.5
7
+ Stable tag: 2.6.8
8
 
9
  Plugin supports some of the grammatical rules of the Polish language.
10
 
88
  return 'unfiltered_html';
89
  }
90
  `
 
91
  == Screenshots ==
92
 
93
  1. Orphan Options (Polish).
95
 
96
  == Changelog ==
97
 
98
+ = 2.6.8 - 2017-05-23 =
99
+
100
+ * Use [WordPress Options Class](https://github.com/iworks/wordpress-options-class) to handle new options screen.
101
+ * Added a taxonomies title and description to replacements.
102
+ * Added author description to replacements.
103
+ * Fixed a problem with preg_replace() "Compilation failed: range out of order".
104
+
105
  = 2.6.7 - 2017-05-09 =
106
 
107
  * Allow to apply replacement to all languages by using filter `iworks_orphan_apply_to_all_languages' set on true.
sierotki.php CHANGED
@@ -5,18 +5,45 @@ Plugin URI: http://iworks.pl/2011/02/16/sierotki/
5
  Text Domain: sierotki
6
  Description: Implement Polish grammar rules with orphans.
7
  Author: Marcin Pietrzak
8
- Version: 2.6.7
9
  Author URI: http://iworks.pl/
10
  */
11
 
12
- require_once( dirname( __FILE__ ) ).'/vendor/iworks/orphan.php';
13
- include_once( dirname( __FILE__ ) ).'/vendor/iworks/rate/rate.php';
14
 
15
- new iworks_orphan();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
  register_activation_hook( __FILE__, 'iworks_orphan_activate' );
18
  register_deactivation_hook( __FILE__, 'iworks_orphan_deactivate' );
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  /**
21
  * Activate plugin function
22
  *
@@ -24,6 +51,8 @@ register_deactivation_hook( __FILE__, 'iworks_orphan_deactivate' );
24
  *
25
  */
26
  function iworks_orphan_activate() {
 
 
27
  iworks_orphan_change_options_autoload_status( 'yes' );
28
  }
29
 
5
  Text Domain: sierotki
6
  Description: Implement Polish grammar rules with orphans.
7
  Author: Marcin Pietrzak
8
+ Version: 2.6.8
9
  Author URI: http://iworks.pl/
10
  */
11
 
12
+ include_once dirname( __FILE__ ).'/etc/options.php';
 
13
 
14
+
15
+ $vendor = dirname( __FILE__ ).'/vendor';
16
+
17
+ require_once $vendor . '/iworks/orphan.php';
18
+ if ( ! class_exists( 'iworks_rate' ) ) {
19
+ include_once $vendor . '/iworks/rate/rate.php';
20
+ }
21
+ /**
22
+ * since 2.6.8
23
+ */
24
+ if ( ! class_exists( 'iworks_options' ) ) {
25
+ include_once $vendor.'/iworks/options/options.php';
26
+ }
27
+
28
+ new iworks_orphan( __FILE__ );
29
 
30
  register_activation_hook( __FILE__, 'iworks_orphan_activate' );
31
  register_deactivation_hook( __FILE__, 'iworks_orphan_deactivate' );
32
 
33
+ /**
34
+ * load options
35
+ *
36
+ * since 2.6.8
37
+ *
38
+ */
39
+ function get_orphan_options() {
40
+ $options = new iworks_options();
41
+ $options->set_option_function_name( 'orphang_indicator_options' );
42
+ $options->set_option_prefix( 'iworks_orphan_' );
43
+ $options->init();
44
+ return $options;
45
+ }
46
+
47
  /**
48
  * Activate plugin function
49
  *
51
  *
52
  */
53
  function iworks_orphan_activate() {
54
+ $options = get_orphan_options();
55
+ $options->activate();
56
  iworks_orphan_change_options_autoload_status( 'yes' );
57
  }
58
 
vendor/iworks/options/assets/scripts/common.js ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(function(){
2
+ iworks_options_tabulator_init();
3
+ /**
4
+ * Switch button
5
+ */
6
+ if ( jQuery.fn.switchButton ) {
7
+ jQuery('.iworks_options .switch-button').each(function() {
8
+ var options = {
9
+ checked: jQuery(this).checked,
10
+ on_label: switch_button.labels.on_label,
11
+ off_label: switch_button.labels.off_label
12
+ };
13
+ jQuery(this).switchButton(options);
14
+ });
15
+ }
16
+ /**
17
+ * Color picker
18
+ */
19
+ if ( jQuery.fn.wpColorPicker ) {
20
+ jQuery('.wpColorPicker').wpColorPicker();
21
+ }
22
+ /**
23
+ * select2
24
+ */
25
+ if ( jQuery.fn.select2 ) {
26
+ jQuery('.iworks-options .select2').select2();
27
+ }
28
+ /**
29
+ * slider
30
+ */
31
+ if ( jQuery.fn.slider ) {
32
+ jQuery('.iworks-options .slider').each( function() {
33
+ jQuery(this).parent().append('<div class="ui-slider"></div>' );
34
+ var target = jQuery(this);
35
+ var options = {
36
+ value: parseInt( target.val() ),
37
+ step: parseInt( target.data('step') || target.attr('step') || 1 ),
38
+ min: parseInt( target.data('min') || target.attr('min') || 0 ),
39
+ max: parseInt( target.data('max') || target.attr('max') || 100 ),
40
+ slide: function( event, ui ) {
41
+ target.val( ui.value );
42
+ }
43
+ };
44
+ jQuery('.ui-slider', jQuery(this).parent()).slider( options );
45
+ });
46
+ }
47
+ });
48
+ /**
49
+ * Tabulator Bootup
50
+ */
51
+ function iworks_options_tabulator_init()
52
+ {
53
+ if (!jQuery("#hasadmintabs").length) {
54
+ return;
55
+ }
56
+ jQuery('#hasadmintabs').prepend("<ul><\/ul>");
57
+ jQuery('#hasadmintabs > fieldset').each(function(i){
58
+ id = jQuery(this).attr('id');
59
+ rel = jQuery(this).attr('rel');
60
+ caption = jQuery(this).find('h3').text();
61
+ if ( rel ) {
62
+ rel = ' class="'+rel+'"';
63
+ }
64
+ jQuery('#hasadmintabs > ul').append('<li><a href="#'+id+'"><span'+rel+'>'+caption+"<\/span><\/a><\/li>");
65
+ jQuery(this).find('h3').hide();
66
+ });
67
+ index = 0;
68
+ jQuery('#hasadmintabs h3').each(function(i){
69
+ if ( jQuery(this).hasClass( 'selected' ) ) {
70
+ index = i;
71
+ }
72
+ });
73
+ if ( index < 0 ) index = 0;
74
+ jQuery("#hasadmintabs").tabs({ active: index });
75
+ jQuery('#hasadmintabs ul a').click(function(i){
76
+ jQuery('#hasadmintabs #last_used_tab').val(jQuery(this).parent().index());
77
+ });
78
+ }
79
+
vendor/iworks/options/assets/scripts/jquery.switch_button.js ADDED
@@ -0,0 +1,306 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * jquery.switchButton.js v1.0
3
+ * jQuery iPhone-like switch button
4
+ * @author Olivier Lance <olivier.lance@sylights.com>
5
+ *
6
+ * Copyright (c) Olivier Lance - released under MIT License {{{
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person
9
+ * obtaining a copy of this software and associated documentation
10
+ * files (the "Software"), to deal in the Software without
11
+ * restriction, including without limitation the rights to use,
12
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the
14
+ * Software is furnished to do so, subject to the following
15
+ * conditions:
16
+
17
+ * The above copyright notice and this permission notice shall be
18
+ * included in all copies or substantial portions of the Software.
19
+
20
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27
+ * OTHER DEALINGS IN THE SOFTWARE.
28
+
29
+ * }}}
30
+ */
31
+
32
+ /*
33
+ * Meant to be used on a <input type="checkbox">, this widget will replace the receiver element with an iPhone-style
34
+ * switch button with two states: "on" and "off".
35
+ * Labels of the states are customizable, as are their presence and position. The receiver element's "checked" attribute
36
+ * is updated according to the state of the switch, so that it can be used in a <form>.
37
+ *
38
+ */
39
+
40
+ (function($) {
41
+
42
+ $.widget("sylightsUI.switchButton", {
43
+
44
+ options: {
45
+ checked: undefined, // State of the switch
46
+
47
+ show_labels: true, // Should we show the on and off labels?
48
+ labels_placement: "both", // Position of the labels: "both", "left" or "right"
49
+ on_label: "ON", // Text to be displayed when checked
50
+ off_label: "OFF", // Text to be displayed when unchecked
51
+
52
+ width: 25, // Width of the button in pixels
53
+ height: 11, // Height of the button in pixels
54
+ button_width: 12, // Width of the sliding part in pixels
55
+
56
+ clear: true, // Should we insert a div with style="clear: both;" after the switch button?
57
+ clear_after: null, // Override the element after which the clearing div should be inserted (null > right after the button)
58
+ on_callback: undefined, //callback function that will be executed after going to on state
59
+ off_callback: undefined //callback function that will be executed after going to off state
60
+ },
61
+
62
+ _create: function() {
63
+ // Init the switch from the checkbox if no state was specified on creation
64
+ if (this.options.checked === undefined) {
65
+ this.options.checked = this.element.prop("checked");
66
+ }
67
+
68
+ this._initLayout();
69
+ this._initEvents();
70
+ },
71
+
72
+ _initLayout: function() {
73
+ // Hide the receiver element
74
+ this.element.hide();
75
+
76
+ // Create our objects: two labels and the button
77
+ this.off_label = $("<span>").addClass("switch-button-label");
78
+ this.on_label = $("<span>").addClass("switch-button-label");
79
+
80
+ this.button_bg = $("<div>").addClass("switch-button-background");
81
+ this.button = $("<div>").addClass("switch-button-button");
82
+
83
+ // Insert the objects into the DOM
84
+ this.off_label.insertAfter(this.element);
85
+ this.button_bg.insertAfter(this.off_label);
86
+ this.on_label.insertAfter(this.button_bg);
87
+
88
+ this.button_bg.append(this.button);
89
+
90
+ // Insert a clearing element after the specified element if needed
91
+ if(this.options.clear)
92
+ {
93
+ if (this.options.clear_after === null) {
94
+ this.options.clear_after = this.on_label;
95
+ }
96
+ $("<div>").css({
97
+ clear: "left"
98
+ }).insertAfter(this.options.clear_after);
99
+ }
100
+
101
+ // Call refresh to update labels text and visibility
102
+ this._refresh();
103
+
104
+ // Init labels and switch state
105
+ // This will animate all checked switches to the ON position when
106
+ // loading... this is intentional!
107
+ this.options.checked = !this.options.checked;
108
+ this._toggleSwitch(true);
109
+ },
110
+
111
+ _refresh: function() {
112
+ // Refresh labels display
113
+ if (this.options.show_labels) {
114
+ this.off_label.show();
115
+ this.on_label.show();
116
+ }
117
+ else {
118
+ this.off_label.hide();
119
+ this.on_label.hide();
120
+ }
121
+
122
+ // Move labels around depending on labels_placement option
123
+ switch(this.options.labels_placement) {
124
+ case "both":
125
+ {
126
+ // Don't move anything if labels are already in place
127
+ if(this.button_bg.prev() !== this.off_label || this.button_bg.next() !== this.on_label)
128
+ {
129
+ // Detach labels form DOM and place them correctly
130
+ this.off_label.detach();
131
+ this.on_label.detach();
132
+ this.off_label.insertBefore(this.button_bg);
133
+ this.on_label.insertAfter(this.button_bg);
134
+
135
+ // Update label classes
136
+ this.on_label.addClass(this.options.checked ? "on" : "off").removeClass(this.options.checked ? "off" : "on");
137
+ this.off_label.addClass(this.options.checked ? "off" : "on").removeClass(this.options.checked ? "on" : "off");
138
+
139
+ }
140
+ break;
141
+ }
142
+
143
+ case "left":
144
+ {
145
+ // Don't move anything if labels are already in place
146
+ if(this.button_bg.prev() !== this.on_label || this.on_label.prev() !== this.off_label)
147
+ {
148
+ // Detach labels form DOM and place them correctly
149
+ this.off_label.detach();
150
+ this.on_label.detach();
151
+ this.off_label.insertBefore(this.button_bg);
152
+ this.on_label.insertBefore(this.button_bg);
153
+
154
+ // update label classes
155
+ this.on_label.addClass("on").removeClass("off");
156
+ this.off_label.addClass("off").removeClass("on");
157
+ }
158
+ break;
159
+ }
160
+
161
+ case "right":
162
+ {
163
+ // Don't move anything if labels are already in place
164
+ if(this.button_bg.next() !== this.off_label || this.off_label.next() !== this.on_label)
165
+ {
166
+ // Detach labels form DOM and place them correctly
167
+ this.off_label.detach();
168
+ this.on_label.detach();
169
+ this.off_label.insertAfter(this.button_bg);
170
+ this.on_label.insertAfter(this.off_label);
171
+
172
+ // update label classes
173
+ this.on_label.addClass("on").removeClass("off");
174
+ this.off_label.addClass("off").removeClass("on");
175
+ }
176
+ break;
177
+ }
178
+
179
+ }
180
+
181
+ // Refresh labels texts
182
+ this.on_label.html(this.options.on_label);
183
+ this.off_label.html(this.options.off_label);
184
+
185
+ // Refresh button's dimensions
186
+ this.button_bg.width(this.options.width);
187
+ this.button_bg.height(this.options.height);
188
+ this.button.width(this.options.button_width);
189
+ this.button.height(this.options.height);
190
+ },
191
+
192
+ _initEvents: function() {
193
+ var self = this;
194
+
195
+ // Toggle switch when the switch is clicked
196
+ this.button_bg.click(function(e) {
197
+ e.preventDefault();
198
+ e.stopPropagation();
199
+ self._toggleSwitch(false);
200
+ return false;
201
+ });
202
+ this.button.click(function(e) {
203
+ e.preventDefault();
204
+ e.stopPropagation();
205
+ self._toggleSwitch(false);
206
+ return false;
207
+ });
208
+
209
+ // Set switch value when clicking labels
210
+ this.on_label.click(function(e) {
211
+ if (self.options.checked && self.options.labels_placement === "both") {
212
+ return false;
213
+ }
214
+
215
+ self._toggleSwitch(false);
216
+ return false;
217
+ });
218
+
219
+ this.off_label.click(function(e) {
220
+ if (!self.options.checked && self.options.labels_placement === "both") {
221
+ return false;
222
+ }
223
+
224
+ self._toggleSwitch(false);
225
+ return false;
226
+ });
227
+
228
+ },
229
+
230
+ _setOption: function(key, value) {
231
+ if (key === "checked") {
232
+ this._setChecked(value);
233
+ return;
234
+ }
235
+
236
+ this.options[key] = value;
237
+ this._refresh();
238
+ },
239
+
240
+ _setChecked: function(value) {
241
+ if (value === this.options.checked) {
242
+ return;
243
+ }
244
+
245
+ this.options.checked = !value;
246
+ this._toggleSwitch(false);
247
+ },
248
+
249
+ _toggleSwitch: function(isInitializing) {
250
+ // Don't toggle the switch if it is set to readonly or disabled, unless it is initializing and animating itself
251
+ if( !isInitializing && (this.element.attr('readonly') == 'readonly' || this.element.prop('disabled')) )
252
+ return;
253
+
254
+ this.options.checked = !this.options.checked;
255
+ var newLeft = "";
256
+ if (this.options.checked) {
257
+ // Update the underlying checkbox state
258
+ this.element.prop("checked", true);
259
+ this.element.change();
260
+
261
+ var dLeft = this.options.width - this.options.button_width;
262
+ newLeft = "+=" + dLeft;
263
+
264
+ // Update labels states
265
+ if(this.options.labels_placement == "both")
266
+ {
267
+ this.off_label.removeClass("on").addClass("off");
268
+ this.on_label.removeClass("off").addClass("on");
269
+ }
270
+ else
271
+ {
272
+ this.off_label.hide();
273
+ this.on_label.show();
274
+ }
275
+ this.button_bg.addClass("checked");
276
+ //execute on state callback if its supplied
277
+ if(typeof this.options.on_callback === 'function') this.options.on_callback.call(this);
278
+ }
279
+ else {
280
+ // Update the underlying checkbox state
281
+ this.element.prop("checked", false);
282
+ this.element.change();
283
+ newLeft = "-1px";
284
+
285
+ // Update labels states
286
+ if(this.options.labels_placement == "both")
287
+ {
288
+ this.off_label.removeClass("off").addClass("on");
289
+ this.on_label.removeClass("on").addClass("off");
290
+ }
291
+ else
292
+ {
293
+ this.off_label.show();
294
+ this.on_label.hide();
295
+ }
296
+ this.button_bg.removeClass("checked");
297
+ //execute off state callback if its supplied
298
+ if(typeof this.options.off_callback === 'function') this.options.off_callback.call(this);
299
+ }
300
+ // Animate the switch
301
+ this.button.animate({ left: newLeft }, 250, "easeInOutCubic");
302
+ }
303
+
304
+ });
305
+
306
+ })(jQuery);
vendor/iworks/options/assets/scripts/select2.min.js ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ /*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b=function(){if(a&&a.fn&&a.fn.select2&&a.fn.select2.amd)var b=a.fn.select2.amd;var b;return function(){if(!b||!b.requirejs){b?c=b:b={};var a,c,d;!function(b){function e(a,b){return u.call(a,b)}function f(a,b){var c,d,e,f,g,h,i,j,k,l,m,n=b&&b.split("/"),o=s.map,p=o&&o["*"]||{};if(a&&"."===a.charAt(0))if(b){for(a=a.split("/"),g=a.length-1,s.nodeIdCompat&&w.test(a[g])&&(a[g]=a[g].replace(w,"")),a=n.slice(0,n.length-1).concat(a),k=0;k<a.length;k+=1)if(m=a[k],"."===m)a.splice(k,1),k-=1;else if(".."===m){if(1===k&&(".."===a[2]||".."===a[0]))break;k>0&&(a.splice(k-1,2),k-=2)}a=a.join("/")}else 0===a.indexOf("./")&&(a=a.substring(2));if((n||p)&&o){for(c=a.split("/"),k=c.length;k>0;k-=1){if(d=c.slice(0,k).join("/"),n)for(l=n.length;l>0;l-=1)if(e=o[n.slice(0,l).join("/")],e&&(e=e[d])){f=e,h=k;break}if(f)break;!i&&p&&p[d]&&(i=p[d],j=k)}!f&&i&&(f=i,h=j),f&&(c.splice(0,h,f),a=c.join("/"))}return a}function g(a,c){return function(){var d=v.call(arguments,0);return"string"!=typeof d[0]&&1===d.length&&d.push(null),n.apply(b,d.concat([a,c]))}}function h(a){return function(b){return f(b,a)}}function i(a){return function(b){q[a]=b}}function j(a){if(e(r,a)){var c=r[a];delete r[a],t[a]=!0,m.apply(b,c)}if(!e(q,a)&&!e(t,a))throw new Error("No "+a);return q[a]}function k(a){var b,c=a?a.indexOf("!"):-1;return c>-1&&(b=a.substring(0,c),a=a.substring(c+1,a.length)),[b,a]}function l(a){return function(){return s&&s.config&&s.config[a]||{}}}var m,n,o,p,q={},r={},s={},t={},u=Object.prototype.hasOwnProperty,v=[].slice,w=/\.js$/;o=function(a,b){var c,d=k(a),e=d[0];return a=d[1],e&&(e=f(e,b),c=j(e)),e?a=c&&c.normalize?c.normalize(a,h(b)):f(a,b):(a=f(a,b),d=k(a),e=d[0],a=d[1],e&&(c=j(e))),{f:e?e+"!"+a:a,n:a,pr:e,p:c}},p={require:function(a){return g(a)},exports:function(a){var b=q[a];return"undefined"!=typeof b?b:q[a]={}},module:function(a){return{id:a,uri:"",exports:q[a],config:l(a)}}},m=function(a,c,d,f){var h,k,l,m,n,s,u=[],v=typeof d;if(f=f||a,"undefined"===v||"function"===v){for(c=!c.length&&d.length?["require","exports","module"]:c,n=0;n<c.length;n+=1)if(m=o(c[n],f),k=m.f,"require"===k)u[n]=p.require(a);else if("exports"===k)u[n]=p.exports(a),s=!0;else if("module"===k)h=u[n]=p.module(a);else if(e(q,k)||e(r,k)||e(t,k))u[n]=j(k);else{if(!m.p)throw new Error(a+" missing "+k);m.p.load(m.n,g(f,!0),i(k),{}),u[n]=q[k]}l=d?d.apply(q[a],u):void 0,a&&(h&&h.exports!==b&&h.exports!==q[a]?q[a]=h.exports:l===b&&s||(q[a]=l))}else a&&(q[a]=d)},a=c=n=function(a,c,d,e,f){if("string"==typeof a)return p[a]?p[a](c):j(o(a,c).f);if(!a.splice){if(s=a,s.deps&&n(s.deps,s.callback),!c)return;c.splice?(a=c,c=d,d=null):a=b}return c=c||function(){},"function"==typeof d&&(d=e,e=f),e?m(b,a,c,d):setTimeout(function(){m(b,a,c,d)},4),n},n.config=function(a){return n(a)},a._defined=q,d=function(a,b,c){if("string"!=typeof a)throw new Error("See almond README: incorrect module build, no module name");b.splice||(c=b,b=[]),e(q,a)||e(r,a)||(r[a]=[a,b,c])},d.amd={jQuery:!0}}(),b.requirejs=a,b.require=c,b.define=d}}(),b.define("almond",function(){}),b.define("jquery",[],function(){var b=a||$;return null==b&&console&&console.error&&console.error("Select2: An instance of jQuery or a jQuery-compatible library was not found. Make sure that you are including jQuery before Select2 on your web page."),b}),b.define("select2/utils",["jquery"],function(a){function b(a){var b=a.prototype,c=[];for(var d in b){var e=b[d];"function"==typeof e&&"constructor"!==d&&c.push(d)}return c}var c={};c.Extend=function(a,b){function c(){this.constructor=a}var d={}.hasOwnProperty;for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},c.Decorate=function(a,c){function d(){var b=Array.prototype.unshift,d=c.prototype.constructor.length,e=a.prototype.constructor;d>0&&(b.call(arguments,a.prototype.constructor),e=c.prototype.constructor),e.apply(this,arguments)}function e(){this.constructor=d}var f=b(c),g=b(a);c.displayName=a.displayName,d.prototype=new e;for(var h=0;h<g.length;h++){var i=g[h];d.prototype[i]=a.prototype[i]}for(var j=(function(a){var b=function(){};a in d.prototype&&(b=d.prototype[a]);var e=c.prototype[a];return function(){var a=Array.prototype.unshift;return a.call(arguments,b),e.apply(this,arguments)}}),k=0;k<f.length;k++){var l=f[k];d.prototype[l]=j(l)}return d};var d=function(){this.listeners={}};return d.prototype.on=function(a,b){this.listeners=this.listeners||{},a in this.listeners?this.listeners[a].push(b):this.listeners[a]=[b]},d.prototype.trigger=function(a){var b=Array.prototype.slice,c=b.call(arguments,1);this.listeners=this.listeners||{},null==c&&(c=[]),0===c.length&&c.push({}),c[0]._type=a,a in this.listeners&&this.invoke(this.listeners[a],b.call(arguments,1)),"*"in this.listeners&&this.invoke(this.listeners["*"],arguments)},d.prototype.invoke=function(a,b){for(var c=0,d=a.length;d>c;c++)a[c].apply(this,b)},c.Observable=d,c.generateChars=function(a){for(var b="",c=0;a>c;c++){var d=Math.floor(36*Math.random());b+=d.toString(36)}return b},c.bind=function(a,b){return function(){a.apply(b,arguments)}},c._convertData=function(a){for(var b in a){var c=b.split("-"),d=a;if(1!==c.length){for(var e=0;e<c.length;e++){var f=c[e];f=f.substring(0,1).toLowerCase()+f.substring(1),f in d||(d[f]={}),e==c.length-1&&(d[f]=a[b]),d=d[f]}delete a[b]}}return a},c.hasScroll=function(b,c){var d=a(c),e=c.style.overflowX,f=c.style.overflowY;return e!==f||"hidden"!==f&&"visible"!==f?"scroll"===e||"scroll"===f?!0:d.innerHeight()<c.scrollHeight||d.innerWidth()<c.scrollWidth:!1},c.escapeMarkup=function(a){var b={"\\":"&#92;","&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#47;"};return"string"!=typeof a?a:String(a).replace(/[&<>"'\/\\]/g,function(a){return b[a]})},c.appendMany=function(b,c){if("1.7"===a.fn.jquery.substr(0,3)){var d=a();a.map(c,function(a){d=d.add(a)}),c=d}b.append(c)},c}),b.define("select2/results",["jquery","./utils"],function(a,b){function c(a,b,d){this.$element=a,this.data=d,this.options=b,c.__super__.constructor.call(this)}return b.Extend(c,b.Observable),c.prototype.render=function(){var b=a('<ul class="select2-results__options" role="tree"></ul>');return this.options.get("multiple")&&b.attr("aria-multiselectable","true"),this.$results=b,b},c.prototype.clear=function(){this.$results.empty()},c.prototype.displayMessage=function(b){var c=this.options.get("escapeMarkup");this.clear(),this.hideLoading();var d=a('<li role="treeitem" aria-live="assertive" class="select2-results__option"></li>'),e=this.options.get("translations").get(b.message);d.append(c(e(b.args))),d[0].className+=" select2-results__message",this.$results.append(d)},c.prototype.hideMessages=function(){this.$results.find(".select2-results__message").remove()},c.prototype.append=function(a){this.hideLoading();var b=[];if(null==a.results||0===a.results.length)return void(0===this.$results.children().length&&this.trigger("results:message",{message:"noResults"}));a.results=this.sort(a.results);for(var c=0;c<a.results.length;c++){var d=a.results[c],e=this.option(d);b.push(e)}this.$results.append(b)},c.prototype.position=function(a,b){var c=b.find(".select2-results");c.append(a)},c.prototype.sort=function(a){var b=this.options.get("sorter");return b(a)},c.prototype.highlightFirstItem=function(){var a=this.$results.find(".select2-results__option[aria-selected]"),b=a.filter("[aria-selected=true]");b.length>0?b.first().trigger("mouseenter"):a.first().trigger("mouseenter"),this.ensureHighlightVisible()},c.prototype.setClasses=function(){var b=this;this.data.current(function(c){var d=a.map(c,function(a){return a.id.toString()}),e=b.$results.find(".select2-results__option[aria-selected]");e.each(function(){var b=a(this),c=a.data(this,"data"),e=""+c.id;null!=c.element&&c.element.selected||null==c.element&&a.inArray(e,d)>-1?b.attr("aria-selected","true"):b.attr("aria-selected","false")})})},c.prototype.showLoading=function(a){this.hideLoading();var b=this.options.get("translations").get("searching"),c={disabled:!0,loading:!0,text:b(a)},d=this.option(c);d.className+=" loading-results",this.$results.prepend(d)},c.prototype.hideLoading=function(){this.$results.find(".loading-results").remove()},c.prototype.option=function(b){var c=document.createElement("li");c.className="select2-results__option";var d={role:"treeitem","aria-selected":"false"};b.disabled&&(delete d["aria-selected"],d["aria-disabled"]="true"),null==b.id&&delete d["aria-selected"],null!=b._resultId&&(c.id=b._resultId),b.title&&(c.title=b.title),b.children&&(d.role="group",d["aria-label"]=b.text,delete d["aria-selected"]);for(var e in d){var f=d[e];c.setAttribute(e,f)}if(b.children){var g=a(c),h=document.createElement("strong");h.className="select2-results__group";a(h);this.template(b,h);for(var i=[],j=0;j<b.children.length;j++){var k=b.children[j],l=this.option(k);i.push(l)}var m=a("<ul></ul>",{"class":"select2-results__options select2-results__options--nested"});m.append(i),g.append(h),g.append(m)}else this.template(b,c);return a.data(c,"data",b),c},c.prototype.bind=function(b,c){var d=this,e=b.id+"-results";this.$results.attr("id",e),b.on("results:all",function(a){d.clear(),d.append(a.data),b.isOpen()&&(d.setClasses(),d.highlightFirstItem())}),b.on("results:append",function(a){d.append(a.data),b.isOpen()&&d.setClasses()}),b.on("query",function(a){d.hideMessages(),d.showLoading(a)}),b.on("select",function(){b.isOpen()&&(d.setClasses(),d.highlightFirstItem())}),b.on("unselect",function(){b.isOpen()&&(d.setClasses(),d.highlightFirstItem())}),b.on("open",function(){d.$results.attr("aria-expanded","true"),d.$results.attr("aria-hidden","false"),d.setClasses(),d.ensureHighlightVisible()}),b.on("close",function(){d.$results.attr("aria-expanded","false"),d.$results.attr("aria-hidden","true"),d.$results.removeAttr("aria-activedescendant")}),b.on("results:toggle",function(){var a=d.getHighlightedResults();0!==a.length&&a.trigger("mouseup")}),b.on("results:select",function(){var a=d.getHighlightedResults();if(0!==a.length){var b=a.data("data");"true"==a.attr("aria-selected")?d.trigger("close",{}):d.trigger("select",{data:b})}}),b.on("results:previous",function(){var a=d.getHighlightedResults(),b=d.$results.find("[aria-selected]"),c=b.index(a);if(0!==c){var e=c-1;0===a.length&&(e=0);var f=b.eq(e);f.trigger("mouseenter");var g=d.$results.offset().top,h=f.offset().top,i=d.$results.scrollTop()+(h-g);0===e?d.$results.scrollTop(0):0>h-g&&d.$results.scrollTop(i)}}),b.on("results:next",function(){var a=d.getHighlightedResults(),b=d.$results.find("[aria-selected]"),c=b.index(a),e=c+1;if(!(e>=b.length)){var f=b.eq(e);f.trigger("mouseenter");var g=d.$results.offset().top+d.$results.outerHeight(!1),h=f.offset().top+f.outerHeight(!1),i=d.$results.scrollTop()+h-g;0===e?d.$results.scrollTop(0):h>g&&d.$results.scrollTop(i)}}),b.on("results:focus",function(a){a.element.addClass("select2-results__option--highlighted")}),b.on("results:message",function(a){d.displayMessage(a)}),a.fn.mousewheel&&this.$results.on("mousewheel",function(a){var b=d.$results.scrollTop(),c=d.$results.get(0).scrollHeight-b+a.deltaY,e=a.deltaY>0&&b-a.deltaY<=0,f=a.deltaY<0&&c<=d.$results.height();e?(d.$results.scrollTop(0),a.preventDefault(),a.stopPropagation()):f&&(d.$results.scrollTop(d.$results.get(0).scrollHeight-d.$results.height()),a.preventDefault(),a.stopPropagation())}),this.$results.on("mouseup",".select2-results__option[aria-selected]",function(b){var c=a(this),e=c.data("data");return"true"===c.attr("aria-selected")?void(d.options.get("multiple")?d.trigger("unselect",{originalEvent:b,data:e}):d.trigger("close",{})):void d.trigger("select",{originalEvent:b,data:e})}),this.$results.on("mouseenter",".select2-results__option[aria-selected]",function(b){var c=a(this).data("data");d.getHighlightedResults().removeClass("select2-results__option--highlighted"),d.trigger("results:focus",{data:c,element:a(this)})})},c.prototype.getHighlightedResults=function(){var a=this.$results.find(".select2-results__option--highlighted");return a},c.prototype.destroy=function(){this.$results.remove()},c.prototype.ensureHighlightVisible=function(){var a=this.getHighlightedResults();if(0!==a.length){var b=this.$results.find("[aria-selected]"),c=b.index(a),d=this.$results.offset().top,e=a.offset().top,f=this.$results.scrollTop()+(e-d),g=e-d;f-=2*a.outerHeight(!1),2>=c?this.$results.scrollTop(0):(g>this.$results.outerHeight()||0>g)&&this.$results.scrollTop(f)}},c.prototype.template=function(b,c){var d=this.options.get("templateResult"),e=this.options.get("escapeMarkup"),f=d(b,c);null==f?c.style.display="none":"string"==typeof f?c.innerHTML=e(f):a(c).append(f)},c}),b.define("select2/keys",[],function(){var a={BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46};return a}),b.define("select2/selection/base",["jquery","../utils","../keys"],function(a,b,c){function d(a,b){this.$element=a,this.options=b,d.__super__.constructor.call(this)}return b.Extend(d,b.Observable),d.prototype.render=function(){var b=a('<span class="select2-selection" role="combobox" aria-haspopup="true" aria-expanded="false"></span>');return this._tabindex=0,null!=this.$element.data("old-tabindex")?this._tabindex=this.$element.data("old-tabindex"):null!=this.$element.attr("tabindex")&&(this._tabindex=this.$element.attr("tabindex")),b.attr("title",this.$element.attr("title")),b.attr("tabindex",this._tabindex),this.$selection=b,b},d.prototype.bind=function(a,b){var d=this,e=(a.id+"-container",a.id+"-results");this.container=a,this.$selection.on("focus",function(a){d.trigger("focus",a)}),this.$selection.on("blur",function(a){d._handleBlur(a)}),this.$selection.on("keydown",function(a){d.trigger("keypress",a),a.which===c.SPACE&&a.preventDefault()}),a.on("results:focus",function(a){d.$selection.attr("aria-activedescendant",a.data._resultId)}),a.on("selection:update",function(a){d.update(a.data)}),a.on("open",function(){d.$selection.attr("aria-expanded","true"),d.$selection.attr("aria-owns",e),d._attachCloseHandler(a)}),a.on("close",function(){d.$selection.attr("aria-expanded","false"),d.$selection.removeAttr("aria-activedescendant"),d.$selection.removeAttr("aria-owns"),d.$selection.focus(),d._detachCloseHandler(a)}),a.on("enable",function(){d.$selection.attr("tabindex",d._tabindex)}),a.on("disable",function(){d.$selection.attr("tabindex","-1")})},d.prototype._handleBlur=function(b){var c=this;window.setTimeout(function(){document.activeElement==c.$selection[0]||a.contains(c.$selection[0],document.activeElement)||c.trigger("blur",b)},1)},d.prototype._attachCloseHandler=function(b){a(document.body).on("mousedown.select2."+b.id,function(b){var c=a(b.target),d=c.closest(".select2"),e=a(".select2.select2-container--open");e.each(function(){var b=a(this);if(this!=d[0]){var c=b.data("element");c.select2("close")}})})},d.prototype._detachCloseHandler=function(b){a(document.body).off("mousedown.select2."+b.id)},d.prototype.position=function(a,b){var c=b.find(".selection");c.append(a)},d.prototype.destroy=function(){this._detachCloseHandler(this.container)},d.prototype.update=function(a){throw new Error("The `update` method must be defined in child classes.")},d}),b.define("select2/selection/single",["jquery","./base","../utils","../keys"],function(a,b,c,d){function e(){e.__super__.constructor.apply(this,arguments)}return c.Extend(e,b),e.prototype.render=function(){var a=e.__super__.render.call(this);return a.addClass("select2-selection--single"),a.html('<span class="select2-selection__rendered"></span><span class="select2-selection__arrow" role="presentation"><b role="presentation"></b></span>'),a},e.prototype.bind=function(a,b){var c=this;e.__super__.bind.apply(this,arguments);var d=a.id+"-container";this.$selection.find(".select2-selection__rendered").attr("id",d),this.$selection.attr("aria-labelledby",d),this.$selection.on("mousedown",function(a){1===a.which&&c.trigger("toggle",{originalEvent:a})}),this.$selection.on("focus",function(a){}),this.$selection.on("blur",function(a){}),a.on("focus",function(b){a.isOpen()||c.$selection.focus()}),a.on("selection:update",function(a){c.update(a.data)})},e.prototype.clear=function(){this.$selection.find(".select2-selection__rendered").empty()},e.prototype.display=function(a,b){var c=this.options.get("templateSelection"),d=this.options.get("escapeMarkup");return d(c(a,b))},e.prototype.selectionContainer=function(){return a("<span></span>")},e.prototype.update=function(a){if(0===a.length)return void this.clear();var b=a[0],c=this.$selection.find(".select2-selection__rendered"),d=this.display(b,c);c.empty().append(d),c.prop("title",b.title||b.text)},e}),b.define("select2/selection/multiple",["jquery","./base","../utils"],function(a,b,c){function d(a,b){d.__super__.constructor.apply(this,arguments)}return c.Extend(d,b),d.prototype.render=function(){var a=d.__super__.render.call(this);return a.addClass("select2-selection--multiple"),a.html('<ul class="select2-selection__rendered"></ul>'),a},d.prototype.bind=function(b,c){var e=this;d.__super__.bind.apply(this,arguments),this.$selection.on("click",function(a){e.trigger("toggle",{originalEvent:a})}),this.$selection.on("click",".select2-selection__choice__remove",function(b){if(!e.options.get("disabled")){var c=a(this),d=c.parent(),f=d.data("data");e.trigger("unselect",{originalEvent:b,data:f})}})},d.prototype.clear=function(){this.$selection.find(".select2-selection__rendered").empty()},d.prototype.display=function(a,b){var c=this.options.get("templateSelection"),d=this.options.get("escapeMarkup");return d(c(a,b))},d.prototype.selectionContainer=function(){var b=a('<li class="select2-selection__choice"><span class="select2-selection__choice__remove" role="presentation">&times;</span></li>');return b},d.prototype.update=function(a){if(this.clear(),0!==a.length){for(var b=[],d=0;d<a.length;d++){var e=a[d],f=this.selectionContainer(),g=this.display(e,f);f.append(g),f.prop("title",e.title||e.text),f.data("data",e),b.push(f)}var h=this.$selection.find(".select2-selection__rendered");c.appendMany(h,b)}},d}),b.define("select2/selection/placeholder",["../utils"],function(a){function b(a,b,c){this.placeholder=this.normalizePlaceholder(c.get("placeholder")),a.call(this,b,c)}return b.prototype.normalizePlaceholder=function(a,b){return"string"==typeof b&&(b={id:"",text:b}),b},b.prototype.createPlaceholder=function(a,b){var c=this.selectionContainer();return c.html(this.display(b)),c.addClass("select2-selection__placeholder").removeClass("select2-selection__choice"),c},b.prototype.update=function(a,b){var c=1==b.length&&b[0].id!=this.placeholder.id,d=b.length>1;if(d||c)return a.call(this,b);this.clear();var e=this.createPlaceholder(this.placeholder);this.$selection.find(".select2-selection__rendered").append(e)},b}),b.define("select2/selection/allowClear",["jquery","../keys"],function(a,b){function c(){}return c.prototype.bind=function(a,b,c){var d=this;a.call(this,b,c),null==this.placeholder&&this.options.get("debug")&&window.console&&console.error&&console.error("Select2: The `allowClear` option should be used in combination with the `placeholder` option."),this.$selection.on("mousedown",".select2-selection__clear",function(a){d._handleClear(a)}),b.on("keypress",function(a){d._handleKeyboardClear(a,b)})},c.prototype._handleClear=function(a,b){if(!this.options.get("disabled")){var c=this.$selection.find(".select2-selection__clear");if(0!==c.length){b.stopPropagation();for(var d=c.data("data"),e=0;e<d.length;e++){var f={data:d[e]};if(this.trigger("unselect",f),f.prevented)return}this.$element.val(this.placeholder.id).trigger("change"),this.trigger("toggle",{})}}},c.prototype._handleKeyboardClear=function(a,c,d){d.isOpen()||(c.which==b.DELETE||c.which==b.BACKSPACE)&&this._handleClear(c)},c.prototype.update=function(b,c){if(b.call(this,c),!(this.$selection.find(".select2-selection__placeholder").length>0||0===c.length)){var d=a('<span class="select2-selection__clear">&times;</span>');d.data("data",c),this.$selection.find(".select2-selection__rendered").prepend(d)}},c}),b.define("select2/selection/search",["jquery","../utils","../keys"],function(a,b,c){function d(a,b,c){a.call(this,b,c)}return d.prototype.render=function(b){var c=a('<li class="select2-search select2-search--inline"><input class="select2-search__field" type="search" tabindex="-1" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" role="textbox" aria-autocomplete="list" /></li>');this.$searchContainer=c,this.$search=c.find("input");var d=b.call(this);return this._transferTabIndex(),d},d.prototype.bind=function(a,b,d){var e=this;a.call(this,b,d),b.on("open",function(){e.$search.trigger("focus")}),b.on("close",function(){e.$search.val(""),e.$search.removeAttr("aria-activedescendant"),e.$search.trigger("focus")}),b.on("enable",function(){e.$search.prop("disabled",!1),e._transferTabIndex()}),b.on("disable",function(){e.$search.prop("disabled",!0)}),b.on("focus",function(a){e.$search.trigger("focus")}),b.on("results:focus",function(a){e.$search.attr("aria-activedescendant",a.id)}),this.$selection.on("focusin",".select2-search--inline",function(a){e.trigger("focus",a)}),this.$selection.on("focusout",".select2-search--inline",function(a){e._handleBlur(a)}),this.$selection.on("keydown",".select2-search--inline",function(a){a.stopPropagation(),e.trigger("keypress",a),e._keyUpPrevented=a.isDefaultPrevented();var b=a.which;if(b===c.BACKSPACE&&""===e.$search.val()){var d=e.$searchContainer.prev(".select2-selection__choice");if(d.length>0){var f=d.data("data");e.searchRemoveChoice(f),a.preventDefault()}}});var f=document.documentMode,g=f&&11>=f;this.$selection.on("input.searchcheck",".select2-search--inline",function(a){return g?void e.$selection.off("input.search input.searchcheck"):void e.$selection.off("keyup.search")}),this.$selection.on("keyup.search input.search",".select2-search--inline",function(a){if(g&&"input"===a.type)return void e.$selection.off("input.search input.searchcheck");var b=a.which;b!=c.SHIFT&&b!=c.CTRL&&b!=c.ALT&&b!=c.TAB&&e.handleSearch(a)})},d.prototype._transferTabIndex=function(a){this.$search.attr("tabindex",this.$selection.attr("tabindex")),this.$selection.attr("tabindex","-1")},d.prototype.createPlaceholder=function(a,b){this.$search.attr("placeholder",b.text)},d.prototype.update=function(a,b){var c=this.$search[0]==document.activeElement;this.$search.attr("placeholder",""),a.call(this,b),this.$selection.find(".select2-selection__rendered").append(this.$searchContainer),this.resizeSearch(),c&&this.$search.focus()},d.prototype.handleSearch=function(){if(this.resizeSearch(),!this._keyUpPrevented){var a=this.$search.val();this.trigger("query",{term:a})}this._keyUpPrevented=!1},d.prototype.searchRemoveChoice=function(a,b){this.trigger("unselect",{data:b}),this.$search.val(b.text),this.handleSearch()},d.prototype.resizeSearch=function(){this.$search.css("width","25px");var a="";if(""!==this.$search.attr("placeholder"))a=this.$selection.find(".select2-selection__rendered").innerWidth();else{var b=this.$search.val().length+1;a=.75*b+"em"}this.$search.css("width",a)},d}),b.define("select2/selection/eventRelay",["jquery"],function(a){function b(){}return b.prototype.bind=function(b,c,d){var e=this,f=["open","opening","close","closing","select","selecting","unselect","unselecting"],g=["opening","closing","selecting","unselecting"];b.call(this,c,d),c.on("*",function(b,c){if(-1!==a.inArray(b,f)){c=c||{};var d=a.Event("select2:"+b,{params:c});e.$element.trigger(d),-1!==a.inArray(b,g)&&(c.prevented=d.isDefaultPrevented())}})},b}),b.define("select2/translation",["jquery","require"],function(a,b){function c(a){this.dict=a||{}}return c.prototype.all=function(){return this.dict},c.prototype.get=function(a){return this.dict[a]},c.prototype.extend=function(b){this.dict=a.extend({},b.all(),this.dict)},c._cache={},c.loadPath=function(a){if(!(a in c._cache)){var d=b(a);c._cache[a]=d}return new c(c._cache[a])},c}),b.define("select2/diacritics",[],function(){var a={"Ⓐ":"A","A":"A","À":"A","Á":"A","Â":"A","Ầ":"A","Ấ":"A","Ẫ":"A","Ẩ":"A","Ã":"A","Ā":"A","Ă":"A","Ằ":"A","Ắ":"A","Ẵ":"A","Ẳ":"A","Ȧ":"A","Ǡ":"A","Ä":"A","Ǟ":"A","Ả":"A","Å":"A","Ǻ":"A","Ǎ":"A","Ȁ":"A","Ȃ":"A","Ạ":"A","Ậ":"A","Ặ":"A","Ḁ":"A","Ą":"A","Ⱥ":"A","Ɐ":"A","Ꜳ":"AA","Æ":"AE","Ǽ":"AE","Ǣ":"AE","Ꜵ":"AO","Ꜷ":"AU","Ꜹ":"AV","Ꜻ":"AV","Ꜽ":"AY","Ⓑ":"B","B":"B","Ḃ":"B","Ḅ":"B","Ḇ":"B","Ƀ":"B","Ƃ":"B","Ɓ":"B","Ⓒ":"C","C":"C","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","Ç":"C","Ḉ":"C","Ƈ":"C","Ȼ":"C","Ꜿ":"C","Ⓓ":"D","D":"D","Ḋ":"D","Ď":"D","Ḍ":"D","Ḑ":"D","Ḓ":"D","Ḏ":"D","Đ":"D","Ƌ":"D","Ɗ":"D","Ɖ":"D","Ꝺ":"D","DZ":"DZ","DŽ":"DZ","Dz":"Dz","Dž":"Dz","Ⓔ":"E","E":"E","È":"E","É":"E","Ê":"E","Ề":"E","Ế":"E","Ễ":"E","Ể":"E","Ẽ":"E","Ē":"E","Ḕ":"E","Ḗ":"E","Ĕ":"E","Ė":"E","Ë":"E","Ẻ":"E","Ě":"E","Ȅ":"E","Ȇ":"E","Ẹ":"E","Ệ":"E","Ȩ":"E","Ḝ":"E","Ę":"E","Ḙ":"E","Ḛ":"E","Ɛ":"E","Ǝ":"E","Ⓕ":"F","F":"F","Ḟ":"F","Ƒ":"F","Ꝼ":"F","Ⓖ":"G","G":"G","Ǵ":"G","Ĝ":"G","Ḡ":"G","Ğ":"G","Ġ":"G","Ǧ":"G","Ģ":"G","Ǥ":"G","Ɠ":"G","Ꞡ":"G","Ᵹ":"G","Ꝿ":"G","Ⓗ":"H","H":"H","Ĥ":"H","Ḣ":"H","Ḧ":"H","Ȟ":"H","Ḥ":"H","Ḩ":"H","Ḫ":"H","Ħ":"H","Ⱨ":"H","Ⱶ":"H","Ɥ":"H","Ⓘ":"I","I":"I","Ì":"I","Í":"I","Î":"I","Ĩ":"I","Ī":"I","Ĭ":"I","İ":"I","Ï":"I","Ḯ":"I","Ỉ":"I","Ǐ":"I","Ȉ":"I","Ȋ":"I","Ị":"I","Į":"I","Ḭ":"I","Ɨ":"I","Ⓙ":"J","J":"J","Ĵ":"J","Ɉ":"J","Ⓚ":"K","K":"K","Ḱ":"K","Ǩ":"K","Ḳ":"K","Ķ":"K","Ḵ":"K","Ƙ":"K","Ⱪ":"K","Ꝁ":"K","Ꝃ":"K","Ꝅ":"K","Ꞣ":"K","Ⓛ":"L","L":"L","Ŀ":"L","Ĺ":"L","Ľ":"L","Ḷ":"L","Ḹ":"L","Ļ":"L","Ḽ":"L","Ḻ":"L","Ł":"L","Ƚ":"L","Ɫ":"L","Ⱡ":"L","Ꝉ":"L","Ꝇ":"L","Ꞁ":"L","LJ":"LJ","Lj":"Lj","Ⓜ":"M","M":"M","Ḿ":"M","Ṁ":"M","Ṃ":"M","Ɱ":"M","Ɯ":"M","Ⓝ":"N","N":"N","Ǹ":"N","Ń":"N","Ñ":"N","Ṅ":"N","Ň":"N","Ṇ":"N","Ņ":"N","Ṋ":"N","Ṉ":"N","Ƞ":"N","Ɲ":"N","Ꞑ":"N","Ꞥ":"N","NJ":"NJ","Nj":"Nj","Ⓞ":"O","O":"O","Ò":"O","Ó":"O","Ô":"O","Ồ":"O","Ố":"O","Ỗ":"O","Ổ":"O","Õ":"O","Ṍ":"O","Ȭ":"O","Ṏ":"O","Ō":"O","Ṑ":"O","Ṓ":"O","Ŏ":"O","Ȯ":"O","Ȱ":"O","Ö":"O","Ȫ":"O","Ỏ":"O","Ő":"O","Ǒ":"O","Ȍ":"O","Ȏ":"O","Ơ":"O","Ờ":"O","Ớ":"O","Ỡ":"O","Ở":"O","Ợ":"O","Ọ":"O","Ộ":"O","Ǫ":"O","Ǭ":"O","Ø":"O","Ǿ":"O","Ɔ":"O","Ɵ":"O","Ꝋ":"O","Ꝍ":"O","Ƣ":"OI","Ꝏ":"OO","Ȣ":"OU","Ⓟ":"P","P":"P","Ṕ":"P","Ṗ":"P","Ƥ":"P","Ᵽ":"P","Ꝑ":"P","Ꝓ":"P","Ꝕ":"P","Ⓠ":"Q","Q":"Q","Ꝗ":"Q","Ꝙ":"Q","Ɋ":"Q","Ⓡ":"R","R":"R","Ŕ":"R","Ṙ":"R","Ř":"R","Ȑ":"R","Ȓ":"R","Ṛ":"R","Ṝ":"R","Ŗ":"R","Ṟ":"R","Ɍ":"R","Ɽ":"R","Ꝛ":"R","Ꞧ":"R","Ꞃ":"R","Ⓢ":"S","S":"S","ẞ":"S","Ś":"S","Ṥ":"S","Ŝ":"S","Ṡ":"S","Š":"S","Ṧ":"S","Ṣ":"S","Ṩ":"S","Ș":"S","Ş":"S","Ȿ":"S","Ꞩ":"S","Ꞅ":"S","Ⓣ":"T","T":"T","Ṫ":"T","Ť":"T","Ṭ":"T","Ț":"T","Ţ":"T","Ṱ":"T","Ṯ":"T","Ŧ":"T","Ƭ":"T","Ʈ":"T","Ⱦ":"T","Ꞇ":"T","Ꜩ":"TZ","Ⓤ":"U","U":"U","Ù":"U","Ú":"U","Û":"U","Ũ":"U","Ṹ":"U","Ū":"U","Ṻ":"U","Ŭ":"U","Ü":"U","Ǜ":"U","Ǘ":"U","Ǖ":"U","Ǚ":"U","Ủ":"U","Ů":"U","Ű":"U","Ǔ":"U","Ȕ":"U","Ȗ":"U","Ư":"U","Ừ":"U","Ứ":"U","Ữ":"U","Ử":"U","Ự":"U","Ụ":"U","Ṳ":"U","Ų":"U","Ṷ":"U","Ṵ":"U","Ʉ":"U","Ⓥ":"V","V":"V","Ṽ":"V","Ṿ":"V","Ʋ":"V","Ꝟ":"V","Ʌ":"V","Ꝡ":"VY","Ⓦ":"W","W":"W","Ẁ":"W","Ẃ":"W","Ŵ":"W","Ẇ":"W","Ẅ":"W","Ẉ":"W","Ⱳ":"W","Ⓧ":"X","X":"X","Ẋ":"X","Ẍ":"X","Ⓨ":"Y","Y":"Y","Ỳ":"Y","Ý":"Y","Ŷ":"Y","Ỹ":"Y","Ȳ":"Y","Ẏ":"Y","Ÿ":"Y","Ỷ":"Y","Ỵ":"Y","Ƴ":"Y","Ɏ":"Y","Ỿ":"Y","Ⓩ":"Z","Z":"Z","Ź":"Z","Ẑ":"Z","Ż":"Z","Ž":"Z","Ẓ":"Z","Ẕ":"Z","Ƶ":"Z","Ȥ":"Z","Ɀ":"Z","Ⱬ":"Z","Ꝣ":"Z","ⓐ":"a","a":"a","ẚ":"a","à":"a","á":"a","â":"a","ầ":"a","ấ":"a","ẫ":"a","ẩ":"a","ã":"a","ā":"a","ă":"a","ằ":"a","ắ":"a","ẵ":"a","ẳ":"a","ȧ":"a","ǡ":"a","ä":"a","ǟ":"a","ả":"a","å":"a","ǻ":"a","ǎ":"a","ȁ":"a","ȃ":"a","ạ":"a","ậ":"a","ặ":"a","ḁ":"a","ą":"a","ⱥ":"a","ɐ":"a","ꜳ":"aa","æ":"ae","ǽ":"ae","ǣ":"ae","ꜵ":"ao","ꜷ":"au","ꜹ":"av","ꜻ":"av","ꜽ":"ay","ⓑ":"b","b":"b","ḃ":"b","ḅ":"b","ḇ":"b","ƀ":"b","ƃ":"b","ɓ":"b","ⓒ":"c","c":"c","ć":"c","ĉ":"c","ċ":"c","č":"c","ç":"c","ḉ":"c","ƈ":"c","ȼ":"c","ꜿ":"c","ↄ":"c","ⓓ":"d","d":"d","ḋ":"d","ď":"d","ḍ":"d","ḑ":"d","ḓ":"d","ḏ":"d","đ":"d","ƌ":"d","ɖ":"d","ɗ":"d","ꝺ":"d","dz":"dz","dž":"dz","ⓔ":"e","e":"e","è":"e","é":"e","ê":"e","ề":"e","ế":"e","ễ":"e","ể":"e","ẽ":"e","ē":"e","ḕ":"e","ḗ":"e","ĕ":"e","ė":"e","ë":"e","ẻ":"e","ě":"e","ȅ":"e","ȇ":"e","ẹ":"e","ệ":"e","ȩ":"e","ḝ":"e","ę":"e","ḙ":"e","ḛ":"e","ɇ":"e","ɛ":"e","ǝ":"e","ⓕ":"f","f":"f","ḟ":"f","ƒ":"f","ꝼ":"f","ⓖ":"g","g":"g","ǵ":"g","ĝ":"g","ḡ":"g","ğ":"g","ġ":"g","ǧ":"g","ģ":"g","ǥ":"g","ɠ":"g","ꞡ":"g","ᵹ":"g","ꝿ":"g","ⓗ":"h","h":"h","ĥ":"h","ḣ":"h","ḧ":"h","ȟ":"h","ḥ":"h","ḩ":"h","ḫ":"h","ẖ":"h","ħ":"h","ⱨ":"h","ⱶ":"h","ɥ":"h","ƕ":"hv","ⓘ":"i","i":"i","ì":"i","í":"i","î":"i","ĩ":"i","ī":"i","ĭ":"i","ï":"i","ḯ":"i","ỉ":"i","ǐ":"i","ȉ":"i","ȋ":"i","ị":"i","į":"i","ḭ":"i","ɨ":"i","ı":"i","ⓙ":"j","j":"j","ĵ":"j","ǰ":"j","ɉ":"j","ⓚ":"k","k":"k","ḱ":"k","ǩ":"k","ḳ":"k","ķ":"k","ḵ":"k","ƙ":"k","ⱪ":"k","ꝁ":"k","ꝃ":"k","ꝅ":"k","ꞣ":"k","ⓛ":"l","l":"l","ŀ":"l","ĺ":"l","ľ":"l","ḷ":"l","ḹ":"l","ļ":"l","ḽ":"l","ḻ":"l","ſ":"l","ł":"l","ƚ":"l","ɫ":"l","ⱡ":"l","ꝉ":"l","ꞁ":"l","ꝇ":"l","lj":"lj","ⓜ":"m","m":"m","ḿ":"m","ṁ":"m","ṃ":"m","ɱ":"m","ɯ":"m","ⓝ":"n","n":"n","ǹ":"n","ń":"n","ñ":"n","ṅ":"n","ň":"n","ṇ":"n","ņ":"n","ṋ":"n","ṉ":"n","ƞ":"n","ɲ":"n","ʼn":"n","ꞑ":"n","ꞥ":"n","nj":"nj","ⓞ":"o","o":"o","ò":"o","ó":"o","ô":"o","ồ":"o","ố":"o","ỗ":"o","ổ":"o","õ":"o","ṍ":"o","ȭ":"o","ṏ":"o","ō":"o","ṑ":"o","ṓ":"o","ŏ":"o","ȯ":"o","ȱ":"o","ö":"o","ȫ":"o","ỏ":"o","ő":"o","ǒ":"o","ȍ":"o","ȏ":"o","ơ":"o","ờ":"o","ớ":"o","ỡ":"o","ở":"o","ợ":"o","ọ":"o","ộ":"o","ǫ":"o","ǭ":"o","ø":"o","ǿ":"o","ɔ":"o","ꝋ":"o","ꝍ":"o","ɵ":"o","ƣ":"oi","ȣ":"ou","ꝏ":"oo","ⓟ":"p","p":"p","ṕ":"p","ṗ":"p","ƥ":"p","ᵽ":"p","ꝑ":"p","ꝓ":"p","ꝕ":"p","ⓠ":"q","q":"q","ɋ":"q","ꝗ":"q","ꝙ":"q","ⓡ":"r","r":"r","ŕ":"r","ṙ":"r","ř":"r","ȑ":"r","ȓ":"r","ṛ":"r","ṝ":"r","ŗ":"r","ṟ":"r","ɍ":"r","ɽ":"r","ꝛ":"r","ꞧ":"r","ꞃ":"r","ⓢ":"s","s":"s","ß":"s","ś":"s","ṥ":"s","ŝ":"s","ṡ":"s","š":"s","ṧ":"s","ṣ":"s","ṩ":"s","ș":"s","ş":"s","ȿ":"s","ꞩ":"s","ꞅ":"s","ẛ":"s","ⓣ":"t","t":"t","ṫ":"t","ẗ":"t","ť":"t","ṭ":"t","ț":"t","ţ":"t","ṱ":"t","ṯ":"t","ŧ":"t","ƭ":"t","ʈ":"t","ⱦ":"t","ꞇ":"t","ꜩ":"tz","ⓤ":"u","u":"u","ù":"u","ú":"u","û":"u","ũ":"u","ṹ":"u","ū":"u","ṻ":"u","ŭ":"u","ü":"u","ǜ":"u","ǘ":"u","ǖ":"u","ǚ":"u","ủ":"u","ů":"u","ű":"u","ǔ":"u","ȕ":"u","ȗ":"u","ư":"u","ừ":"u","ứ":"u","ữ":"u","ử":"u","ự":"u","ụ":"u","ṳ":"u","ų":"u","ṷ":"u","ṵ":"u","ʉ":"u","ⓥ":"v","v":"v","ṽ":"v","ṿ":"v","ʋ":"v","ꝟ":"v","ʌ":"v","ꝡ":"vy","ⓦ":"w","w":"w","ẁ":"w","ẃ":"w","ŵ":"w","ẇ":"w","ẅ":"w","ẘ":"w","ẉ":"w","ⱳ":"w","ⓧ":"x","x":"x","ẋ":"x","ẍ":"x","ⓨ":"y","y":"y","ỳ":"y","ý":"y","ŷ":"y","ỹ":"y","ȳ":"y","ẏ":"y","ÿ":"y","ỷ":"y","ẙ":"y","ỵ":"y","ƴ":"y","ɏ":"y","ỿ":"y","ⓩ":"z","z":"z","ź":"z","ẑ":"z","ż":"z","ž":"z","ẓ":"z","ẕ":"z","ƶ":"z","ȥ":"z","ɀ":"z","ⱬ":"z","ꝣ":"z","Ά":"Α","Έ":"Ε","Ή":"Η","Ί":"Ι","Ϊ":"Ι","Ό":"Ο","Ύ":"Υ","Ϋ":"Υ","Ώ":"Ω","ά":"α","έ":"ε","ή":"η","ί":"ι","ϊ":"ι","ΐ":"ι","ό":"ο","ύ":"υ","ϋ":"υ","ΰ":"υ","ω":"ω","ς":"σ"};return a}),b.define("select2/data/base",["../utils"],function(a){function b(a,c){b.__super__.constructor.call(this)}return a.Extend(b,a.Observable),b.prototype.current=function(a){throw new Error("The `current` method must be defined in child classes.")},b.prototype.query=function(a,b){throw new Error("The `query` method must be defined in child classes.")},b.prototype.bind=function(a,b){},b.prototype.destroy=function(){},b.prototype.generateResultId=function(b,c){var d=b.id+"-result-";return d+=a.generateChars(4),d+=null!=c.id?"-"+c.id.toString():"-"+a.generateChars(4)},b}),b.define("select2/data/select",["./base","../utils","jquery"],function(a,b,c){function d(a,b){this.$element=a,this.options=b,d.__super__.constructor.call(this)}return b.Extend(d,a),d.prototype.current=function(a){var b=[],d=this;this.$element.find(":selected").each(function(){var a=c(this),e=d.item(a);b.push(e)}),a(b)},d.prototype.select=function(a){var b=this;if(a.selected=!0,c(a.element).is("option"))return a.element.selected=!0,void this.$element.trigger("change");
2
+ if(this.$element.prop("multiple"))this.current(function(d){var e=[];a=[a],a.push.apply(a,d);for(var f=0;f<a.length;f++){var g=a[f].id;-1===c.inArray(g,e)&&e.push(g)}b.$element.val(e),b.$element.trigger("change")});else{var d=a.id;this.$element.val(d),this.$element.trigger("change")}},d.prototype.unselect=function(a){var b=this;if(this.$element.prop("multiple"))return a.selected=!1,c(a.element).is("option")?(a.element.selected=!1,void this.$element.trigger("change")):void this.current(function(d){for(var e=[],f=0;f<d.length;f++){var g=d[f].id;g!==a.id&&-1===c.inArray(g,e)&&e.push(g)}b.$element.val(e),b.$element.trigger("change")})},d.prototype.bind=function(a,b){var c=this;this.container=a,a.on("select",function(a){c.select(a.data)}),a.on("unselect",function(a){c.unselect(a.data)})},d.prototype.destroy=function(){this.$element.find("*").each(function(){c.removeData(this,"data")})},d.prototype.query=function(a,b){var d=[],e=this,f=this.$element.children();f.each(function(){var b=c(this);if(b.is("option")||b.is("optgroup")){var f=e.item(b),g=e.matches(a,f);null!==g&&d.push(g)}}),b({results:d})},d.prototype.addOptions=function(a){b.appendMany(this.$element,a)},d.prototype.option=function(a){var b;a.children?(b=document.createElement("optgroup"),b.label=a.text):(b=document.createElement("option"),void 0!==b.textContent?b.textContent=a.text:b.innerText=a.text),a.id&&(b.value=a.id),a.disabled&&(b.disabled=!0),a.selected&&(b.selected=!0),a.title&&(b.title=a.title);var d=c(b),e=this._normalizeItem(a);return e.element=b,c.data(b,"data",e),d},d.prototype.item=function(a){var b={};if(b=c.data(a[0],"data"),null!=b)return b;if(a.is("option"))b={id:a.val(),text:a.text(),disabled:a.prop("disabled"),selected:a.prop("selected"),title:a.prop("title")};else if(a.is("optgroup")){b={text:a.prop("label"),children:[],title:a.prop("title")};for(var d=a.children("option"),e=[],f=0;f<d.length;f++){var g=c(d[f]),h=this.item(g);e.push(h)}b.children=e}return b=this._normalizeItem(b),b.element=a[0],c.data(a[0],"data",b),b},d.prototype._normalizeItem=function(a){c.isPlainObject(a)||(a={id:a,text:a}),a=c.extend({},{text:""},a);var b={selected:!1,disabled:!1};return null!=a.id&&(a.id=a.id.toString()),null!=a.text&&(a.text=a.text.toString()),null==a._resultId&&a.id&&null!=this.container&&(a._resultId=this.generateResultId(this.container,a)),c.extend({},b,a)},d.prototype.matches=function(a,b){var c=this.options.get("matcher");return c(a,b)},d}),b.define("select2/data/array",["./select","../utils","jquery"],function(a,b,c){function d(a,b){var c=b.get("data")||[];d.__super__.constructor.call(this,a,b),this.addOptions(this.convertToOptions(c))}return b.Extend(d,a),d.prototype.select=function(a){var b=this.$element.find("option").filter(function(b,c){return c.value==a.id.toString()});0===b.length&&(b=this.option(a),this.addOptions(b)),d.__super__.select.call(this,a)},d.prototype.convertToOptions=function(a){function d(a){return function(){return c(this).val()==a.id}}for(var e=this,f=this.$element.find("option"),g=f.map(function(){return e.item(c(this)).id}).get(),h=[],i=0;i<a.length;i++){var j=this._normalizeItem(a[i]);if(c.inArray(j.id,g)>=0){var k=f.filter(d(j)),l=this.item(k),m=c.extend(!0,{},j,l),n=this.option(m);k.replaceWith(n)}else{var o=this.option(j);if(j.children){var p=this.convertToOptions(j.children);b.appendMany(o,p)}h.push(o)}}return h},d}),b.define("select2/data/ajax",["./array","../utils","jquery"],function(a,b,c){function d(a,b){this.ajaxOptions=this._applyDefaults(b.get("ajax")),null!=this.ajaxOptions.processResults&&(this.processResults=this.ajaxOptions.processResults),d.__super__.constructor.call(this,a,b)}return b.Extend(d,a),d.prototype._applyDefaults=function(a){var b={data:function(a){return c.extend({},a,{q:a.term})},transport:function(a,b,d){var e=c.ajax(a);return e.then(b),e.fail(d),e}};return c.extend({},b,a,!0)},d.prototype.processResults=function(a){return a},d.prototype.query=function(a,b){function d(){var d=f.transport(f,function(d){var f=e.processResults(d,a);e.options.get("debug")&&window.console&&console.error&&(f&&f.results&&c.isArray(f.results)||console.error("Select2: The AJAX results did not return an array in the `results` key of the response.")),b(f)},function(){d.status&&"0"===d.status||e.trigger("results:message",{message:"errorLoading"})});e._request=d}var e=this;null!=this._request&&(c.isFunction(this._request.abort)&&this._request.abort(),this._request=null);var f=c.extend({type:"GET"},this.ajaxOptions);"function"==typeof f.url&&(f.url=f.url.call(this.$element,a)),"function"==typeof f.data&&(f.data=f.data.call(this.$element,a)),this.ajaxOptions.delay&&null!=a.term?(this._queryTimeout&&window.clearTimeout(this._queryTimeout),this._queryTimeout=window.setTimeout(d,this.ajaxOptions.delay)):d()},d}),b.define("select2/data/tags",["jquery"],function(a){function b(b,c,d){var e=d.get("tags"),f=d.get("createTag");void 0!==f&&(this.createTag=f);var g=d.get("insertTag");if(void 0!==g&&(this.insertTag=g),b.call(this,c,d),a.isArray(e))for(var h=0;h<e.length;h++){var i=e[h],j=this._normalizeItem(i),k=this.option(j);this.$element.append(k)}}return b.prototype.query=function(a,b,c){function d(a,f){for(var g=a.results,h=0;h<g.length;h++){var i=g[h],j=null!=i.children&&!d({results:i.children},!0),k=i.text===b.term;if(k||j)return f?!1:(a.data=g,void c(a))}if(f)return!0;var l=e.createTag(b);if(null!=l){var m=e.option(l);m.attr("data-select2-tag",!0),e.addOptions([m]),e.insertTag(g,l)}a.results=g,c(a)}var e=this;return this._removeOldTags(),null==b.term||null!=b.page?void a.call(this,b,c):void a.call(this,b,d)},b.prototype.createTag=function(b,c){var d=a.trim(c.term);return""===d?null:{id:d,text:d}},b.prototype.insertTag=function(a,b,c){b.unshift(c)},b.prototype._removeOldTags=function(b){var c=(this._lastTag,this.$element.find("option[data-select2-tag]"));c.each(function(){this.selected||a(this).remove()})},b}),b.define("select2/data/tokenizer",["jquery"],function(a){function b(a,b,c){var d=c.get("tokenizer");void 0!==d&&(this.tokenizer=d),a.call(this,b,c)}return b.prototype.bind=function(a,b,c){a.call(this,b,c),this.$search=b.dropdown.$search||b.selection.$search||c.find(".select2-search__field")},b.prototype.query=function(b,c,d){function e(b){var c=g._normalizeItem(b),d=g.$element.find("option").filter(function(){return a(this).val()===c.id});if(!d.length){var e=g.option(c);e.attr("data-select2-tag",!0),g._removeOldTags(),g.addOptions([e])}f(c)}function f(a){g.trigger("select",{data:a})}var g=this;c.term=c.term||"";var h=this.tokenizer(c,this.options,e);h.term!==c.term&&(this.$search.length&&(this.$search.val(h.term),this.$search.focus()),c.term=h.term),b.call(this,c,d)},b.prototype.tokenizer=function(b,c,d,e){for(var f=d.get("tokenSeparators")||[],g=c.term,h=0,i=this.createTag||function(a){return{id:a.term,text:a.term}};h<g.length;){var j=g[h];if(-1!==a.inArray(j,f)){var k=g.substr(0,h),l=a.extend({},c,{term:k}),m=i(l);null!=m?(e(m),g=g.substr(h+1)||"",h=0):h++}else h++}return{term:g}},b}),b.define("select2/data/minimumInputLength",[],function(){function a(a,b,c){this.minimumInputLength=c.get("minimumInputLength"),a.call(this,b,c)}return a.prototype.query=function(a,b,c){return b.term=b.term||"",b.term.length<this.minimumInputLength?void this.trigger("results:message",{message:"inputTooShort",args:{minimum:this.minimumInputLength,input:b.term,params:b}}):void a.call(this,b,c)},a}),b.define("select2/data/maximumInputLength",[],function(){function a(a,b,c){this.maximumInputLength=c.get("maximumInputLength"),a.call(this,b,c)}return a.prototype.query=function(a,b,c){return b.term=b.term||"",this.maximumInputLength>0&&b.term.length>this.maximumInputLength?void this.trigger("results:message",{message:"inputTooLong",args:{maximum:this.maximumInputLength,input:b.term,params:b}}):void a.call(this,b,c)},a}),b.define("select2/data/maximumSelectionLength",[],function(){function a(a,b,c){this.maximumSelectionLength=c.get("maximumSelectionLength"),a.call(this,b,c)}return a.prototype.query=function(a,b,c){var d=this;this.current(function(e){var f=null!=e?e.length:0;return d.maximumSelectionLength>0&&f>=d.maximumSelectionLength?void d.trigger("results:message",{message:"maximumSelected",args:{maximum:d.maximumSelectionLength}}):void a.call(d,b,c)})},a}),b.define("select2/dropdown",["jquery","./utils"],function(a,b){function c(a,b){this.$element=a,this.options=b,c.__super__.constructor.call(this)}return b.Extend(c,b.Observable),c.prototype.render=function(){var b=a('<span class="select2-dropdown"><span class="select2-results"></span></span>');return b.attr("dir",this.options.get("dir")),this.$dropdown=b,b},c.prototype.bind=function(){},c.prototype.position=function(a,b){},c.prototype.destroy=function(){this.$dropdown.remove()},c}),b.define("select2/dropdown/search",["jquery","../utils"],function(a,b){function c(){}return c.prototype.render=function(b){var c=b.call(this),d=a('<span class="select2-search select2-search--dropdown"><input class="select2-search__field" type="search" tabindex="-1" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" role="textbox" /></span>');return this.$searchContainer=d,this.$search=d.find("input"),c.prepend(d),c},c.prototype.bind=function(b,c,d){var e=this;b.call(this,c,d),this.$search.on("keydown",function(a){e.trigger("keypress",a),e._keyUpPrevented=a.isDefaultPrevented()}),this.$search.on("input",function(b){a(this).off("keyup")}),this.$search.on("keyup input",function(a){e.handleSearch(a)}),c.on("open",function(){e.$search.attr("tabindex",0),e.$search.focus(),window.setTimeout(function(){e.$search.focus()},0)}),c.on("close",function(){e.$search.attr("tabindex",-1),e.$search.val("")}),c.on("focus",function(){c.isOpen()&&e.$search.focus()}),c.on("results:all",function(a){if(null==a.query.term||""===a.query.term){var b=e.showSearch(a);b?e.$searchContainer.removeClass("select2-search--hide"):e.$searchContainer.addClass("select2-search--hide")}})},c.prototype.handleSearch=function(a){if(!this._keyUpPrevented){var b=this.$search.val();this.trigger("query",{term:b})}this._keyUpPrevented=!1},c.prototype.showSearch=function(a,b){return!0},c}),b.define("select2/dropdown/hidePlaceholder",[],function(){function a(a,b,c,d){this.placeholder=this.normalizePlaceholder(c.get("placeholder")),a.call(this,b,c,d)}return a.prototype.append=function(a,b){b.results=this.removePlaceholder(b.results),a.call(this,b)},a.prototype.normalizePlaceholder=function(a,b){return"string"==typeof b&&(b={id:"",text:b}),b},a.prototype.removePlaceholder=function(a,b){for(var c=b.slice(0),d=b.length-1;d>=0;d--){var e=b[d];this.placeholder.id===e.id&&c.splice(d,1)}return c},a}),b.define("select2/dropdown/infiniteScroll",["jquery"],function(a){function b(a,b,c,d){this.lastParams={},a.call(this,b,c,d),this.$loadingMore=this.createLoadingMore(),this.loading=!1}return b.prototype.append=function(a,b){this.$loadingMore.remove(),this.loading=!1,a.call(this,b),this.showLoadingMore(b)&&this.$results.append(this.$loadingMore)},b.prototype.bind=function(b,c,d){var e=this;b.call(this,c,d),c.on("query",function(a){e.lastParams=a,e.loading=!0}),c.on("query:append",function(a){e.lastParams=a,e.loading=!0}),this.$results.on("scroll",function(){var b=a.contains(document.documentElement,e.$loadingMore[0]);if(!e.loading&&b){var c=e.$results.offset().top+e.$results.outerHeight(!1),d=e.$loadingMore.offset().top+e.$loadingMore.outerHeight(!1);c+50>=d&&e.loadMore()}})},b.prototype.loadMore=function(){this.loading=!0;var b=a.extend({},{page:1},this.lastParams);b.page++,this.trigger("query:append",b)},b.prototype.showLoadingMore=function(a,b){return b.pagination&&b.pagination.more},b.prototype.createLoadingMore=function(){var b=a('<li class="select2-results__option select2-results__option--load-more"role="treeitem" aria-disabled="true"></li>'),c=this.options.get("translations").get("loadingMore");return b.html(c(this.lastParams)),b},b}),b.define("select2/dropdown/attachBody",["jquery","../utils"],function(a,b){function c(b,c,d){this.$dropdownParent=d.get("dropdownParent")||a(document.body),b.call(this,c,d)}return c.prototype.bind=function(a,b,c){var d=this,e=!1;a.call(this,b,c),b.on("open",function(){d._showDropdown(),d._attachPositioningHandler(b),e||(e=!0,b.on("results:all",function(){d._positionDropdown(),d._resizeDropdown()}),b.on("results:append",function(){d._positionDropdown(),d._resizeDropdown()}))}),b.on("close",function(){d._hideDropdown(),d._detachPositioningHandler(b)}),this.$dropdownContainer.on("mousedown",function(a){a.stopPropagation()})},c.prototype.destroy=function(a){a.call(this),this.$dropdownContainer.remove()},c.prototype.position=function(a,b,c){b.attr("class",c.attr("class")),b.removeClass("select2"),b.addClass("select2-container--open"),b.css({position:"absolute",top:-999999}),this.$container=c},c.prototype.render=function(b){var c=a("<span></span>"),d=b.call(this);return c.append(d),this.$dropdownContainer=c,c},c.prototype._hideDropdown=function(a){this.$dropdownContainer.detach()},c.prototype._attachPositioningHandler=function(c,d){var e=this,f="scroll.select2."+d.id,g="resize.select2."+d.id,h="orientationchange.select2."+d.id,i=this.$container.parents().filter(b.hasScroll);i.each(function(){a(this).data("select2-scroll-position",{x:a(this).scrollLeft(),y:a(this).scrollTop()})}),i.on(f,function(b){var c=a(this).data("select2-scroll-position");a(this).scrollTop(c.y)}),a(window).on(f+" "+g+" "+h,function(a){e._positionDropdown(),e._resizeDropdown()})},c.prototype._detachPositioningHandler=function(c,d){var e="scroll.select2."+d.id,f="resize.select2."+d.id,g="orientationchange.select2."+d.id,h=this.$container.parents().filter(b.hasScroll);h.off(e),a(window).off(e+" "+f+" "+g)},c.prototype._positionDropdown=function(){var b=a(window),c=this.$dropdown.hasClass("select2-dropdown--above"),d=this.$dropdown.hasClass("select2-dropdown--below"),e=null,f=this.$container.offset();f.bottom=f.top+this.$container.outerHeight(!1);var g={height:this.$container.outerHeight(!1)};g.top=f.top,g.bottom=f.top+g.height;var h={height:this.$dropdown.outerHeight(!1)},i={top:b.scrollTop(),bottom:b.scrollTop()+b.height()},j=i.top<f.top-h.height,k=i.bottom>f.bottom+h.height,l={left:f.left,top:g.bottom},m=this.$dropdownParent;"static"===m.css("position")&&(m=m.offsetParent());var n=m.offset();l.top-=n.top,l.left-=n.left,c||d||(e="below"),k||!j||c?!j&&k&&c&&(e="below"):e="above",("above"==e||c&&"below"!==e)&&(l.top=g.top-n.top-h.height),null!=e&&(this.$dropdown.removeClass("select2-dropdown--below select2-dropdown--above").addClass("select2-dropdown--"+e),this.$container.removeClass("select2-container--below select2-container--above").addClass("select2-container--"+e)),this.$dropdownContainer.css(l)},c.prototype._resizeDropdown=function(){var a={width:this.$container.outerWidth(!1)+"px"};this.options.get("dropdownAutoWidth")&&(a.minWidth=a.width,a.position="relative",a.width="auto"),this.$dropdown.css(a)},c.prototype._showDropdown=function(a){this.$dropdownContainer.appendTo(this.$dropdownParent),this._positionDropdown(),this._resizeDropdown()},c}),b.define("select2/dropdown/minimumResultsForSearch",[],function(){function a(b){for(var c=0,d=0;d<b.length;d++){var e=b[d];e.children?c+=a(e.children):c++}return c}function b(a,b,c,d){this.minimumResultsForSearch=c.get("minimumResultsForSearch"),this.minimumResultsForSearch<0&&(this.minimumResultsForSearch=1/0),a.call(this,b,c,d)}return b.prototype.showSearch=function(b,c){return a(c.data.results)<this.minimumResultsForSearch?!1:b.call(this,c)},b}),b.define("select2/dropdown/selectOnClose",[],function(){function a(){}return a.prototype.bind=function(a,b,c){var d=this;a.call(this,b,c),b.on("close",function(a){d._handleSelectOnClose(a)})},a.prototype._handleSelectOnClose=function(a,b){if(b&&null!=b.originalSelect2Event){var c=b.originalSelect2Event;if("select"===c._type||"unselect"===c._type)return}var d=this.getHighlightedResults();if(!(d.length<1)){var e=d.data("data");null!=e.element&&e.element.selected||null==e.element&&e.selected||this.trigger("select",{data:e})}},a}),b.define("select2/dropdown/closeOnSelect",[],function(){function a(){}return a.prototype.bind=function(a,b,c){var d=this;a.call(this,b,c),b.on("select",function(a){d._selectTriggered(a)}),b.on("unselect",function(a){d._selectTriggered(a)})},a.prototype._selectTriggered=function(a,b){var c=b.originalEvent;c&&c.ctrlKey||this.trigger("close",{originalEvent:c,originalSelect2Event:b})},a}),b.define("select2/i18n/en",[],function(){return{errorLoading:function(){return"The results could not be loaded."},inputTooLong:function(a){var b=a.input.length-a.maximum,c="Please delete "+b+" character";return 1!=b&&(c+="s"),c},inputTooShort:function(a){var b=a.minimum-a.input.length,c="Please enter "+b+" or more characters";return c},loadingMore:function(){return"Loading more results…"},maximumSelected:function(a){var b="You can only select "+a.maximum+" item";return 1!=a.maximum&&(b+="s"),b},noResults:function(){return"No results found"},searching:function(){return"Searching…"}}}),b.define("select2/defaults",["jquery","require","./results","./selection/single","./selection/multiple","./selection/placeholder","./selection/allowClear","./selection/search","./selection/eventRelay","./utils","./translation","./diacritics","./data/select","./data/array","./data/ajax","./data/tags","./data/tokenizer","./data/minimumInputLength","./data/maximumInputLength","./data/maximumSelectionLength","./dropdown","./dropdown/search","./dropdown/hidePlaceholder","./dropdown/infiniteScroll","./dropdown/attachBody","./dropdown/minimumResultsForSearch","./dropdown/selectOnClose","./dropdown/closeOnSelect","./i18n/en"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C){function D(){this.reset()}D.prototype.apply=function(l){if(l=a.extend(!0,{},this.defaults,l),null==l.dataAdapter){if(null!=l.ajax?l.dataAdapter=o:null!=l.data?l.dataAdapter=n:l.dataAdapter=m,l.minimumInputLength>0&&(l.dataAdapter=j.Decorate(l.dataAdapter,r)),l.maximumInputLength>0&&(l.dataAdapter=j.Decorate(l.dataAdapter,s)),l.maximumSelectionLength>0&&(l.dataAdapter=j.Decorate(l.dataAdapter,t)),l.tags&&(l.dataAdapter=j.Decorate(l.dataAdapter,p)),(null!=l.tokenSeparators||null!=l.tokenizer)&&(l.dataAdapter=j.Decorate(l.dataAdapter,q)),null!=l.query){var C=b(l.amdBase+"compat/query");l.dataAdapter=j.Decorate(l.dataAdapter,C)}if(null!=l.initSelection){var D=b(l.amdBase+"compat/initSelection");l.dataAdapter=j.Decorate(l.dataAdapter,D)}}if(null==l.resultsAdapter&&(l.resultsAdapter=c,null!=l.ajax&&(l.resultsAdapter=j.Decorate(l.resultsAdapter,x)),null!=l.placeholder&&(l.resultsAdapter=j.Decorate(l.resultsAdapter,w)),l.selectOnClose&&(l.resultsAdapter=j.Decorate(l.resultsAdapter,A))),null==l.dropdownAdapter){if(l.multiple)l.dropdownAdapter=u;else{var E=j.Decorate(u,v);l.dropdownAdapter=E}if(0!==l.minimumResultsForSearch&&(l.dropdownAdapter=j.Decorate(l.dropdownAdapter,z)),l.closeOnSelect&&(l.dropdownAdapter=j.Decorate(l.dropdownAdapter,B)),null!=l.dropdownCssClass||null!=l.dropdownCss||null!=l.adaptDropdownCssClass){var F=b(l.amdBase+"compat/dropdownCss");l.dropdownAdapter=j.Decorate(l.dropdownAdapter,F)}l.dropdownAdapter=j.Decorate(l.dropdownAdapter,y)}if(null==l.selectionAdapter){if(l.multiple?l.selectionAdapter=e:l.selectionAdapter=d,null!=l.placeholder&&(l.selectionAdapter=j.Decorate(l.selectionAdapter,f)),l.allowClear&&(l.selectionAdapter=j.Decorate(l.selectionAdapter,g)),l.multiple&&(l.selectionAdapter=j.Decorate(l.selectionAdapter,h)),null!=l.containerCssClass||null!=l.containerCss||null!=l.adaptContainerCssClass){var G=b(l.amdBase+"compat/containerCss");l.selectionAdapter=j.Decorate(l.selectionAdapter,G)}l.selectionAdapter=j.Decorate(l.selectionAdapter,i)}if("string"==typeof l.language)if(l.language.indexOf("-")>0){var H=l.language.split("-"),I=H[0];l.language=[l.language,I]}else l.language=[l.language];if(a.isArray(l.language)){var J=new k;l.language.push("en");for(var K=l.language,L=0;L<K.length;L++){var M=K[L],N={};try{N=k.loadPath(M)}catch(O){try{M=this.defaults.amdLanguageBase+M,N=k.loadPath(M)}catch(P){l.debug&&window.console&&console.warn&&console.warn('Select2: The language file for "'+M+'" could not be automatically loaded. A fallback will be used instead.');continue}}J.extend(N)}l.translations=J}else{var Q=k.loadPath(this.defaults.amdLanguageBase+"en"),R=new k(l.language);R.extend(Q),l.translations=R}return l},D.prototype.reset=function(){function b(a){function b(a){return l[a]||a}return a.replace(/[^\u0000-\u007E]/g,b)}function c(d,e){if(""===a.trim(d.term))return e;if(e.children&&e.children.length>0){for(var f=a.extend(!0,{},e),g=e.children.length-1;g>=0;g--){var h=e.children[g],i=c(d,h);null==i&&f.children.splice(g,1)}return f.children.length>0?f:c(d,f)}var j=b(e.text).toUpperCase(),k=b(d.term).toUpperCase();return j.indexOf(k)>-1?e:null}this.defaults={amdBase:"./",amdLanguageBase:"./i18n/",closeOnSelect:!0,debug:!1,dropdownAutoWidth:!1,escapeMarkup:j.escapeMarkup,language:C,matcher:c,minimumInputLength:0,maximumInputLength:0,maximumSelectionLength:0,minimumResultsForSearch:0,selectOnClose:!1,sorter:function(a){return a},templateResult:function(a){return a.text},templateSelection:function(a){return a.text},theme:"default",width:"resolve"}},D.prototype.set=function(b,c){var d=a.camelCase(b),e={};e[d]=c;var f=j._convertData(e);a.extend(this.defaults,f)};var E=new D;return E}),b.define("select2/options",["require","jquery","./defaults","./utils"],function(a,b,c,d){function e(b,e){if(this.options=b,null!=e&&this.fromElement(e),this.options=c.apply(this.options),e&&e.is("input")){var f=a(this.get("amdBase")+"compat/inputData");this.options.dataAdapter=d.Decorate(this.options.dataAdapter,f)}}return e.prototype.fromElement=function(a){var c=["select2"];null==this.options.multiple&&(this.options.multiple=a.prop("multiple")),null==this.options.disabled&&(this.options.disabled=a.prop("disabled")),null==this.options.language&&(a.prop("lang")?this.options.language=a.prop("lang").toLowerCase():a.closest("[lang]").prop("lang")&&(this.options.language=a.closest("[lang]").prop("lang"))),null==this.options.dir&&(a.prop("dir")?this.options.dir=a.prop("dir"):a.closest("[dir]").prop("dir")?this.options.dir=a.closest("[dir]").prop("dir"):this.options.dir="ltr"),a.prop("disabled",this.options.disabled),a.prop("multiple",this.options.multiple),a.data("select2Tags")&&(this.options.debug&&window.console&&console.warn&&console.warn('Select2: The `data-select2-tags` attribute has been changed to use the `data-data` and `data-tags="true"` attributes and will be removed in future versions of Select2.'),a.data("data",a.data("select2Tags")),a.data("tags",!0)),a.data("ajaxUrl")&&(this.options.debug&&window.console&&console.warn&&console.warn("Select2: The `data-ajax-url` attribute has been changed to `data-ajax--url` and support for the old attribute will be removed in future versions of Select2."),a.attr("ajax--url",a.data("ajaxUrl")),a.data("ajax--url",a.data("ajaxUrl")));var e={};e=b.fn.jquery&&"1."==b.fn.jquery.substr(0,2)&&a[0].dataset?b.extend(!0,{},a[0].dataset,a.data()):a.data();var f=b.extend(!0,{},e);f=d._convertData(f);for(var g in f)b.inArray(g,c)>-1||(b.isPlainObject(this.options[g])?b.extend(this.options[g],f[g]):this.options[g]=f[g]);return this},e.prototype.get=function(a){return this.options[a]},e.prototype.set=function(a,b){this.options[a]=b},e}),b.define("select2/core",["jquery","./options","./utils","./keys"],function(a,b,c,d){var e=function(a,c){null!=a.data("select2")&&a.data("select2").destroy(),this.$element=a,this.id=this._generateId(a),c=c||{},this.options=new b(c,a),e.__super__.constructor.call(this);var d=a.attr("tabindex")||0;a.data("old-tabindex",d),a.attr("tabindex","-1");var f=this.options.get("dataAdapter");this.dataAdapter=new f(a,this.options);var g=this.render();this._placeContainer(g);var h=this.options.get("selectionAdapter");this.selection=new h(a,this.options),this.$selection=this.selection.render(),this.selection.position(this.$selection,g);var i=this.options.get("dropdownAdapter");this.dropdown=new i(a,this.options),this.$dropdown=this.dropdown.render(),this.dropdown.position(this.$dropdown,g);var j=this.options.get("resultsAdapter");this.results=new j(a,this.options,this.dataAdapter),this.$results=this.results.render(),this.results.position(this.$results,this.$dropdown);var k=this;this._bindAdapters(),this._registerDomEvents(),this._registerDataEvents(),this._registerSelectionEvents(),this._registerDropdownEvents(),this._registerResultsEvents(),this._registerEvents(),this.dataAdapter.current(function(a){k.trigger("selection:update",{data:a})}),a.addClass("select2-hidden-accessible"),a.attr("aria-hidden","true"),this._syncAttributes(),a.data("select2",this)};return c.Extend(e,c.Observable),e.prototype._generateId=function(a){var b="";return b=null!=a.attr("id")?a.attr("id"):null!=a.attr("name")?a.attr("name")+"-"+c.generateChars(2):c.generateChars(4),b=b.replace(/(:|\.|\[|\]|,)/g,""),b="select2-"+b},e.prototype._placeContainer=function(a){a.insertAfter(this.$element);var b=this._resolveWidth(this.$element,this.options.get("width"));null!=b&&a.css("width",b)},e.prototype._resolveWidth=function(a,b){var c=/^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i;if("resolve"==b){var d=this._resolveWidth(a,"style");return null!=d?d:this._resolveWidth(a,"element")}if("element"==b){var e=a.outerWidth(!1);return 0>=e?"auto":e+"px"}if("style"==b){var f=a.attr("style");if("string"!=typeof f)return null;for(var g=f.split(";"),h=0,i=g.length;i>h;h+=1){var j=g[h].replace(/\s/g,""),k=j.match(c);if(null!==k&&k.length>=1)return k[1]}return null}return b},e.prototype._bindAdapters=function(){this.dataAdapter.bind(this,this.$container),this.selection.bind(this,this.$container),this.dropdown.bind(this,this.$container),this.results.bind(this,this.$container)},e.prototype._registerDomEvents=function(){var b=this;this.$element.on("change.select2",function(){b.dataAdapter.current(function(a){b.trigger("selection:update",{data:a})})}),this.$element.on("focus.select2",function(a){b.trigger("focus",a)}),this._syncA=c.bind(this._syncAttributes,this),this._syncS=c.bind(this._syncSubtree,this),this.$element[0].attachEvent&&this.$element[0].attachEvent("onpropertychange",this._syncA);var d=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver;null!=d?(this._observer=new d(function(c){a.each(c,b._syncA),a.each(c,b._syncS)}),this._observer.observe(this.$element[0],{attributes:!0,childList:!0,subtree:!1})):this.$element[0].addEventListener&&(this.$element[0].addEventListener("DOMAttrModified",b._syncA,!1),this.$element[0].addEventListener("DOMNodeInserted",b._syncS,!1),this.$element[0].addEventListener("DOMNodeRemoved",b._syncS,!1))},e.prototype._registerDataEvents=function(){var a=this;this.dataAdapter.on("*",function(b,c){a.trigger(b,c)})},e.prototype._registerSelectionEvents=function(){var b=this,c=["toggle","focus"];this.selection.on("toggle",function(){b.toggleDropdown()}),this.selection.on("focus",function(a){b.focus(a)}),this.selection.on("*",function(d,e){-1===a.inArray(d,c)&&b.trigger(d,e)})},e.prototype._registerDropdownEvents=function(){var a=this;this.dropdown.on("*",function(b,c){a.trigger(b,c)})},e.prototype._registerResultsEvents=function(){var a=this;this.results.on("*",function(b,c){a.trigger(b,c)})},e.prototype._registerEvents=function(){var a=this;this.on("open",function(){a.$container.addClass("select2-container--open")}),this.on("close",function(){a.$container.removeClass("select2-container--open")}),this.on("enable",function(){a.$container.removeClass("select2-container--disabled")}),this.on("disable",function(){a.$container.addClass("select2-container--disabled")}),this.on("blur",function(){a.$container.removeClass("select2-container--focus")}),this.on("query",function(b){a.isOpen()||a.trigger("open",{}),this.dataAdapter.query(b,function(c){a.trigger("results:all",{data:c,query:b})})}),this.on("query:append",function(b){this.dataAdapter.query(b,function(c){a.trigger("results:append",{data:c,query:b})})}),this.on("keypress",function(b){var c=b.which;a.isOpen()?c===d.ESC||c===d.TAB||c===d.UP&&b.altKey?(a.close(),b.preventDefault()):c===d.ENTER?(a.trigger("results:select",{}),b.preventDefault()):c===d.SPACE&&b.ctrlKey?(a.trigger("results:toggle",{}),b.preventDefault()):c===d.UP?(a.trigger("results:previous",{}),b.preventDefault()):c===d.DOWN&&(a.trigger("results:next",{}),b.preventDefault()):(c===d.ENTER||c===d.SPACE||c===d.DOWN&&b.altKey)&&(a.open(),b.preventDefault())})},e.prototype._syncAttributes=function(){this.options.set("disabled",this.$element.prop("disabled")),this.options.get("disabled")?(this.isOpen()&&this.close(),this.trigger("disable",{})):this.trigger("enable",{})},e.prototype._syncSubtree=function(a,b){var c=!1,d=this;if(!a||!a.target||"OPTION"===a.target.nodeName||"OPTGROUP"===a.target.nodeName){if(b)if(b.addedNodes&&b.addedNodes.length>0)for(var e=0;e<b.addedNodes.length;e++){var f=b.addedNodes[e];f.selected&&(c=!0)}else b.removedNodes&&b.removedNodes.length>0&&(c=!0);else c=!0;c&&this.dataAdapter.current(function(a){d.trigger("selection:update",{data:a})})}},e.prototype.trigger=function(a,b){var c=e.__super__.trigger,d={open:"opening",close:"closing",select:"selecting",unselect:"unselecting"};if(void 0===b&&(b={}),a in d){var f=d[a],g={prevented:!1,name:a,args:b};if(c.call(this,f,g),g.prevented)return void(b.prevented=!0)}c.call(this,a,b)},e.prototype.toggleDropdown=function(){this.options.get("disabled")||(this.isOpen()?this.close():this.open())},e.prototype.open=function(){this.isOpen()||this.trigger("query",{})},e.prototype.close=function(){this.isOpen()&&this.trigger("close",{})},e.prototype.isOpen=function(){return this.$container.hasClass("select2-container--open")},e.prototype.hasFocus=function(){return this.$container.hasClass("select2-container--focus")},e.prototype.focus=function(a){this.hasFocus()||(this.$container.addClass("select2-container--focus"),this.trigger("focus",{}))},e.prototype.enable=function(a){this.options.get("debug")&&window.console&&console.warn&&console.warn('Select2: The `select2("enable")` method has been deprecated and will be removed in later Select2 versions. Use $element.prop("disabled") instead.'),(null==a||0===a.length)&&(a=[!0]);var b=!a[0];this.$element.prop("disabled",b)},e.prototype.data=function(){this.options.get("debug")&&arguments.length>0&&window.console&&console.warn&&console.warn('Select2: Data can no longer be set using `select2("data")`. You should consider setting the value instead using `$element.val()`.');var a=[];return this.dataAdapter.current(function(b){a=b}),a},e.prototype.val=function(b){if(this.options.get("debug")&&window.console&&console.warn&&console.warn('Select2: The `select2("val")` method has been deprecated and will be removed in later Select2 versions. Use $element.val() instead.'),null==b||0===b.length)return this.$element.val();var c=b[0];a.isArray(c)&&(c=a.map(c,function(a){return a.toString()})),this.$element.val(c).trigger("change")},e.prototype.destroy=function(){this.$container.remove(),this.$element[0].detachEvent&&this.$element[0].detachEvent("onpropertychange",this._syncA),null!=this._observer?(this._observer.disconnect(),this._observer=null):this.$element[0].removeEventListener&&(this.$element[0].removeEventListener("DOMAttrModified",this._syncA,!1),this.$element[0].removeEventListener("DOMNodeInserted",this._syncS,!1),this.$element[0].removeEventListener("DOMNodeRemoved",this._syncS,!1)),this._syncA=null,this._syncS=null,this.$element.off(".select2"),this.$element.attr("tabindex",this.$element.data("old-tabindex")),this.$element.removeClass("select2-hidden-accessible"),this.$element.attr("aria-hidden","false"),this.$element.removeData("select2"),this.dataAdapter.destroy(),this.selection.destroy(),this.dropdown.destroy(),this.results.destroy(),this.dataAdapter=null,this.selection=null,this.dropdown=null,this.results=null;
3
+ },e.prototype.render=function(){var b=a('<span class="select2 select2-container"><span class="selection"></span><span class="dropdown-wrapper" aria-hidden="true"></span></span>');return b.attr("dir",this.options.get("dir")),this.$container=b,this.$container.addClass("select2-container--"+this.options.get("theme")),b.data("element",this.$element),b},e}),b.define("jquery-mousewheel",["jquery"],function(a){return a}),b.define("jquery.select2",["jquery","jquery-mousewheel","./select2/core","./select2/defaults"],function(a,b,c,d){if(null==a.fn.select2){var e=["open","close","destroy"];a.fn.select2=function(b){if(b=b||{},"object"==typeof b)return this.each(function(){var d=a.extend(!0,{},b);new c(a(this),d)}),this;if("string"==typeof b){var d,f=Array.prototype.slice.call(arguments,1);return this.each(function(){var c=a(this).data("select2");null==c&&window.console&&console.error&&console.error("The select2('"+b+"') method was called on an element that is not using Select2."),d=c[b].apply(c,f)}),a.inArray(b,e)>-1?this:d}throw new Error("Invalid arguments for Select2: "+b)}}return null==a.fn.select2.defaults&&(a.fn.select2.defaults=d),c}),{define:b.define,require:b.require}}(),c=b.require("jquery.select2");return a.fn.select2.amd=b,c});
vendor/iworks/options/assets/styles/common.css ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * select2
3
+ */
4
+ .iworks-options .select2 {
5
+ min-width: 300px;
6
+ }
7
+ .iworks-options .select2 .select2-selection {
8
+ border-color: #aaa;
9
+ }
10
+ /**
11
+ * ui-slider
12
+ */
13
+ .iworks-options div.ui-slider span.ui-slider-handle {
14
+ background-color: #08b;
15
+ cursor: col-resize;
16
+ }
17
+ .iworks-options div.ui-slider {
18
+ margin-top: 10px;
19
+ max-width: 200px;
20
+ }
21
+ .iworks-options .iworks-options-type-wpcolorpicker span.description {
22
+ display: block;
23
+ }
24
+ /**
25
+ * switch-button
26
+ */
27
+ .switch-button-background.checked {
28
+ background-color: #085;
29
+ }
30
+ /**
31
+ * tabs
32
+ */
33
+ #hasadmintabs ul.ui-tabs-nav
34
+ {
35
+ border-bottom:1px solid #dfdfdf;
36
+ font-size:12px;
37
+ height:29px;
38
+ list-style-image:none;
39
+ list-style-position:outside;
40
+ list-style-type:none;
41
+ margin:13px 0 0;
42
+ overflow:visible;
43
+ padding:0 0 0 8px;
44
+ }
45
+
46
+ #hasadmintabs ul.ui-tabs-nav li
47
+ {
48
+ display:block;
49
+ float:left;
50
+ line-height:200%;
51
+ list-style-image:none;
52
+ list-style-position:outside;
53
+ list-style-type:none;
54
+ margin:0;
55
+ padding:0;
56
+ position:relative;
57
+ text-align:center;
58
+ white-space:nowrap;
59
+ width:auto;
60
+ }
61
+
62
+ #hasadmintabs ul.ui-tabs-nav li a {
63
+ background:transparent none no-repeat scroll 0 50%;
64
+ border-bottom:1px solid #dfdfdf;
65
+ display:block;
66
+ float:left;
67
+ line-height:28px;
68
+ padding:1px 13px 0;
69
+ position:relative;
70
+ text-decoration:none;
71
+ }
72
+
73
+ #hasadmintabs ul.ui-tabs-nav li.ui-tabs-selected a
74
+ ,#hasadmintabs ul.ui-tabs-nav li.ui-tabs-active a {
75
+ -moz-border-radius-topleft:4px;
76
+ -moz-border-radius-topright:4px;
77
+ border:1px solid #dfdfdf;
78
+ border-bottom-color:#f9f9f9;
79
+ color:#333333;
80
+ font-weight:normal;
81
+ padding:0 12px;
82
+ }
83
+
84
+ #hasadmintabs ul.ui-tabs-nav a:focus, a:active {
85
+ outline-color:-moz-use-text-color;
86
+ outline-style:none;
87
+ outline-width:medium;
88
+ }
89
+
90
+ @media screen and (max-width: 782px) {
91
+ .has-right-sidebar .iworks-options #post-body-content {
92
+ margin: 0;
93
+ }
94
+ }
95
+ /**
96
+ * ui-slider
97
+ */
98
+ .iworks-options .ui-slider {
99
+ background-color: #aaa;
100
+ }
101
+ .ui-slider {
102
+ position: relative;
103
+ text-align: left;
104
+ }
105
+ .ui-slider .ui-slider-handle {
106
+ position: absolute;
107
+ z-index: 2;
108
+ width: 1.2em;
109
+ height: 1.2em;
110
+ cursor: default;
111
+ -ms-touch-action: none;
112
+ touch-action: none;
113
+ }
114
+ .ui-slider .ui-slider-range {
115
+ position: absolute;
116
+ z-index: 1;
117
+ font-size: .7em;
118
+ display: block;
119
+ border: 0;
120
+ background-position: 0 0;
121
+ }
122
+
123
+ /* support: IE8 - See #6727 */
124
+ .ui-slider.ui-state-disabled .ui-slider-handle,
125
+ .ui-slider.ui-state-disabled .ui-slider-range {
126
+ filter: inherit;
127
+ }
128
+
129
+ .ui-slider-horizontal {
130
+ height: .6em;
131
+ }
132
+ .ui-slider-horizontal .ui-slider-handle {
133
+ top: -.3em;
134
+ margin-left: -.6em;
135
+ }
136
+ .ui-slider-horizontal .ui-slider-range {
137
+ top: 0;
138
+ height: 100%;
139
+ }
140
+ .ui-slider-horizontal .ui-slider-range-min {
141
+ left: 0;
142
+ }
143
+ .ui-slider-horizontal .ui-slider-range-max {
144
+ right: 0;
145
+ }
146
+
147
+ .ui-slider-vertical {
148
+ width: .8em;
149
+ height: 100px;
150
+ }
vendor/iworks/options/assets/styles/jquery.switch_button.css ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .switch-button-label {
2
+ float: left;
3
+
4
+ font-size: 10pt;
5
+ cursor: pointer;
6
+ }
7
+
8
+ .switch-button-label.off {
9
+ color: #adadad;
10
+ }
11
+
12
+ .switch-button-label.on {
13
+ color: #0088CC;
14
+ }
15
+
16
+ .switch-button-background {
17
+ float: left;
18
+ position: relative;
19
+
20
+ background: #ccc;
21
+ border: 1px solid #aaa;
22
+
23
+ margin: 1px 10px;
24
+
25
+ -webkit-border-radius: 4px;
26
+ -moz-border-radius: 4px;
27
+ border-radius: 4px;
28
+
29
+ cursor: pointer;
30
+ }
31
+
32
+ .switch-button-button {
33
+ position: absolute;
34
+
35
+ left: -1px;
36
+ top : -1px;
37
+
38
+ background: #FAFAFA;
39
+ border: 1px solid #aaa;
40
+
41
+ -webkit-border-radius: 4px;
42
+ -moz-border-radius: 4px;
43
+ border-radius: 4px;
44
+ }
vendor/iworks/options/assets/styles/select2.min.css ADDED
@@ -0,0 +1 @@
 
1
+ .select2-container{box-sizing:border-box;display:inline-block;margin:0;position:relative;vertical-align:middle}.select2-container .select2-selection--single{box-sizing:border-box;cursor:pointer;display:block;height:28px;user-select:none;-webkit-user-select:none}.select2-container .select2-selection--single .select2-selection__rendered{display:block;padding-left:8px;padding-right:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.select2-container .select2-selection--single .select2-selection__clear{position:relative}.select2-container[dir="rtl"] .select2-selection--single .select2-selection__rendered{padding-right:8px;padding-left:20px}.select2-container .select2-selection--multiple{box-sizing:border-box;cursor:pointer;display:block;min-height:32px;user-select:none;-webkit-user-select:none}.select2-container .select2-selection--multiple .select2-selection__rendered{display:inline-block;overflow:hidden;padding-left:8px;text-overflow:ellipsis;white-space:nowrap}.select2-container .select2-search--inline{float:left}.select2-container .select2-search--inline .select2-search__field{box-sizing:border-box;border:none;font-size:100%;margin-top:5px;padding:0}.select2-container .select2-search--inline .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-dropdown{background-color:white;border:1px solid #aaa;border-radius:4px;box-sizing:border-box;display:block;position:absolute;left:-100000px;width:100%;z-index:1051}.select2-results{display:block}.select2-results__options{list-style:none;margin:0;padding:0}.select2-results__option{padding:6px;user-select:none;-webkit-user-select:none}.select2-results__option[aria-selected]{cursor:pointer}.select2-container--open .select2-dropdown{left:0}.select2-container--open .select2-dropdown--above{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--open .select2-dropdown--below{border-top:none;border-top-left-radius:0;border-top-right-radius:0}.select2-search--dropdown{display:block;padding:4px}.select2-search--dropdown .select2-search__field{padding:4px;width:100%;box-sizing:border-box}.select2-search--dropdown .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-search--dropdown.select2-search--hide{display:none}.select2-close-mask{border:0;margin:0;padding:0;display:block;position:fixed;left:0;top:0;min-height:100%;min-width:100%;height:auto;width:auto;opacity:0;z-index:99;background-color:#fff;filter:alpha(opacity=0)}.select2-hidden-accessible{border:0 !important;clip:rect(0 0 0 0) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important}.select2-container--default .select2-selection--single{background-color:#fff;border:1px solid #aaa;border-radius:4px}.select2-container--default .select2-selection--single .select2-selection__rendered{color:#444;line-height:28px}.select2-container--default .select2-selection--single .select2-selection__clear{cursor:pointer;float:right;font-weight:bold}.select2-container--default .select2-selection--single .select2-selection__placeholder{color:#999}.select2-container--default .select2-selection--single .select2-selection__arrow{height:26px;position:absolute;top:1px;right:1px;width:20px}.select2-container--default .select2-selection--single .select2-selection__arrow b{border-color:#888 transparent transparent transparent;border-style:solid;border-width:5px 4px 0 4px;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__clear{float:left}.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__arrow{left:1px;right:auto}.select2-container--default.select2-container--disabled .select2-selection--single{background-color:#eee;cursor:default}.select2-container--default.select2-container--disabled .select2-selection--single .select2-selection__clear{display:none}.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #888 transparent;border-width:0 4px 5px 4px}.select2-container--default .select2-selection--multiple{background-color:white;border:1px solid #aaa;border-radius:4px;cursor:text}.select2-container--default .select2-selection--multiple .select2-selection__rendered{box-sizing:border-box;list-style:none;margin:0;padding:0 5px;width:100%}.select2-container--default .select2-selection--multiple .select2-selection__rendered li{list-style:none}.select2-container--default .select2-selection--multiple .select2-selection__placeholder{color:#999;margin-top:5px;float:left}.select2-container--default .select2-selection--multiple .select2-selection__clear{cursor:pointer;float:right;font-weight:bold;margin-top:5px;margin-right:10px}.select2-container--default .select2-selection--multiple .select2-selection__choice{background-color:#e4e4e4;border:1px solid #aaa;border-radius:4px;cursor:default;float:left;margin-right:5px;margin-top:5px;padding:0 5px}.select2-container--default .select2-selection--multiple .select2-selection__choice__remove{color:#999;cursor:pointer;display:inline-block;font-weight:bold;margin-right:2px}.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover{color:#333}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice,.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__placeholder,.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-search--inline{float:right}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice{margin-left:5px;margin-right:auto}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto}.select2-container--default.select2-container--focus .select2-selection--multiple{border:solid black 1px;outline:0}.select2-container--default.select2-container--disabled .select2-selection--multiple{background-color:#eee;cursor:default}.select2-container--default.select2-container--disabled .select2-selection__choice__remove{display:none}.select2-container--default.select2-container--open.select2-container--above .select2-selection--single,.select2-container--default.select2-container--open.select2-container--above .select2-selection--multiple{border-top-left-radius:0;border-top-right-radius:0}.select2-container--default.select2-container--open.select2-container--below .select2-selection--single,.select2-container--default.select2-container--open.select2-container--below .select2-selection--multiple{border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--default .select2-search--dropdown .select2-search__field{border:1px solid #aaa}.select2-container--default .select2-search--inline .select2-search__field{background:transparent;border:none;outline:0;box-shadow:none;-webkit-appearance:textfield}.select2-container--default .select2-results>.select2-results__options{max-height:200px;overflow-y:auto}.select2-container--default .select2-results__option[role=group]{padding:0}.select2-container--default .select2-results__option[aria-disabled=true]{color:#999}.select2-container--default .select2-results__option[aria-selected=true]{background-color:#ddd}.select2-container--default .select2-results__option .select2-results__option{padding-left:1em}.select2-container--default .select2-results__option .select2-results__option .select2-results__group{padding-left:0}.select2-container--default .select2-results__option .select2-results__option .select2-results__option{margin-left:-1em;padding-left:2em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-2em;padding-left:3em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-3em;padding-left:4em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-4em;padding-left:5em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-5em;padding-left:6em}.select2-container--default .select2-results__option--highlighted[aria-selected]{background-color:#5897fb;color:white}.select2-container--default .select2-results__group{cursor:default;display:block;padding:6px}.select2-container--classic .select2-selection--single{background-color:#f7f7f7;border:1px solid #aaa;border-radius:4px;outline:0;background-image:-webkit-linear-gradient(top, #fff 50%, #eee 100%);background-image:-o-linear-gradient(top, #fff 50%, #eee 100%);background-image:linear-gradient(to bottom, #fff 50%, #eee 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0)}.select2-container--classic .select2-selection--single:focus{border:1px solid #5897fb}.select2-container--classic .select2-selection--single .select2-selection__rendered{color:#444;line-height:28px}.select2-container--classic .select2-selection--single .select2-selection__clear{cursor:pointer;float:right;font-weight:bold;margin-right:10px}.select2-container--classic .select2-selection--single .select2-selection__placeholder{color:#999}.select2-container--classic .select2-selection--single .select2-selection__arrow{background-color:#ddd;border:none;border-left:1px solid #aaa;border-top-right-radius:4px;border-bottom-right-radius:4px;height:26px;position:absolute;top:1px;right:1px;width:20px;background-image:-webkit-linear-gradient(top, #eee 50%, #ccc 100%);background-image:-o-linear-gradient(top, #eee 50%, #ccc 100%);background-image:linear-gradient(to bottom, #eee 50%, #ccc 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFCCCCCC', GradientType=0)}.select2-container--classic .select2-selection--single .select2-selection__arrow b{border-color:#888 transparent transparent transparent;border-style:solid;border-width:5px 4px 0 4px;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__clear{float:left}.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__arrow{border:none;border-right:1px solid #aaa;border-radius:0;border-top-left-radius:4px;border-bottom-left-radius:4px;left:1px;right:auto}.select2-container--classic.select2-container--open .select2-selection--single{border:1px solid #5897fb}.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow{background:transparent;border:none}.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #888 transparent;border-width:0 4px 5px 4px}.select2-container--classic.select2-container--open.select2-container--above .select2-selection--single{border-top:none;border-top-left-radius:0;border-top-right-radius:0;background-image:-webkit-linear-gradient(top, #fff 0%, #eee 50%);background-image:-o-linear-gradient(top, #fff 0%, #eee 50%);background-image:linear-gradient(to bottom, #fff 0%, #eee 50%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0)}.select2-container--classic.select2-container--open.select2-container--below .select2-selection--single{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0;background-image:-webkit-linear-gradient(top, #eee 50%, #fff 100%);background-image:-o-linear-gradient(top, #eee 50%, #fff 100%);background-image:linear-gradient(to bottom, #eee 50%, #fff 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFFFFFFF', GradientType=0)}.select2-container--classic .select2-selection--multiple{background-color:white;border:1px solid #aaa;border-radius:4px;cursor:text;outline:0}.select2-container--classic .select2-selection--multiple:focus{border:1px solid #5897fb}.select2-container--classic .select2-selection--multiple .select2-selection__rendered{list-style:none;margin:0;padding:0 5px}.select2-container--classic .select2-selection--multiple .select2-selection__clear{display:none}.select2-container--classic .select2-selection--multiple .select2-selection__choice{background-color:#e4e4e4;border:1px solid #aaa;border-radius:4px;cursor:default;float:left;margin-right:5px;margin-top:5px;padding:0 5px}.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove{color:#888;cursor:pointer;display:inline-block;font-weight:bold;margin-right:2px}.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove:hover{color:#555}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice{float:right}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice{margin-left:5px;margin-right:auto}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto}.select2-container--classic.select2-container--open .select2-selection--multiple{border:1px solid #5897fb}.select2-container--classic.select2-container--open.select2-container--above .select2-selection--multiple{border-top:none;border-top-left-radius:0;border-top-right-radius:0}.select2-container--classic.select2-container--open.select2-container--below .select2-selection--multiple{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--classic .select2-search--dropdown .select2-search__field{border:1px solid #aaa;outline:0}.select2-container--classic .select2-search--inline .select2-search__field{outline:0;box-shadow:none}.select2-container--classic .select2-dropdown{background-color:#fff;border:1px solid transparent}.select2-container--classic .select2-dropdown--above{border-bottom:none}.select2-container--classic .select2-dropdown--below{border-top:none}.select2-container--classic .select2-results>.select2-results__options{max-height:200px;overflow-y:auto}.select2-container--classic .select2-results__option[role=group]{padding:0}.select2-container--classic .select2-results__option[aria-disabled=true]{color:grey}.select2-container--classic .select2-results__option--highlighted[aria-selected]{background-color:#3875d7;color:#fff}.select2-container--classic .select2-results__group{cursor:default;display:block;padding:6px}.select2-container--classic.select2-container--open .select2-dropdown{border-color:#5897fb}
vendor/iworks/options/options.php ADDED
@@ -0,0 +1,1562 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Class Name: iWorks Options
4
+ Class URI: http://iworks.pl/
5
+ Description: Option class to manage options.
6
+ Version: 2.6.2
7
+ Author: Marcin Pietrzak
8
+ Author URI: http://iworks.pl/
9
+ License: GPLv2 or later
10
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
+
12
+ Copyright 2011-2017 Marcin Pietrzak (marcin@iworks.pl)
13
+
14
+ this program is free software; you can redistribute it and/or modify
15
+ it under the terms of the GNU General Public License, version 2, as
16
+ published by the Free Software Foundation.
17
+
18
+ This program is distributed in the hope that it will be useful,
19
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ GNU General Public License for more details.
22
+
23
+ You should have received a copy of the GNU General Public License
24
+ along with this program; if not, write to the Free Software
25
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26
+
27
+ */
28
+
29
+ if ( ! defined( 'WPINC' ) ) {
30
+ die;
31
+ }
32
+
33
+ if ( class_exists( 'iworks_options' ) ) {
34
+ return;
35
+ }
36
+
37
+ class iworks_options {
38
+ private $option_function_name;
39
+ private $option_group;
40
+ private $option_prefix;
41
+ private $version;
42
+ private $pagehooks = array();
43
+ private $scripts_enqueued = array();
44
+ public $notices;
45
+
46
+ public function __construct() {
47
+ /**
48
+ * basic setup
49
+ */
50
+ $this->notices = array();
51
+ $this->version = '2.6.2';
52
+ $this->option_group = 'index';
53
+ $this->option_function_name = null;
54
+ $this->option_prefix = null;
55
+ /**
56
+ * afer basic setup
57
+ */
58
+ $this->files = $this->get_files();
59
+ /**
60
+ * hooks
61
+ */
62
+ add_action( 'admin_enqueue_scripts', array( $this, 'register_styles' ), 0 );
63
+ add_action( 'admin_head', array( $this, 'admin_head' ) );
64
+ add_action( 'admin_menu', array( $this, 'admin_menu' ) );
65
+ add_action( 'admin_notices', array( &$this, 'admin_notices' ) );
66
+ add_filter( 'screen_layout_columns', array( $this, 'screen_layout_columns' ), 10, 2 );
67
+ }
68
+
69
+ public function init() {
70
+ $this->get_option_array();
71
+ }
72
+
73
+ public function admin_menu() {
74
+ $data = $this->get_option_array();
75
+ if ( ! isset( $this->options ) ) {
76
+ return;
77
+ }
78
+ $pages = array();
79
+ $pages['index'] = $data;
80
+ if ( isset( $data['pages'] ) ) {
81
+ $pages += $data['pages'];
82
+ }
83
+ foreach ( $pages as $key => $data ) {
84
+ $keys_to_sanitize = array( 'menu', 'parent' );
85
+ foreach ( $keys_to_sanitize as $key_to_sanitize ) {
86
+ if ( ! array_key_exists( $key_to_sanitize, $data ) ) {
87
+ $data[ $key_to_sanitize ] = '';
88
+ }
89
+ }
90
+ if ( 'submenu' == $data['menu'] ) {
91
+ if ( ! empty( $data['parent'] ) ) {
92
+ /**
93
+ * Check callback
94
+ */
95
+ $callback = array( $this, 'show_page' );
96
+ if ( isset( $data['show_page_callback'] ) && is_callable( $data['show_page_callback'] ) ) {
97
+ $callback = $data['show_page_callback'];
98
+ }
99
+ /**
100
+ * add submenu
101
+ */
102
+ $this->pagehooks[ $key ] = add_submenu_page(
103
+ $data['parent'],
104
+ $data['page_title'],
105
+ isset( $data['menu_title'] )? $data['menu_title']:$data['page_title'],
106
+ apply_filters( 'iworks_options_capagility', 'manage_options', 'settings' ),
107
+ $this->get_option_name( $key ),
108
+ $callback
109
+ );
110
+ add_action( 'load-'.$this->pagehooks[ $key ], array( $this, 'load_page' ) );
111
+ }
112
+ } else {
113
+ switch ( $data['menu'] ) {
114
+ case 'comments':
115
+ case 'dashboard':
116
+ case 'links':
117
+ case 'management':
118
+ case 'media':
119
+ case 'options':
120
+ case 'pages':
121
+ case 'plugins':
122
+ case 'posts':
123
+ case 'posts':
124
+ case 'theme':
125
+ case 'users':
126
+ $function = sprintf( 'add_%s_page', $data['menu'] );
127
+ break;
128
+ default:
129
+ $function = 'add_menu_page';
130
+ break;
131
+ }
132
+ if ( isset( $data['page_title'] ) ) {
133
+ $this->pagehooks[ $key ] = $function(
134
+ $data['page_title'],
135
+ isset( $data['menu_title'] )? $data['menu_title']:$data['page_title'],
136
+ 'manage_options',
137
+ $this->get_option_name( $key ),
138
+ array( $this, 'show_page' )
139
+ );
140
+ add_action( 'load-'.$this->pagehooks[ $key ], array( $this, 'load_page' ) );
141
+ }
142
+ }
143
+ }
144
+ }
145
+
146
+ public function get_version() {
147
+ return $this->version;
148
+ }
149
+
150
+ public function set_option_function_name( $option_function_name ) {
151
+ $this->option_function_name = $option_function_name;
152
+ }
153
+
154
+ public function set_option_prefix( $option_prefix ) {
155
+ $this->option_prefix = $option_prefix;
156
+ }
157
+
158
+ private function get_option_array() {
159
+ $options = array();
160
+ if ( array_key_exists( $this->option_group, $options ) && ! empty( $options[ $this->option_group ] ) ) {
161
+ $options = apply_filters( $this->option_function_name, $this->options );
162
+ return $options[ $this->option_group ];
163
+ }
164
+ if ( is_callable( $this->option_function_name ) ) {
165
+ $options = apply_filters( $this->option_function_name, call_user_func( $this->option_function_name ) );
166
+ }
167
+ if ( array_key_exists( $this->option_group, $options ) && ! empty( $options[ $this->option_group ] ) ) {
168
+ $this->options[ $this->option_group ] = $options[ $this->option_group ];
169
+ return apply_filters( $this->option_function_name, $this->options[ $this->option_group ] );
170
+ }
171
+ return apply_filters( $this->option_function_name, array() );
172
+ }
173
+
174
+ public function build_options( $option_group = 'index', $echo = true, $term_id = false ) {
175
+ $this->option_group = $option_group;
176
+ $options = $this->get_option_array();
177
+ /**
178
+ * add some defaults
179
+ */
180
+ $options['show_submit_button'] = true;
181
+ $options['add_table'] = true;
182
+ if ( ! array_key_exists( 'type', $options ) ) {
183
+ $options['type'] = 'option';
184
+ }
185
+ /**
186
+ * add defaults for taxonomies
187
+ */
188
+ if ( 'taxonomy' == $options['type'] ) {
189
+ $options['show_submit_button'] = false;
190
+ $options['add_table'] = false;
191
+ }
192
+ /**
193
+ * check options exists?
194
+ */
195
+ if ( ! is_array( $options['options'] ) ) {
196
+ echo '<div class="below-h2 error"><p><strong>'.__( 'An error occurred while getting the configuration.', 'sierotki' ).'</strong></p></div>';
197
+ return;
198
+ }
199
+
200
+ /**
201
+ * proceder
202
+ */
203
+ $is_simple = 'simple' == $this->get_option( 'configuration', 'index', 'advance' );
204
+ $content = '';
205
+ $hidden = '';
206
+ $top = '';
207
+ $use_tabs = isset( $options['use_tabs'] ) && $options['use_tabs'];
208
+ /**
209
+ * add last_used_tab field
210
+ */
211
+ if ( $use_tabs ) {
212
+ $field = array(
213
+ 'type' => 'hidden',
214
+ 'name' => 'last_used_tab',
215
+ 'id' => 'last_used_tab',
216
+ 'value' => $this->get_option( 'last_used_tab' ),
217
+ );
218
+ array_unshift( $options['options'], $field );
219
+ }
220
+ /**
221
+ * produce options
222
+ */
223
+ if ( $use_tabs ) {
224
+ $top .= sprintf(
225
+ '<div id="hasadmintabs" class="ui-tabs ui-widget ui-widget-content ui-corner-all" data-prefix="%s">',
226
+ $this->option_prefix
227
+ );
228
+ }
229
+ $i = 0;
230
+ $label_index = 0;
231
+ $last_tab = null;
232
+ $related_to = array();
233
+ $configuration = 'all';
234
+ foreach ( $options['options'] as $option ) {
235
+ if ( isset( $option['capability'] ) ) {
236
+ if ( ! current_user_can( $option['capability'] ) ) {
237
+ continue;
238
+ }
239
+ }
240
+ /**
241
+ * add default type
242
+ */
243
+ if ( ! array_key_exists( 'type', $option ) ) {
244
+ $option['type'] = 'text';
245
+ }
246
+ /**
247
+ * check show option
248
+ */
249
+ $show_option = true;
250
+ if ( isset( $option['check_supports'] ) && is_array( $option['check_supports'] ) && count( $option['check_supports'] ) ) {
251
+ foreach ( $option['check_supports'] as $support_to_check ) {
252
+ if ( ! current_theme_supports( $support_to_check ) ) {
253
+ $show_option = false;
254
+ }
255
+ }
256
+ }
257
+ if ( ! $show_option ) {
258
+ continue;
259
+ }
260
+ /**
261
+ * dismiss on special type
262
+ */
263
+ if ( 'special' == $option['type'] ) {
264
+ continue;
265
+ }
266
+ /**
267
+ * get option name
268
+ */
269
+ $option_name = false;
270
+ if ( array_key_exists( 'name', $option ) && $option['name'] ) {
271
+ $option_name = $option['name'];
272
+ if ( 'taxonomy' == $options['type'] ) {
273
+ $option_name = sprintf(
274
+ '%s_%s_%s',
275
+ $option_group,
276
+ $term_id,
277
+ $option_name
278
+ );
279
+ }
280
+ }
281
+ /**
282
+ * dismiss if have "callback_to_show" and return false
283
+ */
284
+ if ( ! preg_match( '/^(heading|info)$/', $option['type'] ) && isset( $option['callback_to_show'] ) && is_callable( $option['callback_to_show'] ) ) {
285
+ if ( false === $option['callback_to_show']( $this->get_option( $option_name, $option_group ) ) ) {
286
+ continue;
287
+ }
288
+ }
289
+ /**
290
+ * heading
291
+ */
292
+ if ( preg_match( '/^(heading|page)$/', $option['type'] ) ) {
293
+ if ( isset( $option['configuration'] ) ) {
294
+ $configuration = $option['configuration'];
295
+ } else {
296
+ $configuration = 'all';
297
+ }
298
+ }
299
+ if ( ( $is_simple && $configuration == 'advance' ) || ( ! $is_simple && $configuration == 'simple' ) ) {
300
+ if ( isset( $option['configuration'] ) && 'both' == $option['configuration'] ) {
301
+ continue;
302
+ }
303
+ if ( in_array( $option['type'], array(
304
+ 'checkbox',
305
+ 'email',
306
+ 'image',
307
+ 'number',
308
+ 'radio',
309
+ 'text',
310
+ 'textarea',
311
+ 'url',
312
+ ) ) ) {
313
+ $html_element_name = $option_name? $this->option_prefix.$option_name:'';
314
+ $content .= sprintf(
315
+ '<input type="hidden" name="%s" value="%s" /> %s',
316
+ $html_element_name,
317
+ $this->get_option( $option_name, $option_group ),
318
+ "\n"
319
+ );
320
+ }
321
+ continue;
322
+ }
323
+ $tr_classes = array(
324
+ 'iworks-options-row',
325
+ sprintf( 'iworks-options-type-%s', esc_attr( strtolower( $option['type'] ) ) ),
326
+ );
327
+ if ( $option['type'] == 'heading' ) {
328
+ if ( $use_tabs ) {
329
+ if ( $last_tab != $option['label'] ) {
330
+ $last_tab = $option['label'];
331
+ if ( $options['add_table'] ) {
332
+ $content .= '</tbody></table>';
333
+ }
334
+ $content .= '</fieldset>';
335
+ }
336
+ $content .= sprintf(
337
+ '<fieldset id="iworks_%s" class="ui-tabs-panel ui-widget-content ui-corner-bottom"%s>',
338
+ crc32( $option['label'] ),
339
+ ( isset( $option['class'] ) && $option['class'] )? ' rel="'.$option['class'].'"':''
340
+ );
341
+ if ( ! $use_tabs ) {
342
+ $content .= sprintf( '<h3>%s</h3>', $option['label'] );
343
+ }
344
+ if ( $options['add_table'] ) {
345
+ $content .= sprintf(
346
+ '<table class="form-table%s" style="%s">',
347
+ isset( $options['widefat'] )? ' widefat':'',
348
+ isset( $options['style'] )? $options['style']:''
349
+ );
350
+ $content .= '<tbody>';
351
+ }
352
+ }
353
+ $content .= sprintf( '<tr class="%s"><td colspan="2">', implode( ' ', $tr_classes ) );
354
+ } elseif ( 'subheading' == $option['type'] ) {
355
+ $content .= '<tr><td colspan="2">';
356
+ } elseif ( 'hidden' != $option['type'] ) {
357
+ if ( isset( $option['related_to'] ) && isset( $related_to[ $option['related_to'] ] ) && $related_to[ $option['related_to'] ] == 0 ) {
358
+ $classes[] = 'hidden';
359
+ }
360
+ $content .= sprintf(
361
+ '<tr valign="top" id="tr_%s" class="%s">',
362
+ esc_attr( $option_name? $option_name:'' ),
363
+ implode( ' ', $tr_classes )
364
+ );
365
+ $content .= sprintf(
366
+ '<th scope="row">%s%s</th>',
367
+ isset( $option['dashicon'] ) && $option['dashicon']? sprintf( '<span class="dashicons dashicons-%s"></span>&nbsp;', $option['dashicon'] ):'',
368
+ isset( $option['th'] ) && $option['th']? $option['th']:'&nbsp;'
369
+ );
370
+ $content .= '<td>';
371
+ }
372
+ $html_element_name = $option_name? $this->option_prefix.$option_name:'';
373
+ $filter_name = $html_element_name? $option_group.'_'.$html_element_name : null;
374
+
375
+ /**
376
+ * classes
377
+ */
378
+ $classes = isset( $option['classes'] )? $option['classes'] : ( isset( $option['class'] )? explode( ' ', $option['class'] ) : array() );
379
+ $classes[] = sprintf( 'option-%s', $option['type'] );
380
+
381
+ /**
382
+ * build
383
+ */
384
+ switch ( $option['type'] ) {
385
+ case 'hidden':
386
+ $hidden .= sprintf(
387
+ '<input type="hidden" name="%s" value="%s" id="%s" />',
388
+ esc_attr( $html_element_name ),
389
+ esc_attr( $this->get_option( $option_name, $option_group ) ),
390
+ esc_attr( isset( $option['id'] )? $option['id']:'' )
391
+ );
392
+ break;
393
+ case 'number':
394
+ $args = array();
395
+ $args_keys = array( 'min', 'max', 'step' );
396
+ foreach ( $args_keys as $arg_key ) {
397
+ if ( isset( $option[ $arg_key ] ) ) {
398
+ $args[ $arg_key ] = $option[ $arg_key ];
399
+ }
400
+ }
401
+ if ( isset( $option['use_name_as_id'] ) && $option['use_name_as_id'] ) {
402
+ $args['id'] = sprintf( ' id="%s"', $html_element_name );
403
+ }
404
+
405
+ $content .= sprintf(
406
+ '<input type="%s" name="%s" value="%s" class="%s" %s /> %s',
407
+ $option['type'],
408
+ $html_element_name,
409
+ $this->get_option( $option_name, $option_group ),
410
+ esc_attr( implode( ' ', $classes ) ),
411
+ $this->build_field_attributes( $args ),
412
+ isset( $option['label'] )? $option['label']:''
413
+ );
414
+ break;
415
+ case 'email':
416
+ case 'password':
417
+ case 'text':
418
+ case 'url':
419
+ $id = '';
420
+ if ( isset( $option['use_name_as_id'] ) && $option['use_name_as_id'] ) {
421
+ $id = sprintf( ' id="%s"', $html_element_name );
422
+ }
423
+ $content .= sprintf(
424
+ '<input type="%s" name="%s" value="%s" class="%s"%s /> %s',
425
+ $option['type'],
426
+ $html_element_name,
427
+ $this->get_option( $option_name, $option_group ),
428
+ esc_attr( implode( ' ', $classes ) ),
429
+ $id,
430
+ isset( $option['label'] )? $option['label']:''
431
+ );
432
+ break;
433
+ case 'checkbox':
434
+ $related_to[ $option_name ] = $this->get_option( $option_name, $option_group );
435
+ $checkbox = sprintf(
436
+ '<label for="%s"><input type="checkbox" name="%s" id="%s" value="1"%s%s class="%s" /> %s</label>',
437
+ $html_element_name,
438
+ $html_element_name,
439
+ $html_element_name,
440
+ $related_to[ $option_name ]? ' checked="checked"':'',
441
+ ( ( isset( $option['disabled'] ) && $option['disabled'] ) or ( isset( $option['need_pro'] ) && $option['need_pro'] ) )? ' disabled="disabled"':'',
442
+ esc_attr( implode( ' ', $classes ) ),
443
+ isset( $option['label'] )? $option['label']:''
444
+ );
445
+ $content .= apply_filters( $filter_name, $checkbox );
446
+ break;
447
+ case 'checkbox_group':
448
+ $option_value = $this->get_option( $option_name, $option_group );
449
+ if ( empty( $option_value ) && isset( $option['defaults'] ) ) {
450
+ foreach ( $option['defaults'] as $default ) {
451
+ $option_value[ $default ] = $default;
452
+ }
453
+ }
454
+ $content .= '<ul>';
455
+ $i = 0;
456
+ if ( isset( $option['extra_options'] ) && is_callable( $option['extra_options'] ) ) {
457
+ $option['options'] = array_merge( $option['options'], $option['extra_options']() );
458
+ }
459
+ foreach ( $option['options'] as $value => $label ) {
460
+ $checked = false;
461
+ if ( is_array( $option_value ) && array_key_exists( $value, $option_value ) ) {
462
+ $checked = true;
463
+ }
464
+ $id = sprintf( '%s%d', $option_name, $i++ );
465
+ $content .= sprintf(
466
+ '<li><label for="%s"><input type="checkbox" name="%s[%s]" value="%s"%s id="%s"/> %s</label></li>',
467
+ $id,
468
+ $html_element_name,
469
+ $value,
470
+ $value,
471
+ $checked? ' checked="checked"':'',
472
+ $id,
473
+ $label
474
+ );
475
+ }
476
+ $content .= '</ul>';
477
+ break;
478
+ case 'radio':
479
+ $option_value = $this->get_option( $option_name, $option_group );
480
+ $i = 0;
481
+ /**
482
+ * check user add "radio" or "options".
483
+ */
484
+ $radio_options = array();
485
+ if ( array_key_exists( 'options', $option ) ) {
486
+ $radio_options = $option['options'];
487
+ } else if ( array_key_exists( 'radio', $option ) ) {
488
+ $radio_options = $option['radio'];
489
+ }
490
+ if ( empty( $radio_options ) ) {
491
+ $content .= sprintf(
492
+ '<p>Error: no <strong>radio</strong> array key for option: <em>%s</em>.</p>',
493
+ $option_name
494
+ );
495
+ } else {
496
+ /**
497
+ * add extra options, maybe dynamic?
498
+ */
499
+ $radio_options = apply_filters( $filter_name.'_data', $radio_options );
500
+ $radio = apply_filters( $filter_name.'_content', null, $radio_options, $html_element_name, $option_name, $option_value );
501
+ if ( empty( $radio ) ) {
502
+ foreach ( $radio_options as $value => $input ) {
503
+ $id = sprintf( '%s%d', $option_name, $i++ );
504
+ $disabled = '';
505
+ if ( preg_match( '/\-disabled$/', $value ) ) {
506
+ $disabled = 'disabled="disabled"';
507
+ } elseif ( isset( $input['disabled'] ) && $input['disabled'] ) {
508
+ $disabled = 'disabled="disabled"';
509
+ }
510
+ $classes[] = sanitize_title( $value );
511
+ $radio .= sprintf(
512
+ '<li class="%s%s"><label for="%s"><input type="radio" name="%s" value="%s"%s id="%s" %s/> %s</label>',
513
+ esc_attr( implode( ' ', $classes ) ),
514
+ $disabled? ' disabled':'',
515
+ esc_attr( $id ),
516
+ esc_attr( $html_element_name ),
517
+ esc_attr( $value ),
518
+ ($option_value == $value or ( empty( $option_value ) and isset( $option['default'] ) and $value == $option['default'] ) )? ' checked="checked"':'',
519
+ esc_attr( $id ),
520
+ $disabled,
521
+ esc_html( $input['label'] )
522
+ );
523
+ if ( isset( $input['description'] ) ) {
524
+ $radio .= sprintf(
525
+ '<br /><span class="description">%s</span>',
526
+ $input['description']
527
+ );
528
+ }
529
+ $radio .= '</li>';
530
+ }
531
+ if ( $radio ) {
532
+ $radio = sprintf( '<ul>%s</ul>', $radio );
533
+ }
534
+ } else {
535
+ $radio = apply_filters( $filter_name, $radio );
536
+ if ( empty( $radio ) ) {
537
+ $content .= sprintf(
538
+ '<p>Error: no <strong>radio</strong> array key for option: <em>%s</em>.</p>',
539
+ $option_name
540
+ );
541
+ }
542
+ }
543
+ $content .= apply_filters( $filter_name, $radio );
544
+ }
545
+ break;
546
+ case 'select':
547
+ case 'select2':
548
+ $extra = $name_sufix = '';
549
+ if ( 'select2' == $option['type'] ) {
550
+ $classes[] = 'select2';
551
+ if ( isset( $option['multiple'] ) && $option['multiple'] ) {
552
+ $extra = ' multiple="multiple"';
553
+ $name_sufix = '[]';
554
+ }
555
+ }
556
+ $option_value = $this->get_option( $option_name, $option_group );
557
+ if ( isset( $option['extra_options'] ) && is_callable( $option['extra_options'] ) ) {
558
+ $option['options'] = array_merge( $option['options'], $option['extra_options']() );
559
+ }
560
+ $option['options'] = apply_filters( $filter_name.'_data', $option['options'], $option_name, $option_value );
561
+
562
+ $select = apply_filters( $filter_name.'_content', null, $option['options'], $html_element_name, $option_name, $option_value );
563
+ $select = apply_filters( 'iworks_options_'.$option_name.'_content', null, $option['options'], $html_element_name, $option_name, $option_value );
564
+ if ( empty( $select ) ) {
565
+ foreach ( $option['options'] as $key => $value ) {
566
+ $disabled = '';
567
+ if ( preg_match( '/\-disabled$/', $value ) ) {
568
+ $disabled = 'disabled="disabled"';
569
+ } elseif ( isset( $input['disabled'] ) && $input['disabled'] ) {
570
+ $disabled = 'disabled="disabled"';
571
+ }
572
+ $selected = false;
573
+ if ( is_array( $option_value ) ) {
574
+ if ( empty( $option_value ) ) {
575
+ } else {
576
+ $selected = in_array( $key, $option_value );
577
+ }
578
+ } else {
579
+ $selected = ($option_value == $key or ( empty( $option_value ) and isset( $option['default'] ) and $key == $option['default'] ) );
580
+ }
581
+
582
+ $select .= sprintf(
583
+ '<option %s value="%s" %s %s >%s</option>',
584
+ $disabled? 'class="disabled"':'',
585
+ $key,
586
+ selected( $selected, true, false ),
587
+ $disabled,
588
+ $value
589
+ );
590
+ }
591
+ if ( $select ) {
592
+ $select = sprintf(
593
+ '<select id="%s" name="%s%s" class="%s" %s>%s</select>',
594
+ esc_attr( $html_element_name ),
595
+ esc_attr( $html_element_name ),
596
+ esc_attr( $name_sufix ),
597
+ esc_attr( implode( ' ', $classes ) ),
598
+ $extra,
599
+ $select
600
+ );
601
+ }
602
+ }
603
+ $content .= apply_filters( $filter_name, $select );
604
+ break;
605
+ case 'textarea':
606
+ $value = $this->get_option( $option_name, $option_group );
607
+ $value = ( ! $value && isset( $option['default'] ))? $option['default']:$value;
608
+ $args = array(
609
+ 'rows' => isset( $option['rows'] )? $option['rows']:3,
610
+ 'class' => implode( ' ', $option['classes'] ),
611
+ );
612
+ $content .= $this->textarea( $html_element_name, $value, $args );
613
+ break;
614
+ case 'heading':
615
+ if ( isset( $option['label'] ) && $option['label'] ) {
616
+ $classes = array();
617
+ if ( $this->get_option( 'last_used_tab' ) == $label_index ) {
618
+ $classes[] = 'selected';
619
+ }
620
+ $content .= sprintf(
621
+ '<h3 id="options-%s"%s>%s</h3>',
622
+ sanitize_title_with_dashes( remove_accents( $option['label'] ) ),
623
+ count( $classes )? ' class="'.implode( ' ', $classes ).'"':'',
624
+ $option['label']
625
+ );
626
+ $label_index++;
627
+ $i = 0;
628
+ }
629
+ break;
630
+ case 'info':
631
+ $content .= $option['value'];
632
+ break;
633
+ case 'serialize':
634
+ if ( isset( $option['callback'] ) && is_callable( $option['callback'] ) ) {
635
+ $content .= $option['callback']( $this->get_option( $option_name, $option_group ), $option_name );
636
+ } elseif ( isset( $option['call_user_func'] ) && isset( $option['call_user_data'] ) && is_callable( $option['call_user_func'] ) ) {
637
+ ob_start();
638
+ call_user_func_array( $option['call_user_func'], $option['call_user_data'] );
639
+ $content .= ob_get_contents();
640
+ ob_end_clean();
641
+ }
642
+ break;
643
+ case 'subheading':
644
+ $content .= sprintf( '<h4 class="title">%s</h4>', $option['label'] );
645
+ break;
646
+ case 'wpColorPicker':
647
+ if ( is_admin() ) {
648
+ wp_enqueue_style( 'wp-color-picker' );
649
+ wp_enqueue_script( 'wp-color-picker' );
650
+ }
651
+ $id = '';
652
+ if ( isset( $option['use_name_as_id'] ) && $option['use_name_as_id'] ) {
653
+ $id = sprintf( ' id="%s"', $html_element_name );
654
+ }
655
+ $content .= apply_filters(
656
+ $filter_name,
657
+ sprintf(
658
+ '<input type="text" name="%s" value="%s" class="wpColorPicker %s"%s%s /> %s',
659
+ $html_element_name,
660
+ $this->get_option( $option_name, $option_group ),
661
+ isset( $option['class'] ) && $option['class']? $option['class']:'',
662
+ $id,
663
+ ( isset( $option['need_pro'] ) and $option['need_pro'] )? ' disabled="disabled"':'',
664
+ isset( $option['label'] )? $option['label']:'',
665
+ $html_element_name
666
+ )
667
+ );
668
+ break;
669
+ case 'image':
670
+ if ( isset( $option['description'] ) && $option['description'] ) {
671
+ printf( '<p class="description">%s</p>', $option['description'] );
672
+ }
673
+ $value = $this->get_option( $option_name, $option_group );
674
+ $content .= sprintf(
675
+ '<img id="%s_img" src="%s" alt="" style="%s%sclear:right;display:block;margin-bottom:10px;" />',
676
+ $html_element_name,
677
+ $value? $value : '',
678
+ array_key_exists( 'max-width', $option ) && is_integer( $option['max-width'] )? sprintf( 'max-width: %dpx;', $option['max-width'] ):'',
679
+ array_key_exists( 'max-height', $option ) && is_integer( $option['max-height'] )? sprintf( 'max-height: %dpx;', $option['max-height'] ):''
680
+ );
681
+ $content .= sprintf(
682
+ '<input type="hidden" name="%s" id="%s" value="%s" />',
683
+ $this->get_option( $option_name, $option_group ),
684
+ $this->get_option( $option_name, $option_group ),
685
+ $value
686
+ );
687
+ $content .= sprintf(
688
+ ' <input type="button" class="button iworks_upload_button" value="%s" rel="#%s" />',
689
+ __( 'Upload image', 'sierotki' ),
690
+ $html_element_name
691
+ );
692
+ if ( ! empty( $value ) || ( array_key_exists( 'default', $option ) && $value != $option['default'] ) ) {
693
+ $content .= sprintf(
694
+ ' <input type="submit" class="button iworks_delete_button" value="%s" rel="#%s%s" />',
695
+ __( 'Delete image', 'sierotki' ),
696
+ $html_element_name
697
+ );
698
+ }
699
+ break;
700
+ default:
701
+ $content .= sprintf( 'not implemented type: %s', $option['type'] );
702
+ }
703
+ if ( $option['type'] != 'hidden' ) {
704
+ if ( isset( $option['description'] ) && $option['description'] ) {
705
+ if ( isset( $option['label'] ) && $option['label'] ) {
706
+ $content .= '<br />';
707
+ }
708
+ $content .= sprintf( '<span class="description">%s</span>', $option['description'] );
709
+ }
710
+ $content .= '</td>';
711
+ $content .= '</tr>';
712
+ }
713
+ }
714
+ /**
715
+ * filter
716
+ */
717
+ if ( isset( $option['filter'] ) ) {
718
+ $content .= apply_filters( $option['filter'], '' );
719
+ }
720
+ /**
721
+ * content
722
+ */
723
+ if ( $content ) {
724
+ if ( isset( $options['label'] ) && $options['label'] && ! $use_tabs ) {
725
+ $top .= sprintf( '<h3>%s</h3>', $options['label'] );
726
+ }
727
+ $top .= $hidden;
728
+ if ( $use_tabs ) {
729
+ if ( $options['add_table'] ) {
730
+ $content .= '</tbody></table>';
731
+ }
732
+ $content .= '</fieldset>';
733
+ $content = $top.$content;
734
+ } else {
735
+ if ( $options['add_table'] ) {
736
+ $top .= sprintf( '<table class="form-table%s" style="%s">', isset( $options['widefat'] )? ' widefat':'', isset( $options['style'] )? $options['style']:'' );
737
+ if ( isset( $options['thead'] ) ) {
738
+ $top .= sprintf( '<thead><tr class="%s">', implode( ' ', $tr_classes ) );
739
+ foreach ( $options['thead'] as $text => $colspan ) {
740
+ $top .= sprintf(
741
+ '<th%s>%s</th>',
742
+ $colspan > 1? ' colspan="'.$colspan.'"':'',
743
+ $text
744
+ );
745
+ }
746
+ $top .= '</tr></thead>';
747
+ }
748
+ $top .= '<tbody>';
749
+ }
750
+ $content = $top.$content;
751
+ if ( $options['add_table'] ) {
752
+ $content .= '</tbody></table>';
753
+ }
754
+ }
755
+ }
756
+ if ( $use_tabs ) {
757
+ $content .= '</div>';
758
+ }
759
+ /**
760
+ * submit button
761
+ */
762
+ if ( $options['show_submit_button'] ) {
763
+ $content .= get_submit_button( __( 'Save Changes' ), 'primary', 'submit_button' );
764
+ }
765
+
766
+ /**
767
+ * iworks-options wrapper
768
+ */
769
+ $content = sprintf( '<div class="iworks-options">%s</div>', $content );
770
+
771
+ /* print ? */
772
+ if ( $echo ) {
773
+ echo $content;
774
+ return;
775
+ }
776
+ return $content;
777
+ }
778
+
779
+ private function register_setting( $options, $option_group ) {
780
+ foreach ( $options as $option ) {
781
+ /**
782
+ * don't register setting without type and name
783
+ */
784
+ if ( ! array_key_exists( 'type', $option ) || ! array_key_exists( 'name', $option ) ) {
785
+ continue;
786
+ }
787
+ /**
788
+ * don't register certain type setting or with empty name
789
+ */
790
+ if ( preg_match( '/^(sub)?heading$/', $option['type'] ) || empty( $option['name'] ) ) {
791
+ continue;
792
+ }
793
+ /**
794
+ * register setting
795
+ */
796
+ register_setting(
797
+ $this->option_prefix.$option_group,
798
+ $this->option_prefix.$option['name'],
799
+ isset( $option['sanitize_callback'] )? $option['sanitize_callback']:array( $this, 'sanitize_callback' )
800
+ );
801
+ }
802
+ }
803
+
804
+ public function options_init() {
805
+ $options = array();
806
+ if ( is_callable( $this->option_function_name ) ) {
807
+ $options = call_user_func( $this->option_function_name );
808
+ }
809
+ /**
810
+ * add last_used_tab field
811
+ */
812
+ foreach ( $options as $key => $data ) {
813
+ if ( isset( $options[ $key ]['use_tabs'] ) && $options[ $key ]['use_tabs'] ) {
814
+ $field = array(
815
+ 'type' => 'hidden',
816
+ 'name' => 'last_used_tab',
817
+ 'id' => 'last_used_tab',
818
+ );
819
+ array_unshift( $options[ $key ]['options'], $field );
820
+ }
821
+ }
822
+ /**
823
+ * filter it
824
+ */
825
+ $options = apply_filters( $this->option_function_name, $options );
826
+ /**
827
+ * register_setting
828
+ */
829
+ foreach ( $options as $key => $data ) {
830
+ if ( isset( $data['options'] ) && is_array( $data['options'] ) ) {
831
+ $this->register_setting( $data['options'], $key );
832
+ } elseif ( 'options' == $key ) {
833
+ $this->register_setting( $data, 'theme' );
834
+ }
835
+ }
836
+ }
837
+
838
+ public function get_values( $option_name, $option_group = 'index' ) {
839
+ $this->option_group = $option_group;
840
+ $data = $this->get_option_array();
841
+ $data = $data['options'];
842
+ foreach ( $data as $one ) {
843
+ if ( isset( $one['name'] ) && $one['name'] != $option_name ) {
844
+ continue;
845
+ }
846
+ switch ( $one['type'] ) {
847
+ case 'checkbox_group':
848
+ return $one['options'];
849
+ case 'radio':
850
+ return $one['radio'];
851
+ }
852
+ }
853
+ return;
854
+ }
855
+
856
+ public function get_default_value( $option_name, $option_group = 'index' ) {
857
+ $this->option_group = $option_group;
858
+ $options = $this->get_option_array();
859
+ /**
860
+ * check options exists?
861
+ */
862
+ if ( ! array_key_exists( 'options', $options ) or ! is_array( $options['options'] ) ) {
863
+ return null;
864
+ }
865
+ /**
866
+ * default key name
867
+ */
868
+ $default_option_name = $option_name;
869
+ /**
870
+ * default name for taxonomies
871
+ */
872
+ if ( array_key_exists( 'type', $options ) && 'taxonomy' == $options['type'] ) {
873
+ $re = sprintf( '/^%s_\d+_/', $option_group );
874
+ $default_option_name = preg_replace( $re, '', $default_option_name );
875
+ }
876
+ foreach ( $options['options'] as $option ) {
877
+ if ( isset( $option['name'] ) && $option['name'] == $default_option_name ) {
878
+ return isset( $option['default'] )? $option['default']:null;
879
+ }
880
+ }
881
+ return null;
882
+ }
883
+
884
+ public function activate() {
885
+ $options = apply_filters( $this->option_function_name, call_user_func( $this->option_function_name ) );
886
+ foreach ( $options as $key => $data ) {
887
+ foreach ( $data['options'] as $option ) {
888
+ if ( $option['type'] == 'heading' or ! isset( $option['name'] ) or ! $option['name'] or ! isset( $option['default'] ) ) {
889
+ continue;
890
+ }
891
+ add_option( $this->option_prefix.$option['name'], $option['default'], '', isset( $option['autoload'] )? $option['autoload']:'yes' );
892
+ }
893
+ }
894
+ add_option( $this->option_prefix.'cache_stamp', date( 'c' ) );
895
+ }
896
+
897
+ public function deactivate() {
898
+ $options = apply_filters( $this->option_function_name, call_user_func( $this->option_function_name ) );
899
+ foreach ( $options as $key => $data ) {
900
+ foreach ( $data['options'] as $option ) {
901
+ if ( 'heading' == $option['type'] or ! isset( $option['name'] ) or ! $option['name'] ) {
902
+ continue;
903
+ }
904
+ /**
905
+ * prevent special options
906
+ */
907
+ if ( isset( $option['dont_deactivate'] ) && $option['dont_deactivate'] ) {
908
+ continue;
909
+ }
910
+ delete_option( $this->option_prefix.$option['name'] );
911
+ }
912
+ }
913
+ delete_option( $this->option_prefix.'cache_stamp' );
914
+ delete_option( $this->option_prefix.'version' );
915
+ delete_option( $this->option_prefix.'flush_rules' );
916
+ }
917
+
918
+ public function settings_fields( $option_name, $use_prefix = true ) {
919
+ if ( $use_prefix ) {
920
+ settings_fields( $this->option_prefix . $option_name );
921
+ } else {
922
+ settings_fields( $option_name );
923
+ }
924
+ }
925
+
926
+ /**
927
+ * admin_notices
928
+ */
929
+
930
+ public function admin_notices() {
931
+ if ( empty( $this->notices ) ) {
932
+ return;
933
+ }
934
+ foreach ( $this->notices as $notice ) {
935
+ printf( '<div class="error"><p>%s</p></div>', $notice );
936
+ }
937
+ }
938
+
939
+ /**
940
+ * options: add, get, update
941
+ */
942
+
943
+ public function add_option( $option_name, $option_value, $autoload = true ) {
944
+ $autoload = $autoload? 'yes':'no';
945
+ add_option( $this->option_prefix.$option_name, $option_value, null, $autoload );
946
+ }
947
+
948
+ public function get_option( $option_name, $option_group = 'index', $default_value = null, $forece_default = false ) {
949
+ $option_value = get_option( $this->option_prefix.$option_name, null );
950
+ $default_value = $this->get_default_value( $option_name, $option_group );
951
+ if ( ( $default_value || $forece_default ) && is_null( $option_value ) ) {
952
+ $option_value = $default_value;
953
+ }
954
+ return $option_value;
955
+ }
956
+
957
+ public function get_all_options() {
958
+ $data = array();
959
+ $options = $this->get_option_array();
960
+ foreach ( $options['options'] as $option ) {
961
+ if ( ! array_key_exists( 'name', $option ) || ! $option['name'] ) {
962
+ continue;
963
+ }
964
+ $value = $this->get_option( $option['name'] );
965
+ if ( array_key_exists( 'sanitize_callback', $option ) && is_callable( $option['sanitize_callback'] ) ) {
966
+ $value = call_user_func( $option['sanitize_callback'], $value );
967
+
968
+ }
969
+ $data[ $option['name'] ] = $value;
970
+ }
971
+ return $data;
972
+ }
973
+
974
+ public function get_option_name( $name ) {
975
+ return sprintf( '%s%s', $this->option_prefix, $name );
976
+ }
977
+
978
+ public function update_option( $option_name, $option_value ) {
979
+ /**
980
+ * delete if option have a default value
981
+ */
982
+ $default_value = $this->get_default_value( $this->option_prefix.$option_name );
983
+ if ( $option_name === $default_value ) {
984
+ delete_option( $this->option_prefix.$option_name );
985
+ return;
986
+ }
987
+ update_option( $this->option_prefix.$option_name, $option_value );
988
+ }
989
+
990
+ /**
991
+ * update taxonomy options
992
+ */
993
+
994
+ public function update_taxonomy_options( $option_group, $term_id ) {
995
+ $this->option_group = $option_group;
996
+ $options = $this->get_option_array();
997
+ /**
998
+ * only for taxonomies
999
+ */
1000
+ if ( ! array_key_exists( 'type', $options ) ) {
1001
+ return;
1002
+ }
1003
+ if ( 'taxonomy' != $options['type'] ) {
1004
+ return;
1005
+ }
1006
+ foreach ( $options['options'] as $option ) {
1007
+ if ( ! array_key_exists( 'name', $option ) || ! $option['name'] ) {
1008
+ continue;
1009
+ }
1010
+ $option_name = sprintf(
1011
+ '%s_%s_%s',
1012
+ $option_group,
1013
+ $term_id,
1014
+ $option['name']
1015
+ );
1016
+ $value = array_key_exists( $this->get_option_name( $option_name ), $_POST )? $_POST[ $this->get_option_name( $option_name ) ]:false;
1017
+
1018
+ if ( array_key_exists( 'sanitize_callback', $option ) && is_callable( $option['sanitize_callback'] ) ) {
1019
+ $value = call_user_func( $option['sanitize_callback'], $value );
1020
+ }
1021
+ if ( $value ) {
1022
+ $this->update_option( $option_name, $value );
1023
+ } else {
1024
+ delete_option( $option_name );
1025
+ }
1026
+ }
1027
+ }
1028
+
1029
+ /**
1030
+ * helpers
1031
+ */
1032
+
1033
+ public function select_page_helper( $name, $show_option_none = false, $post_type = 'page' ) {
1034
+ $args = array(
1035
+ 'echo' => false,
1036
+ 'name' => $this->get_option_name( $name ),
1037
+ 'selected' => $this->get_option( $name ),
1038
+ 'show_option_none' => $show_option_none,
1039
+ 'post_type' => $post_type,
1040
+ );
1041
+ return wp_dropdown_pages( $args );
1042
+ }
1043
+
1044
+ public function select_category_helper( $name, $hide_empty = null, $show_option_none = false ) {
1045
+ $args = array(
1046
+ 'echo' => false,
1047
+ 'name' => $this->get_option_name( $name ),
1048
+ 'selected' => $this->get_option( $name ),
1049
+ 'hierarchical' => true,
1050
+ 'hide_empty' => $hide_empty,
1051
+ );
1052
+ if ( $show_option_none ) {
1053
+ $args['show_option_none'] = true;
1054
+ }
1055
+ return wp_dropdown_categories( $args );
1056
+ }
1057
+
1058
+ public function get_option_group() {
1059
+ return $this->option_group;
1060
+ }
1061
+
1062
+ private function get_option_index_from_screen() {
1063
+ $screen = get_current_screen();
1064
+ $key = explode( $this->option_prefix, $screen->id );
1065
+ if ( 2 != count( $key ) ) {
1066
+ return false;
1067
+ }
1068
+ return $key[1];
1069
+ }
1070
+
1071
+ public function show_page( $check_option_name = true, $url = 'options.php' ) {
1072
+
1073
+ $options = array();
1074
+ $option_name = 'index';
1075
+ if ( $check_option_name ) {
1076
+ $option_name = $this->get_option_index_from_screen();
1077
+ if ( ! $option_name ) {
1078
+ return;
1079
+ }
1080
+ $options = $this->options[ $option_name ];
1081
+ } else {
1082
+ $options = $this->get_option_array();
1083
+ }
1084
+ global $screen_layout_columns;
1085
+ $data = array();
1086
+ ?>
1087
+ <div class="wrap iworks_options">
1088
+ <h1><?php echo $options['page_title']; ?></h1>
1089
+ <form method="post" action="<?php echo esc_url( $url ); ?>" id="<?php echo esc_attr( $this->get_option_name( 'admin_index' ) ); ?>">
1090
+ <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
1091
+ <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
1092
+ <input type="hidden" name="action" value="save_howto_metaboxes_general" />
1093
+ <div id="poststuff" class="metabox-holder<?php echo empty( $screen_layout_columns ) || 2 == $screen_layout_columns ? ' has-right-sidebar' : ''; ?>">
1094
+ <?php
1095
+ /**
1096
+ * check metaboxes for key
1097
+ */
1098
+ if ( array_key_exists( 'metaboxes', $this->options[ $option_name ] ) ) {
1099
+ ?>
1100
+ <div id="side-info-column" class="inner-sidebar">
1101
+ <?php do_meta_boxes( $this->pagehooks[ $option_name ], 'side', $this ); ?>
1102
+ </div>
1103
+ <?php } ?>
1104
+ <div id="post-body" class="has-sidebar">
1105
+ <div id="post-body-content" class="has-sidebar-content">
1106
+ <?php
1107
+ $this->settings_fields( $option_name );
1108
+ $this->build_options( $option_name );
1109
+ ?>
1110
+ </div>
1111
+ </div>
1112
+ <br class="clear"/>
1113
+ </div>
1114
+ </form>
1115
+ </div>
1116
+ <?php
1117
+ /**
1118
+ * check metaboxes for key
1119
+ */
1120
+ if ( array_key_exists( 'metaboxes', $this->options[ $option_name ] ) ) {
1121
+ include_once( ABSPATH . '/wp-admin/includes/meta-boxes.php' );
1122
+ ?>
1123
+ <script type="text/javascript" id="<?php echo __CLASS__; ?>">
1124
+ //<![CDATA[
1125
+ jQuery(document).ready( function($) {
1126
+ // close postboxes that should be closed
1127
+ $('.if-js-closed').removeClass('if-js-closed').addClass('closed');
1128
+ // postboxes setup
1129
+ postboxes.add_postbox_toggles('<?php echo $this->pagehooks[ $option_name ]; ?>');
1130
+ });
1131
+ //]]>
1132
+ </script>
1133
+ <?php
1134
+ }
1135
+ }
1136
+
1137
+ public function load_page() {
1138
+ $option_name = $this->get_option_index_from_screen();
1139
+ if ( ! $option_name ) {
1140
+ return;
1141
+ }
1142
+ /**
1143
+ * check options for key
1144
+ */
1145
+ if ( ! array_key_exists( $option_name, $this->options ) ) {
1146
+ return;
1147
+ }
1148
+ /**
1149
+ * check metaboxes for key
1150
+ */
1151
+ if ( ! array_key_exists( 'metaboxes', $this->options[ $option_name ] ) ) {
1152
+ return;
1153
+ }
1154
+ if ( ! count( $this->options[ $option_name ]['metaboxes'] ) ) {
1155
+ return;
1156
+ }
1157
+ /**
1158
+ * ensure, that the needed javascripts been loaded to allow drag/drop,
1159
+ * expand/collapse and hide/show of boxes
1160
+ */
1161
+ wp_enqueue_script( 'common' );
1162
+ wp_enqueue_script( 'wp-lists' );
1163
+ wp_enqueue_script( 'postbox' );
1164
+
1165
+ foreach ( $this->options[ $option_name ]['metaboxes'] as $id => $data ) {
1166
+ add_meta_box(
1167
+ $id,
1168
+ $data['title'],
1169
+ $data['callback'],
1170
+ $this->pagehooks[ $option_name ],
1171
+ $data['context'],
1172
+ $data['priority']
1173
+ );
1174
+ }
1175
+ /**
1176
+ * wp_enqueue_script
1177
+ */
1178
+ if ( array_key_exists( 'enqueue_scripts', $this->options[ $option_name ] ) ) {
1179
+ $scripts = array();
1180
+ if ( is_admin() && isset( $this->options[ $option_name ]['enqueue_scripts']['admin'] ) ) {
1181
+ $scripts = $this->options[ $option_name ]['enqueue_scripts']['admin'];
1182
+ } else if ( ! is_admin() && isset( $this->options[ $option_name ]['enqueue_scripts']['frontend'] ) ) {
1183
+ $scripts = $this->options[ $option_name ]['enqueue_scripts']['frontend'];
1184
+ } else {
1185
+ $scripts = $this->options[ $option_name ]['enqueue_scripts'];
1186
+ }
1187
+ foreach ( $scripts as $script ) {
1188
+ wp_enqueue_script( $script );
1189
+ }
1190
+ }
1191
+ /**
1192
+ * wp_enqueue_style
1193
+ */
1194
+ if ( array_key_exists( 'enqueue_styles', $this->options[ $option_name ] ) ) {
1195
+ $styles = array();
1196
+ if ( is_admin() && isset( $this->options[ $option_name ]['enqueue_styles']['admin'] ) ) {
1197
+ $styles = $this->options[ $option_name ]['enqueue_styles']['admin'];
1198
+ } else if ( ! is_admin() && isset( $this->options[ $option_name ]['enqueue_styles']['frontend'] ) ) {
1199
+ $styles = $this->options[ $option_name ]['enqueue_styles']['frontend'];
1200
+ } else {
1201
+ $styles = $this->options[ $option_name ]['enqueue_styles'];
1202
+ }
1203
+ foreach ( $styles as $style ) {
1204
+ wp_enqueue_style( $style );
1205
+ }
1206
+ }
1207
+ }
1208
+
1209
+ public function screen_layout_columns( $columns, $screen ) {
1210
+ foreach ( $this->pagehooks as $option_name => $pagehook ) {
1211
+ if ( $screen == $pagehook ) {
1212
+ $columns[ $pagehook ] = 2;
1213
+ }
1214
+ }
1215
+ return $columns;
1216
+ }
1217
+
1218
+ public function get_options_by_group( $group ) {
1219
+ $opts = array();
1220
+ $options = $this->get_option_array();
1221
+ if ( ! isset( $options['options'] ) || empty( $options['options'] ) ) {
1222
+ return $options;
1223
+ }
1224
+ foreach ( $options['options'] as $one ) {
1225
+ if ( ! isset( $one['name'] ) || ! isset( $one['type'] ) ) {
1226
+ continue;
1227
+ }
1228
+ if ( ! isset( $one['group'] ) || $group != $one['group'] ) {
1229
+ continue;
1230
+ }
1231
+ $opts[] = $one;
1232
+ }
1233
+ return $opts;
1234
+ }
1235
+
1236
+ /**
1237
+ * input types
1238
+ */
1239
+ public function get_field_by_type( $type, $name, $value = '', $args = array() ) {
1240
+ if ( method_exists( $this, $type ) ) {
1241
+ if ( ! isset( $args['class'] ) ) {
1242
+ $args['class'] = array( 'large-text' );
1243
+ }
1244
+ return $this->$type( $name, $value, $args );
1245
+ }
1246
+ return sprintf( 'wrong type: %s', esc_html( $type ) );
1247
+ }
1248
+
1249
+ private function build_field_attributes( $args ) {
1250
+ $atts = '';
1251
+ foreach ( $args as $key => $value ) {
1252
+ if ( is_array( $value ) ) {
1253
+ $value = implode( ' ', $value );
1254
+ }
1255
+ $atts .= sprintf( ' %s="%s"', esc_html( $key ), esc_attr( trim( $value ) ) );
1256
+ }
1257
+ return $atts;
1258
+ }
1259
+
1260
+ private function select( $name, $value = '', $args = array(), $type = 'text' ) {
1261
+ /**
1262
+ * default value
1263
+ */
1264
+ if ( isset( $args['default'] ) ) {
1265
+ if ( empty( $value ) ) {
1266
+ $value = $args['default'];
1267
+ }
1268
+ unset( $args['default'] );
1269
+ }
1270
+ /**
1271
+ * options
1272
+ */
1273
+ $options = array();
1274
+ if ( isset( $args['options'] ) ) {
1275
+ $options = $args['options'];
1276
+ unset( $args['options'] );
1277
+ }
1278
+ if ( empty( $options ) && ! empty( $value ) ) {
1279
+ $options[ $value['value'] ] = $value['label'];
1280
+ }
1281
+
1282
+ $value_to_check = isset( $value['value'] ) ? $value['value'] : false;
1283
+
1284
+ $content = sprintf(
1285
+ '<select type="%s" name="%s" %s >',
1286
+ esc_attr( $type ),
1287
+ esc_attr( $name ),
1288
+ $this->build_field_attributes( $args )
1289
+ );
1290
+ foreach ( $options as $val => $label ) {
1291
+ $content .= sprintf(
1292
+ '<option value="%s" %s>%s</option>',
1293
+ esc_attr( $val ),
1294
+ selected( $val, $value_to_check, false ),
1295
+ esc_html( $label )
1296
+ );
1297
+ }
1298
+ $content .= '</select>';
1299
+ return $content;
1300
+ }
1301
+
1302
+ private function input( $name, $value = '', $args = array(), $type = 'text' ) {
1303
+ /**
1304
+ * default value
1305
+ */
1306
+ if ( isset( $args['default'] ) ) {
1307
+ if ( empty( $value ) ) {
1308
+ $value = $args['default'];
1309
+ }
1310
+ unset( $args['default'] );
1311
+ }
1312
+ /**
1313
+ * turn off autocomplete
1314
+ */
1315
+ if ( 'text' == $type ) {
1316
+ if ( ! isset( $args['autocomplete'] ) ) {
1317
+ $args['autocomplete'] = 'off';
1318
+ }
1319
+ }
1320
+ return sprintf(
1321
+ '<input type="%s" name="%s" value="%s" %s />',
1322
+ esc_attr( $type ),
1323
+ esc_attr( $name ),
1324
+ esc_attr( $value ),
1325
+ $this->build_field_attributes( $args )
1326
+ );
1327
+ }
1328
+
1329
+ private function text( $name, $value = '', $args = array() ) {
1330
+ return $this->input( $name, $value, $args, __FUNCTION__ );
1331
+ }
1332
+
1333
+ private function date( $name, $value = '', $args = array() ) {
1334
+ if ( ! isset( $args['class'] ) ) {
1335
+ $args['class'] = array();
1336
+ }
1337
+ $args['class'][] = 'datepicker';
1338
+ return $this->input( $name, $value, $args );
1339
+ }
1340
+
1341
+ private function select2( $name, $value = '', $args = array() ) {
1342
+ if ( isset( $args['data-nonce-action'] ) ) {
1343
+ $args['data-nonce'] = wp_create_nonce( $args['data-nonce-action'] );
1344
+ unset( $args['data-nonce-action'] );
1345
+ }
1346
+ if ( ! isset( $args['class'] ) ) {
1347
+ $args['class'] = array();
1348
+ }
1349
+ $args['class'][] = 'select2';
1350
+ return $this->select( $name, $value, $args );
1351
+ }
1352
+
1353
+ private function textarea( $name, $value = '', $args = array() ) {
1354
+ if ( ! isset( $args['rows'] ) ) {
1355
+ $args['rows'] = 3;
1356
+ }
1357
+ return sprintf(
1358
+ '<textarea name="%s" %s>%s</textarea>',
1359
+ esc_attr( $name ),
1360
+ $this->build_field_attributes( $args ),
1361
+ $value
1362
+ );
1363
+ }
1364
+
1365
+ private function radio( $name, $value = '', $args = array() ) {
1366
+ $radio = '';
1367
+ $options = $args['options'];
1368
+ unset( $args['options'] );
1369
+ /**
1370
+ * default value
1371
+ */
1372
+ if ( isset( $args['default'] ) && '' == $value ) {
1373
+ $value = $args['default'];
1374
+ }
1375
+ $i = 0;
1376
+ foreach ( $options as $option_value => $input ) {
1377
+ $id = sprintf( '%s%d', $name, $i++ );
1378
+ $radio .= sprintf(
1379
+ '<li class="%s"><label for="%s"><input type="radio" name="%s" value="%s"%s id="%s"/> %s</label>',
1380
+ esc_attr( sanitize_title( $value ) ),
1381
+ esc_attr( $id ),
1382
+ esc_attr( $name ),
1383
+ esc_attr( $option_value ),
1384
+ checked( $option_value, $value, false ),
1385
+ esc_attr( $id ),
1386
+ esc_html( $input['label'] )
1387
+ );
1388
+ if ( isset( $input['description'] ) ) {
1389
+ $radio .= sprintf(
1390
+ '<br /><span class="description">%s</span>',
1391
+ $input['description']
1392
+ );
1393
+ }
1394
+ $radio .= '</li>';
1395
+ }
1396
+ if ( $radio ) {
1397
+ $radio = sprintf( '<ul>%s</ul>', $radio );
1398
+ }
1399
+ return $radio;
1400
+ }
1401
+
1402
+ private function description( $name, $value = '', $args = array() ) {
1403
+ if ( ! isset( $args['value'] ) || empty( $args['value'] ) ) {
1404
+ return '';
1405
+ }
1406
+ return sprintf( '<p class="description">%s</p>', $args['value'] );
1407
+ }
1408
+
1409
+ private function money( $name, $value = '', $args = array() ) {
1410
+ if ( empty( $value ) || ! is_array( $value ) ) {
1411
+ $value = array(
1412
+ 'integer' => 0,
1413
+ 'fractional' => 0,
1414
+ );
1415
+ }
1416
+ $content = '';
1417
+ /**
1418
+ * Integer
1419
+ */
1420
+ $n = sprintf( '%s[integer]', $name );
1421
+ $content .= $this->input( $n, $value['integer'], array( 'min' => 0 ), 'number' );
1422
+ /**
1423
+ * fractional
1424
+ */
1425
+ $n = sprintf( '%s[fractional]', $name );
1426
+ $content .= $this->input( $n, $value['fractional'], array( 'min' => 0, 'max' => 99 ), 'number' );
1427
+ return $content;
1428
+ }
1429
+
1430
+ public function sanitize_callback( $value ) {
1431
+ return $value;
1432
+ }
1433
+
1434
+ public function admin_head() {
1435
+ $screen = get_current_screen();
1436
+ if ( ! in_array( $screen->id, $this->pagehooks ) ) {
1437
+ return;
1438
+ }
1439
+ $files = $this->get_files();
1440
+ foreach ( $files as $data ) {
1441
+ if ( $data['style'] ) {
1442
+ wp_enqueue_style( $data['handle'] );
1443
+ } else {
1444
+ wp_enqueue_script( $data['handle'] );
1445
+ }
1446
+ }
1447
+ }
1448
+
1449
+ /**
1450
+ * Cnvert color to rgb
1451
+ *
1452
+ * @since 2.4.1
1453
+ *
1454
+ * @param string $hex Hex value of color
1455
+ * @return array RGB array.
1456
+ */
1457
+ public function hex2rgb( $hex ) {
1458
+ $hex = str_replace( '#', '', $hex );
1459
+
1460
+ if ( strlen( $hex ) == 3 ) {
1461
+ $r = hexdec( substr( $hex,0,1 ).substr( $hex,0,1 ) );
1462
+ $g = hexdec( substr( $hex,1,1 ).substr( $hex,1,1 ) );
1463
+ $b = hexdec( substr( $hex,2,1 ).substr( $hex,2,1 ) );
1464
+ } else {
1465
+ $r = hexdec( substr( $hex,0,2 ) );
1466
+ $g = hexdec( substr( $hex,2,2 ) );
1467
+ $b = hexdec( substr( $hex,4,2 ) );
1468
+ }
1469
+ $rgb = array( $r, $g, $b );
1470
+ return $rgb; // returns an array with the rgb values
1471
+ }
1472
+
1473
+ public function register_styles() {
1474
+ $files = $this->get_files();
1475
+ foreach ( $files as $data ) {
1476
+ $file = sprintf( 'assets/%s/%s', $data['style']? 'styles':'scripts', $data['file'] );
1477
+ $file = plugins_url( $file, __FILE__ );
1478
+ $version = isset( $data['version'] )? $data['version'] : $this->version;
1479
+ $deps = isset( $data['deps'] )? $data['deps'] : array();
1480
+ $in_footer = isset( $data['in_footer'] )? $data['in_footer'] : true;
1481
+ if ( $data['style'] ) {
1482
+ wp_register_style( $data['handle'], $file, $deps, $version );
1483
+ } else {
1484
+ wp_register_script( $data['handle'], $file, $deps, $version, $in_footer );
1485
+ if ( isset( $data['wp_localize_script'] ) ) {
1486
+ wp_localize_script( $data['handle'], $data['handle'], $data['wp_localize_script'] );
1487
+ }
1488
+ }
1489
+ }
1490
+ }
1491
+
1492
+ public function get_files() {
1493
+ $f = array(
1494
+ /**
1495
+ * iworks_options core files
1496
+ */
1497
+ array(
1498
+ 'handle' => __CLASS__,
1499
+ 'file' => 'common.css',
1500
+ ),
1501
+ array(
1502
+ 'handle' => __CLASS__,
1503
+ 'file' => 'common.js',
1504
+ 'deps' => array( 'jquery', 'switch_button', 'jquery-ui-tabs' ),
1505
+ ),
1506
+ /**
1507
+ * switch checkbox
1508
+ */
1509
+ array(
1510
+ 'handle' => 'switch_button',
1511
+ 'file' => 'jquery.switch_button.css',
1512
+ 'version' => '1.0',
1513
+ ),
1514
+ array(
1515
+ 'handle' => 'switch_button',
1516
+ 'file' => 'jquery.switch_button.js',
1517
+ 'version' => '1.0',
1518
+ 'deps' => array( 'jquery', 'jquery-effects-core', 'jquery-ui-widget' ),
1519
+ 'wp_localize_script' => $this->get_switch_button_data(),
1520
+ ),
1521
+ /**
1522
+ * select2
1523
+ */
1524
+ array(
1525
+ 'handle' => 'select2',
1526
+ 'file' => 'select2.min.css',
1527
+ 'version' => '4.0.3',
1528
+ ),
1529
+ array(
1530
+ 'handle' => 'select2',
1531
+ 'file' => 'select2.min.js',
1532
+ 'version' => '4.0.3',
1533
+ 'deps' => array( 'jquery' ),
1534
+ ),
1535
+ );
1536
+ $files = array();
1537
+ foreach ( $f as $data ) {
1538
+ $data['style'] = preg_match( '/css$/', $data['file'] );
1539
+ $files[] = $data;
1540
+ }
1541
+ return $files;
1542
+ }
1543
+
1544
+ public function get_switch_button_data() {
1545
+ $data = array(
1546
+ 'labels' => array(
1547
+ 'off_label' => __( 'OFF', 'sierotki' ),
1548
+ 'on_label' => __( 'ON', 'sierotki' ),
1549
+ ),
1550
+ );
1551
+ return $data;
1552
+ }
1553
+
1554
+ /**
1555
+ * Get option page
1556
+ *
1557
+ * @since 2.6.0
1558
+ */
1559
+ public function get_pagehook() {
1560
+ return $this->option_prefix.$this->option_group;
1561
+ }
1562
+ }
vendor/iworks/orphan.php CHANGED
@@ -1,107 +1,100 @@
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  class iworks_orphan
3
  {
4
  private $options;
5
  private $admin_page;
 
 
 
 
 
 
 
 
6
 
7
- public function __construct() {
8
  /**
9
  * l10n
10
  */
11
- load_plugin_textdomain( 'sierotki', false, dirname( plugin_basename( dirname( dirname( __FILE__ ) ) ) ).'/languages' );
 
 
 
 
 
12
 
13
  /**
14
  * actions
15
  */
16
  add_action( 'init', array( $this, 'init' ) );
17
  add_action( 'admin_init', array( $this, 'admin_init' ) );
18
- add_action( 'admin_menu', array( $this, 'admin_menu' ) );
19
  add_action( 'iworks_rate_css', array( $this, 'iworks_rate_css' ) );
20
- add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ), 1 );
21
-
22
- /**
23
- * options
24
- */
25
- $this->options = array(
26
- 'comment_text' => array(
27
- 'description' => __( 'Use for comments:', 'sierotki' ),
28
- 'type' => 'checkbox',
29
- 'label' => __( 'Enabled the substitution of orphans in the comments.', 'sierotki' ),
30
- 'sanitize_callback' => 'absint',
31
- ),
32
- 'the_title' => array(
33
- 'description' => __( 'Use for post title:', 'sierotki' ),
34
- 'type' => 'checkbox',
35
- 'label' => __( 'Enabled the substitution of orphans in the post_title.', 'sierotki' ),
36
- 'sanitize_callback' => 'absint',
37
- ),
38
- 'the_excerpt' => array(
39
- 'description' => __( 'Use for excerpt:', 'sierotki' ),
40
- 'type' => 'checkbox',
41
- 'label' => __( 'Enabled the substitution of orphans in the excerpt.', 'sierotki' ),
42
- 'sanitize_callback' => 'absint',
43
- ),
44
- 'the_content' => array(
45
- 'description' => __( 'Use for content:', 'sierotki' ),
46
- 'type' => 'checkbox',
47
- 'label' => __( 'Enabled the substitution of orphans in the content.', 'sierotki' ),
48
- 'sanitize_callback' => 'absint',
49
- ),
50
- /**
51
- * Since 2.6.6
52
- */
53
- 'widget_title' => array(
54
- 'description' => __( 'Use for widget title:', 'sierotki' ),
55
- 'type' => 'checkbox',
56
- 'label' => __( 'Enabled the substitution of orphans in the widget title.', 'sierotki' ),
57
- 'sanitize_callback' => 'absint',
58
- ),
59
- /**
60
- * Since 2.6.6
61
- */
62
- 'widget_text' => array(
63
- 'description' => __( 'Use for widget text:', 'sierotki' ),
64
- 'type' => 'checkbox',
65
- 'label' => __( 'Enabled the substitution of orphans in the widget text.', 'sierotki' ),
66
- 'sanitize_callback' => 'absint',
67
- ),
68
- 'woocommerce_product_title' => array(
69
- 'description' => __( 'Use for WooCommerce product title:', 'sierotki' ),
70
- 'type' => 'checkbox',
71
- 'label' => __( 'Enabled the substitution of orphans in the WooCommerce product title.', 'sierotki' ),
72
- 'sanitize_callback' => 'absint',
73
- ),
74
- 'woocommerce_short_description' => array(
75
- 'description' => __( 'Use for WooCommerce short description:', 'sierotki' ),
76
- 'type' => 'checkbox',
77
- 'label' => __( 'Enabled the substitution of orphans in the WooCommerce short description.', 'sierotki' ),
78
- 'sanitize_callback' => 'absint',
79
- ),
80
- 'numbers' => array(
81
- 'description' => __( 'Keep numbers together:', 'sierotki' ),
82
- 'type' => 'checkbox',
83
- 'label' => __( 'Allow to keep together phone number or strings with space between numbers.', 'sierotki' ),
84
- 'sanitize_callback' => 'absint',
85
- ),
86
- 'own_orphans' => array(
87
- 'description' => __( 'User definied orphans:', 'sierotki' ),
88
- 'type' => 'text',
89
- 'label' => __( 'Use a comma to separate orphans.', 'sierotki' ),
90
- 'sanitize_callback' => 'esc_html',
91
- ),
92
- );
93
  }
94
 
95
  public function replace( $content ) {
 
 
 
96
  if ( empty( $content ) ) {
97
- return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  }
99
 
100
  /**
101
  * Keep numbers together - this is independed of current language
102
  */
103
- $numbers = get_option( 'iworks_orphan_numbers' );
104
- if ( ! empty( $numbers ) ) {
105
  while ( preg_match( '/(\d) (\d)/', $content ) ) {
106
  $content = preg_replace( '/(\d) (\d)/', '$1&nbsp;$2', $content );
107
  }
@@ -112,7 +105,8 @@ class iworks_orphan
112
  *
113
  * @since 2.6.7
114
  */
115
- $apply_to_all_languages = apply_filters( 'iworks_orphan_apply_to_all_languages', false );
 
116
  if ( ! $apply_to_all_languages ) {
117
  /**
118
  * apply other rules only for Polish language
@@ -240,9 +234,9 @@ class iworks_orphan
240
  if ( ! empty( $matches ) && ! empty( $matches[0] ) ) {
241
  $salt = 'kQc6T9fn5GhEzTM3Sxn7b9TWMV4PO0mOCV06Da7AQJzSJqxYR4z3qBlsW9rtFsWK';
242
  foreach ( $matches[0] as $one ) {
243
- $key = sprintf( '<!-- %s %s -->', $salt, md5( $one ) );
244
  $exceptions[ $key ] = $one;
245
- $re = sprintf( '@%s@', preg_replace( '/@/', '\@', $one ) );
246
  $content = preg_replace( $re, $key, $content );
247
  }
248
  }
@@ -289,120 +283,6 @@ class iworks_orphan
289
  return $content;
290
  }
291
 
292
- public function option_page() {
293
- ?>
294
- <div class="wrap">
295
- <h2><?php _e( 'Orphans', 'sierotki' ) ?></h2>
296
- <div class="postbox-container" style="width:75%">
297
- <form method="post" action="options.php">
298
- <?php settings_fields( 'sierotki' ); ?>
299
- <table class="form-table">
300
- <tbody>
301
- <?php
302
- foreach ( $this->options as $filter => $option ) {
303
- /**
304
- * check option type
305
- */
306
- if (
307
- 0
308
- || ! is_array( $option )
309
- || empty( $option )
310
- || ! array_key_exists( 'type', $option )
311
- ) {
312
- continue;
313
- }
314
- $field = 'iworks_orphan_'.$filter;
315
- printf(
316
- '<tr valign="top"><th scope="row">%s</th><td>',
317
- array_key_exists( 'description', $option )? $option['description']:'&nbsp;'
318
- );
319
- switch ( $option['type'] ) {
320
- case 'checkbox':
321
- printf(
322
- '<label for="%s"><input type="checkbox" name="%s" value="1"%s id="%s"/> %s</label>',
323
- $field,
324
- $field,
325
- checked( 1, get_option( $field, 1 ), false ),
326
- $field,
327
- isset( $option['label'] )? $option['label']:'&nbsp;'
328
- );
329
- break;
330
- case 'text':
331
- default:
332
- printf(
333
- '<input type="text" name="%s" value="%s" id="%s" class="regular-text code" />%s',
334
- $field,
335
- get_option( $field, '' ),
336
- $field,
337
- isset( $option['label'] )? '<p class="description">'.$option['label'].'</p>':''
338
- );
339
- break;
340
- }
341
- print '</td></tr>';
342
- }
343
- ?>
344
- </tbody>
345
- </table>
346
- <p class="submit"><input type="submit" class="button-primary" value="<?php _e( 'Save Changes' ) ?>" /></p>
347
- </form>
348
- </div>
349
- <div class="postbox-container" style="width:23%;margin-left:2%">
350
- <div class="metabox-holder">
351
- <div id="links" class="postbox">
352
- <h3 class="hndle"><?php _e( 'Loved this Plugin?', 'sierotki' ); ?></h3>
353
- <div class="inside">
354
- <p><?php _e( 'Below are some links to help spread this plugin to other users', 'sierotki' ); ?></p>
355
- <ul>
356
- <li><a href="http://wordpress.org/extend/plugins/sierotki/"><?php _e( 'Give it a 5 star on Wordpress.org', 'sierotki' ); ?></a></li>
357
- <li><a href="http://wordpress.org/extend/plugins/sierotki/"><?php _e( 'Link to it so others can easily find it', 'sierotki' ); ?></a></li>
358
- </ul>
359
- </div>
360
- </div>
361
- <div id="help" class="postbox">
362
- <h3 class="hndle"><?php _e( 'Need Assistance?', 'sierotki' ); ?></h3>
363
- <div class="inside">
364
- <p><?php _e( 'Problems? The links bellow can be very helpful to you', 'sierotki' ); ?></p>
365
- <ul>
366
- <li><a href="<?php _e( 'http://wordpress.org/support/plugin/sierotki', 'sierotki' ); ?>"><?php _e( 'Wordpress Help Forum', 'sierotki' ); ?></a></li>
367
- <li><a href="mailto:<?php echo antispambot( 'marcin@iworks.pl' ); ?>"><?php echo antispambot( 'marcin@iworks.pl' ); ?></a></li>
368
- </ul>
369
- <hr />
370
- <p class="description"><?php _e( 'Created by: ', 'sierotki' ); ?> <a href="http://iworks.pl/"><span>iWorks.pl</span></a></p>
371
- </div>
372
- </div>
373
- </div>
374
- </div>
375
- </div><?php
376
- }
377
-
378
- private function get_capability() {
379
- return apply_filters( 'iworks_orphans_capability', 'manage_options' );
380
- }
381
-
382
- public function admin_menu() {
383
- if ( function_exists( 'add_theme_page' ) ) {
384
- $this->admin_page = add_theme_page(
385
- __( 'Orphans', 'sierotki' ),
386
- __( 'Orphans', 'sierotki' ),
387
- /**
388
- * Allow to change capability.
389
- *
390
- * This filter allow to change capability which is needed to
391
- * access to Orphans configuration page.
392
- *
393
- * @since 2.6.0
394
- *
395
- * @param string $capability current capability
396
- *
397
- */
398
- $this->get_capability(),
399
- basename( __FILE__ ),
400
- array( $this, 'option_page' )
401
- );
402
- add_action( 'load-'.$this->admin_page, array( $this, 'add_help_tab' ) );
403
- }
404
- }
405
-
406
  public function add_help_tab() {
407
  $screen = get_current_screen();
408
  if ( $screen->id != $this->admin_page ) {
@@ -427,67 +307,48 @@ foreach ( $this->options as $filter => $option ) {
427
  }
428
 
429
  public function admin_init() {
430
- foreach ( $this->options as $filter => $option ) {
431
- $sanitize_callback = isset( $option['sanitize_callback'] )? $option['sanitize_callback']:null;
432
- register_setting( 'sierotki', 'iworks_orphan_'.$filter, $sanitize_callback );
433
- }
434
- add_filter( 'plugin_row_meta', array( $this, 'links' ), 10, 2 );
435
  }
436
 
437
  public function init() {
438
- if ( 0 == get_option( 'iworks_orphan_initialized', 0 ) ) {
439
- foreach ( $this->options as $filter => $option ) {
440
- if ( ! isset( $option['type'] ) ) {
441
- $option['type'] = 'undefinied';
442
- }
443
- switch ( $option['type'] ) {
444
- case 'checkbox':
445
- update_option( 'iworks_orphan_'.$filter, 1 );
446
- break;
447
- case 'text':
448
- default:
449
- update_option( 'iworks_orphan_'.$filter, '' );
450
- break;
451
- }
452
  }
453
- update_option( 'iworks_orphan_initialized', 1 );
454
- }
455
- foreach ( array_keys( $this->options ) as $filter ) {
456
- if ( 1 == get_option( 'iworks_orphan_'.$filter, 1 ) ) {
457
  add_filter( $filter, array( $this, 'replace' ) );
458
  }
459
  }
460
- add_filter( 'iworks_orphan_replace', array( $this, 'replace' ) );
461
- }
462
 
463
- public function links( $links, $file ) {
464
- if ( $file == plugin_basename( __FILE__ ) ) {
465
- if ( ! is_multisite() ) {
466
- $dir = explode( '/', dirname( __FILE__ ) );
467
- $dir = $dir[ count( $dir ) - 1 ];
468
- $links[] = '<a href="themes.php?page='.$dir.'.php">' . __( 'Settings' ) . '</a>';
 
 
 
 
469
  }
470
- $links[] = '<a href="http://iworks.pl/donate/sierotki.php">' . __( 'Donate' ) . '</a>';
471
  }
472
- return $links;
473
- }
474
 
475
- /**
476
- * Change the admin footer text on Orphans admin pages.
477
- *
478
- * @since 2.3
479
- * @param string $footer_text
480
- * @return string
481
- */
482
- public function admin_footer_text( $footer_text ) {
483
- if ( ! current_user_can( $this->get_capability() ) ) {
484
- return;
485
- }
486
- $screen = get_current_screen();
487
- if ( ! preg_match( '/page_orphan$/', $screen->id ) ) {
488
- return;
489
- }
490
- return sprintf( __( 'If you like <strong>Orphans</strong> please leave us a %s&#9733;&#9733;&#9733;&#9733;&#9733;%s rating. A huge thanks in advance!', 'sierotki' ), '<a href="https://wordpress.org/support/plugin/sierotki/reviews/?rate=5#new-post" target="_blank">', '</a>' );
491
  }
492
 
493
  /**
@@ -501,4 +362,50 @@ foreach ( $this->options as $filter => $option ) {
501
  printf( '.iworks-notice-sierotki .iworks-notice-logo{background-color:#fed696;background-image:url(%s);}', esc_url( $logo ) );
502
  echo '</style>';
503
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
504
  }
1
  <?php
2
+ /*
3
+
4
+ Copyright 2011-2017 Marcin Pietrzak (marcin@iworks.pl)
5
+
6
+ this program is free software; you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License, version 2, as
8
+ published by the Free Software Foundation.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License
16
+ along with this program; if not, write to the Free Software
17
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
+
19
+ */
20
+
21
  class iworks_orphan
22
  {
23
  private $options;
24
  private $admin_page;
25
+ private $settings;
26
+ private $plugin_file;
27
+
28
+ public function __construct( $file ) {
29
+ /**
30
+ * plugin ID
31
+ */
32
+ $this->plugin_file = plugin_basename( $file );
33
 
 
34
  /**
35
  * l10n
36
  */
37
+ load_plugin_textdomain( 'sierotki', false, dirname( $this->plugin_file ).'/languages' );
38
+
39
+ /**
40
+ * options
41
+ */
42
+ $this->options = get_orphan_options();
43
 
44
  /**
45
  * actions
46
  */
47
  add_action( 'init', array( $this, 'init' ) );
48
  add_action( 'admin_init', array( $this, 'admin_init' ) );
 
49
  add_action( 'iworks_rate_css', array( $this, 'iworks_rate_css' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  }
51
 
52
  public function replace( $content ) {
53
+ /**
54
+ * do not replace empty content
55
+ */
56
  if ( empty( $content ) ) {
57
+ return $content;
58
+ }
59
+ /**
60
+ * we do not need this in admin
61
+ */
62
+ if ( is_admin() ) {
63
+ return $content;
64
+ }
65
+ /**
66
+ * check post type
67
+ */
68
+ $entry_related_filters = array( 'the_title', 'the_excerpt', 'the_content' );
69
+ $current_filter = current_filter();
70
+
71
+ if ( in_array( $current_filter, $entry_related_filters ) ) {
72
+ if ( empty( $this->settings['post_type'] ) || ! is_array( $this->settings['post_type'] ) ) {
73
+ return $content;
74
+ }
75
+ global $post;
76
+ if ( ! in_array( $post->post_type, $this->settings['post_type'] ) ) {
77
+ return $content;
78
+ }
79
+ }
80
+ /**
81
+ * check taxonomy
82
+ */
83
+ if ( 'term_description' == $current_filter ) {
84
+ if ( empty( $this->settings['taxonomies'] ) || ! is_array( $this->settings['taxonomies'] ) ) {
85
+ return $content;
86
+ }
87
+ $queried_object = get_queried_object();
88
+ if ( ! in_array( $queried_object->taxonomy, $this->settings['taxonomies'] ) ) {
89
+ return $content;
90
+ }
91
  }
92
 
93
  /**
94
  * Keep numbers together - this is independed of current language
95
  */
96
+ $numbers = $this->is_on( 'numbers' );
97
+ if ( $numbers ) {
98
  while ( preg_match( '/(\d) (\d)/', $content ) ) {
99
  $content = preg_replace( '/(\d) (\d)/', '$1&nbsp;$2', $content );
100
  }
105
  *
106
  * @since 2.6.7
107
  */
108
+ $all_languages = $this->is_on( 'ignore_language' );
109
+ $apply_to_all_languages = apply_filters( 'iworks_orphan_apply_to_all_languages', $all_languages );
110
  if ( ! $apply_to_all_languages ) {
111
  /**
112
  * apply other rules only for Polish language
234
  if ( ! empty( $matches ) && ! empty( $matches[0] ) ) {
235
  $salt = 'kQc6T9fn5GhEzTM3Sxn7b9TWMV4PO0mOCV06Da7AQJzSJqxYR4z3qBlsW9rtFsWK';
236
  foreach ( $matches[0] as $one ) {
237
+ $key = sprintf( '<!-- %s %s -->', $salt, md5( $one ) );
238
  $exceptions[ $key ] = $one;
239
+ $re = sprintf( '@%s@', preg_replace( '/@/', '\@', preg_quote( $one, '/' ) ) );
240
  $content = preg_replace( $re, $key, $content );
241
  }
242
  }
283
  return $content;
284
  }
285
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
286
  public function add_help_tab() {
287
  $screen = get_current_screen();
288
  if ( $screen->id != $this->admin_page ) {
307
  }
308
 
309
  public function admin_init() {
310
+ $this->options->options_init();
311
+ /** This filter is documented in wp-admin/includes/class-wp-plugins-list-table.php */
312
+ add_filter( 'plugin_row_meta', array( $this, 'add_donate_link' ), 10, 2 );
313
+ /** This filter is documented in wp-admin/includes/class-wp-plugins-list-table.php */
314
+ add_filter( 'plugin_action_links', array( $this, 'add_settings_link' ), 10, 2 );
315
  }
316
 
317
  public function init() {
318
+ $this->settings = $this->options->get_all_options();
319
+ $allowed_filters = array(
320
+ 'the_title',
321
+ 'the_excerpt',
322
+ 'the_content',
323
+ 'comment_text',
324
+ 'widget_title',
325
+ 'widget_text',
326
+ 'term_description',
327
+ 'get_the_author_description',
328
+ );
329
+ foreach ( $this->settings as $filter => $value ) {
330
+ if ( ! in_array( $filter, $allowed_filters ) ) {
331
+ continue;
332
  }
333
+ if ( is_integer( $value ) && 1 == $value ) {
 
 
 
334
  add_filter( $filter, array( $this, 'replace' ) );
335
  }
336
  }
 
 
337
 
338
+ /**
339
+ * taxonomies
340
+ */
341
+ if ( 1 == $this->settings['taxonomy_title'] && ! empty( $this->settings['taxonomies'] ) ) {
342
+ add_filter( 'single_term_title', array( $this, 'replace' ) );
343
+ if ( in_array( 'category', $this->settings['taxonomies'] ) ) {
344
+ add_filter( 'single_cat_title', array( $this, 'replace' ) );
345
+ }
346
+ if ( in_array( 'post_tag', $this->settings['taxonomies'] ) ) {
347
+ add_filter( 'single_tag_title', array( $this, 'replace' ) );
348
  }
 
349
  }
 
 
350
 
351
+ add_filter( 'iworks_orphan_replace', array( $this, 'replace' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
352
  }
353
 
354
  /**
362
  printf( '.iworks-notice-sierotki .iworks-notice-logo{background-color:#fed696;background-image:url(%s);}', esc_url( $logo ) );
363
  echo '</style>';
364
  }
365
+
366
+
367
+ private function is_on( $key ) {
368
+ return isset( $this->settings[ $key ] ) && 1 === $this->settings[ $key ];
369
+ }
370
+
371
+ /**
372
+ * Add settings link to plugin_action_links.
373
+ *
374
+ * @since 2.6.8
375
+ *
376
+ * @param array $actions An array of plugin action links.
377
+ * @param string $plugin_file Path to the plugin file relative to the plugins directory.
378
+ */
379
+ public function add_settings_link( $actions, $plugin_file ) {
380
+ if ( is_multisite() ) {
381
+ return $actions;
382
+ }
383
+ if ( $plugin_file == $this->plugin_file ) {
384
+ $page = $this->options->get_pagehook();
385
+ $url = add_query_arg( 'page', $page, admin_url( 'themes.php' ) );
386
+ $url = sprintf( '<a href="%s">%s</a>', esc_url( $url ), esc_html__( 'Settings', 'sierotki' ) );
387
+ $settings = array( $url );
388
+ $actions = array_merge( $settings, $actions );
389
+ }
390
+ return $actions;
391
+ }
392
+
393
+ /**
394
+ * Add donate link to plugin_row_meta.
395
+ *
396
+ * @since 2.6.8
397
+ *
398
+ * @param array $plugin_meta An array of the plugin's metadata,
399
+ * including the version, author,
400
+ * author URI, and plugin URI.
401
+ * @param string $plugin_file Path to the plugin file, relative to the plugins directory.
402
+ */
403
+ public function add_donate_link( $plugin_meta, $plugin_file ) {
404
+
405
+ if ( $plugin_file == $this->plugin_file ) {
406
+ $plugin_meta[] = '<a href="http://iworks.pl/donate/sierotki.php">' . __( 'Donate', 'sierotki' ) . '</a>';
407
+ }
408
+
409
+ return $plugin_meta;
410
+ }
411
  }