Passed
Push — master ( 1d60eb...03dff3 )
by Stiofan
06:44 queued 03:02
created
includes/class-wpinv-notes.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
     exit; // Exit if accessed directly
4 4
 }
5 5
 
@@ -14,74 +14,74 @@  discard block
 block discarded – undo
14 14
     }
15 15
     
16 16
     public function init() {
17
-        do_action( 'wpinv_class_notes_init', $this );
17
+        do_action('wpinv_class_notes_init', $this);
18 18
     }
19 19
     
20 20
     public function includes() {
21
-        do_action( 'wpinv_class_notes_includes', $this );
21
+        do_action('wpinv_class_notes_includes', $this);
22 22
     }
23 23
     
24 24
     public function actions() {
25 25
         // Secure inovice notes
26
-        add_action( 'pre_get_comments', array( $this, 'set_invoice_note_type' ), 11, 1 );
27
-        add_action( 'comment_feed_where', array( $this, 'wpinv_comment_feed_where' ), 10, 1 );
26
+        add_action('pre_get_comments', array($this, 'set_invoice_note_type'), 11, 1);
27
+        add_action('comment_feed_where', array($this, 'wpinv_comment_feed_where'), 10, 1);
28 28
         
29 29
         // Count comments
30
-        add_filter( 'wp_count_comments', array( $this, 'wp_count_comments' ), 11, 2 );
30
+        add_filter('wp_count_comments', array($this, 'wp_count_comments'), 11, 2);
31 31
         
32 32
         // Delete comments count cache whenever there is a new comment or a comment status changes
33
-        add_action( 'wp_insert_comment', array( $this, 'delete_comments_count_cache' ) );
34
-        add_action( 'wp_set_comment_status', array( $this, 'delete_comments_count_cache' ) );
33
+        add_action('wp_insert_comment', array($this, 'delete_comments_count_cache'));
34
+        add_action('wp_set_comment_status', array($this, 'delete_comments_count_cache'));
35 35
         
36
-        do_action( 'wpinv_class_notes_actions', $this );
36
+        do_action('wpinv_class_notes_actions', $this);
37 37
     }
38 38
         
39
-    public function set_invoice_note_type( $query ) {
40
-        $post_ID        = !empty( $query->query_vars['post_ID'] ) ? $query->query_vars['post_ID'] : $query->query_vars['post_id'];
39
+    public function set_invoice_note_type($query) {
40
+        $post_ID = !empty($query->query_vars['post_ID']) ? $query->query_vars['post_ID'] : $query->query_vars['post_id'];
41 41
         
42
-        if ( $post_ID && in_array(get_post_type( $post_ID ), array($this->invoice_post_type, 'wpi_quote' )) ) {
42
+        if ($post_ID && in_array(get_post_type($post_ID), array($this->invoice_post_type, 'wpi_quote'))) {
43 43
             $query->query_vars['type__in']      = $this->comment_type;
44 44
             $query->query_vars['type__not_in']  = '';
45 45
         } else {        
46
-            if ( isset( $query->query_vars['type__in'] ) && $type_in = $query->query_vars['type__in'] ) {
47
-                if ( is_array( $type_in ) && in_array( $this->comment_type, $type_in ) ) {
48
-                    $key = array_search( $this->comment_type, $type_in );
49
-                    unset( $query->query_vars['type__in'][$key] );
50
-                } else if ( !is_array( $type_in ) && $type_in == $this->comment_type ) {
46
+            if (isset($query->query_vars['type__in']) && $type_in = $query->query_vars['type__in']) {
47
+                if (is_array($type_in) && in_array($this->comment_type, $type_in)) {
48
+                    $key = array_search($this->comment_type, $type_in);
49
+                    unset($query->query_vars['type__in'][$key]);
50
+                } else if (!is_array($type_in) && $type_in == $this->comment_type) {
51 51
                     $query->query_vars['type__in'] = '';
52 52
                 }
53 53
             }
54 54
             
55
-            if ( isset( $query->query_vars['type__not_in'] ) && $type_not_in = $query->query_vars['type__not_in'] ) {
56
-                if ( is_array( $type_not_in ) && !in_array( $this->comment_type, $type_not_in ) ) {
55
+            if (isset($query->query_vars['type__not_in']) && $type_not_in = $query->query_vars['type__not_in']) {
56
+                if (is_array($type_not_in) && !in_array($this->comment_type, $type_not_in)) {
57 57
                     $query->query_vars['type__not_in'][] = $this->comment_type;
58
-                } else if ( !is_array( $type_not_in ) && $type_not_in != $this->comment_type ) {
58
+                } else if (!is_array($type_not_in) && $type_not_in != $this->comment_type) {
59 59
                     $query->query_vars['type__not_in'] = (array)$query->query_vars['type__not_in'];
60 60
                     $query->query_vars['type__not_in'][] = $this->comment_type;
61 61
                 }
62 62
             } else {
63
-                $query->query_vars['type__not_in']  = $this->comment_type;
63
+                $query->query_vars['type__not_in'] = $this->comment_type;
64 64
             }
65 65
         }
66 66
         
67 67
         return $query;
68 68
     }
69 69
     
70
-    public function get_invoice_notes( $invoice_id = 0, $type = '' ) {
70
+    public function get_invoice_notes($invoice_id = 0, $type = '') {
71 71
         $args = array( 
72 72
             'post_id'   => $invoice_id,
73 73
             'orderby'   => 'comment_ID',
74 74
             'order'     => 'ASC',
75 75
         );
76 76
         
77
-        if ( $type == 'customer' ) {
77
+        if ($type == 'customer') {
78 78
             $args['meta_key']   = '_wpi_customer_note';
79 79
             $args['meta_value'] = 1;
80 80
         }
81 81
         
82
-        $args   = apply_filters( 'wpinv_invoice_notes_args', $args, $this, $invoice_id, $type );
82
+        $args = apply_filters('wpinv_invoice_notes_args', $args, $this, $invoice_id, $type);
83 83
         
84
-        return get_comments( $args );
84
+        return get_comments($args);
85 85
     }
86 86
     
87 87
     /**
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
      * @return void
93 93
      */
94 94
     public function delete_comments_count_cache() {
95
-        delete_transient( 'wpinv_count_comments' );
95
+        delete_transient('wpinv_count_comments');
96 96
     }
97 97
     
98 98
     /**
@@ -103,16 +103,16 @@  discard block
 block discarded – undo
103 103
      * @param  int    $post_id Post ID.
104 104
      * @return object
105 105
      */
106
-    public function wp_count_comments( $stats, $post_id ) {
106
+    public function wp_count_comments($stats, $post_id) {
107 107
         global $wpdb;
108 108
 
109
-        if ( 0 === $post_id ) {
110
-            $stats = get_transient( 'wpinv_count_comments' );
109
+        if (0 === $post_id) {
110
+            $stats = get_transient('wpinv_count_comments');
111 111
 
112
-            if ( ! $stats ) {
112
+            if (!$stats) {
113 113
                 $stats = array();
114 114
 
115
-                $count = $wpdb->get_results( "SELECT comment_approved, COUNT(*) AS num_comments FROM {$wpdb->comments} WHERE comment_type NOT IN ('" . $this->comment_type . "') GROUP BY comment_approved", ARRAY_A );
115
+                $count = $wpdb->get_results("SELECT comment_approved, COUNT(*) AS num_comments FROM {$wpdb->comments} WHERE comment_type NOT IN ('" . $this->comment_type . "') GROUP BY comment_approved", ARRAY_A);
116 116
 
117 117
                 $total = 0;
118 118
                 $approved = array(
@@ -123,33 +123,33 @@  discard block
 block discarded – undo
123 123
                     'post-trashed' => 'post-trashed',
124 124
                 );
125 125
 
126
-                foreach ( (array) $count as $row ) {
126
+                foreach ((array)$count as $row) {
127 127
                     // Do not count post-trashed toward totals.
128
-                    if ( 'post-trashed' !== $row['comment_approved'] && 'trash' !== $row['comment_approved'] ) {
128
+                    if ('post-trashed' !== $row['comment_approved'] && 'trash' !== $row['comment_approved']) {
129 129
                         $total += $row['num_comments'];
130 130
                     }
131
-                    if ( isset( $approved[ $row['comment_approved'] ] ) ) {
132
-                        $stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments'];
131
+                    if (isset($approved[$row['comment_approved']])) {
132
+                        $stats[$approved[$row['comment_approved']]] = $row['num_comments'];
133 133
                     }
134 134
                 }
135 135
 
136 136
                 $stats['total_comments'] = $total;
137 137
                 $stats['all'] = $total;
138
-                foreach ( $approved as $key ) {
139
-                    if ( empty( $stats[ $key ] ) ) {
140
-                        $stats[ $key ] = 0;
138
+                foreach ($approved as $key) {
139
+                    if (empty($stats[$key])) {
140
+                        $stats[$key] = 0;
141 141
                     }
142 142
                 }
143 143
 
144
-                $stats = (object) $stats;
145
-                set_transient( 'wpinv_count_comments', $stats );
144
+                $stats = (object)$stats;
145
+                set_transient('wpinv_count_comments', $stats);
146 146
             }
147 147
         }
148 148
 
149 149
         return $stats;
150 150
     }
151 151
 
152
-    function wpinv_comment_feed_where($where){
153
-        return $where . ( $where ? ' AND ' : '' ) . " comment_type != 'wpinv_note' ";
152
+    function wpinv_comment_feed_where($where) {
153
+        return $where . ($where ? ' AND ' : '') . " comment_type != 'wpinv_note' ";
154 154
     }
155 155
 }
Please login to merge, or discard this patch.
includes/admin/wpinv-upgrade-functions.php 1 patch
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -11,49 +11,49 @@  discard block
 block discarded – undo
11 11
  * @since 1.0.0
12 12
 */
13 13
 function wpinv_automatic_upgrade() {
14
-    $wpi_version = get_option( 'wpinv_version' );
14
+    $wpi_version = get_option('wpinv_version');
15 15
 
16
-    if ( $wpi_version == WPINV_VERSION ) {
16
+    if ($wpi_version == WPINV_VERSION) {
17 17
         return;
18 18
     }
19 19
     
20
-    if ( version_compare( $wpi_version, '0.0.5', '<' ) ) {
20
+    if (version_compare($wpi_version, '0.0.5', '<')) {
21 21
         wpinv_v005_upgrades();
22 22
     }
23 23
     
24
-    if ( version_compare( $wpi_version, '1.0.3', '<' ) ) {
24
+    if (version_compare($wpi_version, '1.0.3', '<')) {
25 25
         wpinv_v110_upgrades();
26 26
     }
27 27
     
28
-    update_option( 'wpinv_version', WPINV_VERSION );
28
+    update_option('wpinv_version', WPINV_VERSION);
29 29
 }
30
-add_action( 'admin_init', 'wpinv_automatic_upgrade' );
30
+add_action('admin_init', 'wpinv_automatic_upgrade');
31 31
 
32 32
 function wpinv_v005_upgrades() {
33 33
     global $wpdb;
34 34
     
35 35
     // Invoices status
36
-    $results = $wpdb->get_results( "SELECT ID FROM " . $wpdb->posts . " WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
37
-    if ( !empty( $results ) ) {
38
-        $wpdb->query( "UPDATE " . $wpdb->posts . " SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
36
+    $results = $wpdb->get_results("SELECT ID FROM " . $wpdb->posts . " WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )");
37
+    if (!empty($results)) {
38
+        $wpdb->query("UPDATE " . $wpdb->posts . " SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )");
39 39
         
40 40
         // Clean post cache
41
-        foreach ( $results as $row ) {
42
-            clean_post_cache( $row->ID );
41
+        foreach ($results as $row) {
42
+            clean_post_cache($row->ID);
43 43
         }
44 44
     }
45 45
     
46 46
     // Item meta key changes
47 47
     $query = "SELECT DISTINCT post_id FROM " . $wpdb->postmeta . " WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id', '_wpinv_cpt_name', '_wpinv_cpt_singular_name' )";
48
-    $results = $wpdb->get_results( $query );
48
+    $results = $wpdb->get_results($query);
49 49
     
50
-    if ( !empty( $results ) ) {
51
-        $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" );
52
-        $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" );
53
-        $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" );
50
+    if (!empty($results)) {
51
+        $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )");
52
+        $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'");
53
+        $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'");
54 54
         
55
-        foreach ( $results as $row ) {
56
-            clean_post_cache( $row->post_id );
55
+        foreach ($results as $row) {
56
+            clean_post_cache($row->post_id);
57 57
         }
58 58
     }
59 59
 
@@ -74,79 +74,79 @@  discard block
 block discarded – undo
74 74
 function wpinv_convert_old_subscriptions() {
75 75
     global $wpdb;
76 76
 
77
-    $query = "SELECT ". $wpdb->posts .".ID FROM ". $wpdb->posts ." INNER JOIN ". $wpdb->postmeta ." ON ( ". $wpdb->posts .".ID = ". $wpdb->postmeta .".post_id ) WHERE 1=1  AND ". $wpdb->postmeta .".meta_key = '_wpinv_subscr_status' AND (". $wpdb->postmeta .".meta_value = 'pending' OR ". $wpdb->postmeta .".meta_value = 'active' OR ". $wpdb->postmeta .".meta_value = 'cancelled' OR ". $wpdb->postmeta .".meta_value = 'completed' OR ". $wpdb->postmeta .".meta_value = 'expired' OR ". $wpdb->postmeta .".meta_value = 'trialling' OR ". $wpdb->postmeta .".meta_value = 'failing') AND ". $wpdb->posts .".post_type = 'wpi_invoice' GROUP BY ". $wpdb->posts .".ID ORDER BY ". $wpdb->posts .".ID ASC";
77
+    $query = "SELECT " . $wpdb->posts . ".ID FROM " . $wpdb->posts . " INNER JOIN " . $wpdb->postmeta . " ON ( " . $wpdb->posts . ".ID = " . $wpdb->postmeta . ".post_id ) WHERE 1=1  AND " . $wpdb->postmeta . ".meta_key = '_wpinv_subscr_status' AND (" . $wpdb->postmeta . ".meta_value = 'pending' OR " . $wpdb->postmeta . ".meta_value = 'active' OR " . $wpdb->postmeta . ".meta_value = 'cancelled' OR " . $wpdb->postmeta . ".meta_value = 'completed' OR " . $wpdb->postmeta . ".meta_value = 'expired' OR " . $wpdb->postmeta . ".meta_value = 'trialling' OR " . $wpdb->postmeta . ".meta_value = 'failing') AND " . $wpdb->posts . ".post_type = 'wpi_invoice' GROUP BY " . $wpdb->posts . ".ID ORDER BY " . $wpdb->posts . ".ID ASC";
78 78
 
79
-    $results = $wpdb->get_results( $query );
79
+    $results = $wpdb->get_results($query);
80 80
 
81
-    if ( empty( $results ) ) {
81
+    if (empty($results)) {
82 82
         return;
83 83
     }
84 84
 
85
-    foreach ( $results as $row ) {
86
-        $invoice = new WPInv_Invoice( $row->ID );
85
+    foreach ($results as $row) {
86
+        $invoice = new WPInv_Invoice($row->ID);
87 87
 
88
-        if ( empty( $invoice->ID ) ) {
88
+        if (empty($invoice->ID)) {
89 89
             continue;
90 90
         }
91 91
 
92
-        if ( $invoice->has_status( 'wpi-renewal' ) ) {
92
+        if ($invoice->has_status('wpi-renewal')) {
93 93
             continue;
94 94
         }
95 95
         
96
-        $item = $invoice->get_recurring( true );
96
+        $item = $invoice->get_recurring(true);
97 97
 
98
-        if ( empty( $item ) ) {
98
+        if (empty($item)) {
99 99
             continue;
100 100
         }
101 101
 
102 102
         $is_free_trial          = $invoice->is_free_trial();
103
-        $profile_id             = get_post_meta( $invoice->ID, '_wpinv_subscr_profile_id', true );
104
-        $subscription_status    = get_post_meta( $invoice->ID, '_wpinv_subscr_status', true );
103
+        $profile_id             = get_post_meta($invoice->ID, '_wpinv_subscr_profile_id', true);
104
+        $subscription_status    = get_post_meta($invoice->ID, '_wpinv_subscr_status', true);
105 105
         $transaction_id         = $invoice->get_transaction_id();
106 106
 
107 107
         // Last invoice
108
-        $query          = "SELECT ID, post_date FROM ". $wpdb->posts ." WHERE post_type = 'wpi_invoice' AND post_parent = '" . $invoice->ID . "' ORDER BY ID DESC LIMIT 1";
109
-        $last_payment   = $wpdb->get_row( $query );
108
+        $query          = "SELECT ID, post_date FROM " . $wpdb->posts . " WHERE post_type = 'wpi_invoice' AND post_parent = '" . $invoice->ID . "' ORDER BY ID DESC LIMIT 1";
109
+        $last_payment   = $wpdb->get_row($query);
110 110
 
111
-        if ( !empty( $last_payment ) ) {
112
-            $invoice_date       = $last_payment->post_date;
111
+        if (!empty($last_payment)) {
112
+            $invoice_date = $last_payment->post_date;
113 113
             
114
-            $meta_profile_id     = get_post_meta( $last_payment->ID, '_wpinv_subscr_profile_id', true );
115
-            $meta_transaction_id = get_post_meta( $last_payment->ID, '_wpinv_transaction_id', true );
114
+            $meta_profile_id     = get_post_meta($last_payment->ID, '_wpinv_subscr_profile_id', true);
115
+            $meta_transaction_id = get_post_meta($last_payment->ID, '_wpinv_transaction_id', true);
116 116
 
117
-            if ( !empty( $meta_profile_id ) ) {
118
-                $profile_id  = $meta_profile_id;
117
+            if (!empty($meta_profile_id)) {
118
+                $profile_id = $meta_profile_id;
119 119
             }
120 120
 
121
-            if ( !empty( $meta_transaction_id ) ) {
122
-                $transaction_id  = $meta_transaction_id;
121
+            if (!empty($meta_transaction_id)) {
122
+                $transaction_id = $meta_transaction_id;
123 123
             }
124 124
         } else {
125
-            $invoice_date       = $invoice->get_invoice_date( false );
125
+            $invoice_date       = $invoice->get_invoice_date(false);
126 126
         }
127 127
         
128
-        $profile_id             = empty( $profile_id ) ? $invoice->ID : $profile_id;
129
-        $status                 = empty( $subscription_status ) ? 'pending' : $subscription_status;
128
+        $profile_id             = empty($profile_id) ? $invoice->ID : $profile_id;
129
+        $status                 = empty($subscription_status) ? 'pending' : $subscription_status;
130 130
         
131
-        $period                 = $item->get_recurring_period( true );
131
+        $period                 = $item->get_recurring_period(true);
132 132
         $interval               = $item->get_recurring_interval();
133 133
         $bill_times             = (int)$item->get_recurring_limit();
134 134
         $add_period             = $interval . ' ' . $period;
135 135
         $trial_period           = '';
136 136
 
137
-        if ( $invoice->is_free_trial() ) {
138
-            $trial_period       = $item->get_trial_period( true );
137
+        if ($invoice->is_free_trial()) {
138
+            $trial_period       = $item->get_trial_period(true);
139 139
             $free_interval      = $item->get_trial_interval();
140 140
             $trial_period       = $free_interval . ' ' . $trial_period;
141 141
 
142
-            if ( empty( $last_payment ) ) {
142
+            if (empty($last_payment)) {
143 143
                 $add_period     = $trial_period;
144 144
             }
145 145
         }
146 146
 
147
-        $expiration             = date_i18n( 'Y-m-d H:i:s', strtotime( '+' . $add_period  . ' 23:59:59', strtotime( $invoice_date ) ) );
148
-        if ( strtotime( $expiration ) <  strtotime( date_i18n( 'Y-m-d' ) ) ) {
149
-            if ( $status == 'active' || $status == 'trialling' || $status == 'pending' ) {
147
+        $expiration = date_i18n('Y-m-d H:i:s', strtotime('+' . $add_period . ' 23:59:59', strtotime($invoice_date)));
148
+        if (strtotime($expiration) < strtotime(date_i18n('Y-m-d'))) {
149
+            if ($status == 'active' || $status == 'trialling' || $status == 'pending') {
150 150
                 $status = 'expired';
151 151
             }
152 152
         }
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
             'frequency'         => $interval,
160 160
             'period'            => $period,
161 161
             'initial_amount'    => $invoice->get_total(),
162
-            'recurring_amount'  => $invoice->get_recurring_details( 'total' ),
162
+            'recurring_amount'  => $invoice->get_recurring_details('total'),
163 163
             'bill_times'        => $bill_times,
164 164
             'created'           => $invoice_date,
165 165
             'expiration'        => $expiration,
@@ -169,14 +169,14 @@  discard block
 block discarded – undo
169 169
         );
170 170
 
171 171
         $subs_db      = new WPInv_Subscriptions_DB;
172
-        $subs         = $subs_db->get_subscriptions( array( 'parent_payment_id' => $invoice->ID, 'number' => 1 ) );
173
-        $subscription = reset( $subs );
172
+        $subs         = $subs_db->get_subscriptions(array('parent_payment_id' => $invoice->ID, 'number' => 1));
173
+        $subscription = reset($subs);
174 174
 
175
-        if ( empty( $subscription ) || $subscription->id <= 0 ) {
175
+        if (empty($subscription) || $subscription->id <= 0) {
176 176
             $subscription = new WPInv_Subscription();
177
-            $new_sub = $subscription->create( $args );
177
+            $new_sub = $subscription->create($args);
178 178
 
179
-            if ( !empty( $bill_times ) && $new_sub->get_times_billed() >= $bill_times && ( 'active' == $new_sub->status || 'trialling' == $new_sub->status ) ) {
179
+            if (!empty($bill_times) && $new_sub->get_times_billed() >= $bill_times && ('active' == $new_sub->status || 'trialling' == $new_sub->status)) {
180 180
                 $new_sub->complete(); // Mark completed if all times billed
181 181
             }
182 182
         }
@@ -186,20 +186,20 @@  discard block
 block discarded – undo
186 186
 function wpinv_update_new_email_settings() {
187 187
     global $wpinv_options;
188 188
 
189
-    $current_options = get_option( 'wpinv_settings', array() );
189
+    $current_options = get_option('wpinv_settings', array());
190 190
     $options = array(
191
-        'email_new_invoice_body' => __( '<p>Hi Admin,</p><p>You have received payment invoice from {name}.</p>', 'invoicing' ),
192
-        'email_cancelled_invoice_body' => __( '<p>Hi Admin,</p><p>The invoice #{invoice_number} from {site_title} has been cancelled.</p>', 'invoicing' ),
193
-        'email_failed_invoice_body' => __( '<p>Hi Admin,</p><p>Payment for invoice #{invoice_number} from {site_title} has been failed.</p>', 'invoicing' ),
194
-        'email_onhold_invoice_body' => __( '<p>Hi {name},</p><p>Your invoice is on-hold until we confirm your payment has been received.</p>', 'invoicing' ),
195
-        'email_processing_invoice_body' => __( '<p>Hi {name},</p><p>Your invoice has been received at {site_title} and is now being processed.</p>', 'invoicing' ),
196
-        'email_refunded_invoice_body' => __( '<p>Hi {name},</p><p>Your invoice on {site_title} has been refunded.</p>', 'invoicing' ),
197
-        'email_user_invoice_body' => __( '<p>Hi {name},</p><p>An invoice has been created for you on {site_title}. To view / pay for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing' ),
198
-        'email_user_note_body' => __( '<p>Hi {name},</p><p>Following note has been added to your {invoice_label}:</p><blockquote class="wpinv-note">{customer_note}</blockquote>', 'invoicing' ),
199
-        'email_overdue_body' => __( '<p>Hi {full_name},</p><p>This is just a friendly reminder that your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing' ),
191
+        'email_new_invoice_body' => __('<p>Hi Admin,</p><p>You have received payment invoice from {name}.</p>', 'invoicing'),
192
+        'email_cancelled_invoice_body' => __('<p>Hi Admin,</p><p>The invoice #{invoice_number} from {site_title} has been cancelled.</p>', 'invoicing'),
193
+        'email_failed_invoice_body' => __('<p>Hi Admin,</p><p>Payment for invoice #{invoice_number} from {site_title} has been failed.</p>', 'invoicing'),
194
+        'email_onhold_invoice_body' => __('<p>Hi {name},</p><p>Your invoice is on-hold until we confirm your payment has been received.</p>', 'invoicing'),
195
+        'email_processing_invoice_body' => __('<p>Hi {name},</p><p>Your invoice has been received at {site_title} and is now being processed.</p>', 'invoicing'),
196
+        'email_refunded_invoice_body' => __('<p>Hi {name},</p><p>Your invoice on {site_title} has been refunded.</p>', 'invoicing'),
197
+        'email_user_invoice_body' => __('<p>Hi {name},</p><p>An invoice has been created for you on {site_title}. To view / pay for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing'),
198
+        'email_user_note_body' => __('<p>Hi {name},</p><p>Following note has been added to your {invoice_label}:</p><blockquote class="wpinv-note">{customer_note}</blockquote>', 'invoicing'),
199
+        'email_overdue_body' => __('<p>Hi {full_name},</p><p>This is just a friendly reminder that your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing'),
200 200
     );
201 201
 
202
-    foreach ($options as $option => $value){
202
+    foreach ($options as $option => $value) {
203 203
         if (!isset($current_options[$option])) {
204 204
             $current_options[$option] = $value;
205 205
         }
@@ -207,5 +207,5 @@  discard block
 block discarded – undo
207 207
 
208 208
     $wpinv_options = $current_options;
209 209
 
210
-    update_option( 'wpinv_settings', $current_options );
210
+    update_option('wpinv_settings', $current_options);
211 211
 }
212 212
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-mb-invoice-items.php 1 patch
Spacing   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -1,47 +1,47 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7 7
 class WPInv_Meta_Box_Items {
8
-    public static function output( $post ) {
8
+    public static function output($post) {
9 9
         global $wpinv_euvat, $ajax_cart_details;
10 10
 
11
-        $post_id            = !empty( $post->ID ) ? $post->ID : 0;
12
-        $invoice            = new WPInv_Invoice( $post_id );
11
+        $post_id            = !empty($post->ID) ? $post->ID : 0;
12
+        $invoice            = new WPInv_Invoice($post_id);
13 13
         $ajax_cart_details  = $invoice->get_cart_details();
14
-        $subtotal           = $invoice->get_subtotal( true );
14
+        $subtotal           = $invoice->get_subtotal(true);
15 15
         $discount_raw       = $invoice->get_discount();
16
-        $discount           = wpinv_price( $discount_raw, $invoice->get_currency() );
16
+        $discount           = wpinv_price($discount_raw, $invoice->get_currency());
17 17
         $discounts          = $discount_raw > 0 ? $invoice->get_discounts() : '';
18
-        $tax                = $invoice->get_tax( true );
19
-        $total              = $invoice->get_total( true );
18
+        $tax                = $invoice->get_tax(true);
19
+        $total              = $invoice->get_total(true);
20 20
         $item_quantities    = wpinv_item_quantities_enabled();
21 21
         $use_taxes          = wpinv_use_taxes();
22
-        if ( !$use_taxes && (float)$invoice->get_tax() > 0 ) {
22
+        if (!$use_taxes && (float)$invoice->get_tax() > 0) {
23 23
             $use_taxes = true;
24 24
         }
25
-        $item_types         = apply_filters( 'wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post );
25
+        $item_types         = apply_filters('wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post);
26 26
         $is_recurring       = $invoice->is_recurring();
27 27
         $post_type_object   = get_post_type_object($invoice->post_type);
28 28
         $type_title         = $post_type_object->labels->singular_name;
29 29
 
30 30
         $cols = 5;
31
-        if ( $item_quantities ) {
31
+        if ($item_quantities) {
32 32
             $cols++;
33 33
         }
34
-        if ( $use_taxes ) {
34
+        if ($use_taxes) {
35 35
             $cols++;
36 36
         }
37 37
         $class = '';
38
-        if ( $invoice->is_paid() ) {
38
+        if ($invoice->is_paid()) {
39 39
             $class .= ' wpinv-paid';
40 40
         }
41
-        if ( $invoice->is_refunded() ) {
41
+        if ($invoice->is_refunded()) {
42 42
             $class .= ' wpinv-refunded';
43 43
         }
44
-        if ( $is_recurring ) {
44
+        if ($is_recurring) {
45 45
             $class .= ' wpi-recurring';
46 46
         }
47 47
         ?>
@@ -49,21 +49,21 @@  discard block
 block discarded – undo
49 49
             <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0">
50 50
                 <thead>
51 51
                     <tr>
52
-                        <th class="id"><?php _e( 'ID', 'invoicing' );?></th>
53
-                        <th class="title"><?php _e( 'Item', 'invoicing' );?></th>
54
-                        <th class="price"><?php _e( 'Price', 'invoicing' );?></th>
55
-                        <?php if ( $item_quantities ) { ?>
56
-                        <th class="qty"><?php _e( 'Qty', 'invoicing' );?></th>
52
+                        <th class="id"><?php _e('ID', 'invoicing'); ?></th>
53
+                        <th class="title"><?php _e('Item', 'invoicing'); ?></th>
54
+                        <th class="price"><?php _e('Price', 'invoicing'); ?></th>
55
+                        <?php if ($item_quantities) { ?>
56
+                        <th class="qty"><?php _e('Qty', 'invoicing'); ?></th>
57 57
                         <?php } ?>
58
-                        <th class="total"><?php _e( 'Total', 'invoicing' );?></th>
59
-                        <?php if ( $use_taxes ) { ?>
60
-                        <th class="tax"><?php _e( 'Tax (%)', 'invoicing' );?></th>
58
+                        <th class="total"><?php _e('Total', 'invoicing'); ?></th>
59
+                        <?php if ($use_taxes) { ?>
60
+                        <th class="tax"><?php _e('Tax (%)', 'invoicing'); ?></th>
61 61
                         <?php } ?>
62 62
                         <th class="action"></th>
63 63
                     </tr>
64 64
                 </thead>
65 65
                 <tbody class="wpinv-line-items">
66
-                    <?php echo wpinv_admin_get_line_items( $invoice ); ?>
66
+                    <?php echo wpinv_admin_get_line_items($invoice); ?>
67 67
                 </tbody>
68 68
                 <tfoot class="wpinv-totals">
69 69
                     <tr>
@@ -74,45 +74,45 @@  discard block
 block discarded – undo
74 74
                                         <td class="id">
75 75
                                         </td>
76 76
                                         <td class="title">
77
-                                            <input type="text" class="regular-text" placeholder="<?php _e( 'Item Name', 'invoicing' ); ?>" value="" name="_wpinv_quick[name]">
78
-                                            <?php if ( $wpinv_euvat->allow_vat_rules() ) { ?>
77
+                                            <input type="text" class="regular-text" placeholder="<?php _e('Item Name', 'invoicing'); ?>" value="" name="_wpinv_quick[name]">
78
+                                            <?php if ($wpinv_euvat->allow_vat_rules()) { ?>
79 79
                                             <div class="wp-clearfix">
80 80
                                                 <label class="wpi-vat-rule">
81
-                                                    <span class="title"><?php _e( 'VAT rule type', 'invoicing' );?></span>
81
+                                                    <span class="title"><?php _e('VAT rule type', 'invoicing'); ?></span>
82 82
                                                     <span class="input-text-wrap">
83
-                                                        <?php echo wpinv_html_select( array(
83
+                                                        <?php echo wpinv_html_select(array(
84 84
                                                             'options'          => $wpinv_euvat->get_rules(),
85 85
                                                             'name'             => '_wpinv_quick[vat_rule]',
86 86
                                                             'id'               => '_wpinv_quick_vat_rule',
87 87
                                                             'show_option_all'  => false,
88 88
                                                             'show_option_none' => false,
89 89
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-vat-rule',
90
-                                                        ) ); ?>
90
+                                                        )); ?>
91 91
                                                     </span>
92 92
                                                 </label>
93 93
                                             </div>
94
-                                            <?php } if ( $wpinv_euvat->allow_vat_classes() ) { ?>
94
+                                            <?php } if ($wpinv_euvat->allow_vat_classes()) { ?>
95 95
                                             <div class="wp-clearfix">
96 96
                                                 <label class="wpi-vat-class">
97
-                                                    <span class="title"><?php _e( 'VAT class', 'invoicing' );?></span>
97
+                                                    <span class="title"><?php _e('VAT class', 'invoicing'); ?></span>
98 98
                                                     <span class="input-text-wrap">
99
-                                                        <?php echo wpinv_html_select( array(
99
+                                                        <?php echo wpinv_html_select(array(
100 100
                                                             'options'          => $wpinv_euvat->get_all_classes(),
101 101
                                                             'name'             => '_wpinv_quick[vat_class]',
102 102
                                                             'id'               => '_wpinv_quick_vat_class',
103 103
                                                             'show_option_all'  => false,
104 104
                                                             'show_option_none' => false,
105 105
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-vat-class',
106
-                                                        ) ); ?>
106
+                                                        )); ?>
107 107
                                                     </span>
108 108
                                                 </label>
109 109
                                             </div>
110 110
                                             <?php } ?>
111 111
                                             <div class="wp-clearfix">
112 112
                                                 <label class="wpi-item-type">
113
-                                                    <span class="title"><?php _e( 'Item type', 'invoicing' );?></span>
113
+                                                    <span class="title"><?php _e('Item type', 'invoicing'); ?></span>
114 114
                                                     <span class="input-text-wrap">
115
-                                                        <?php echo wpinv_html_select( array(
115
+                                                        <?php echo wpinv_html_select(array(
116 116
                                                             'options'          => $item_types,
117 117
                                                             'name'             => '_wpinv_quick[type]',
118 118
                                                             'id'               => '_wpinv_quick_type',
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
                                                             'show_option_all'  => false,
121 121
                                                             'show_option_none' => false,
122 122
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-type',
123
-                                                        ) ); ?>
123
+                                                        )); ?>
124 124
                                                     </span>
125 125
                                                 </label>
126 126
                                             </div>
@@ -133,11 +133,11 @@  discard block
 block discarded – undo
133 133
                                             </div>
134 134
                                         </td>
135 135
                                         <td class="price"><input type="text" placeholder="0.00" class="wpi-field-price wpi-price" name="_wpinv_quick[price]" /></td>
136
-                                        <?php if ( $item_quantities ) { ?>
136
+                                        <?php if ($item_quantities) { ?>
137 137
                                         <td class="qty"><input type="number" class="small-text" step="1" min="1" value="1" name="_wpinv_quick[qty]" /></td>
138 138
                                         <?php } ?>
139 139
                                         <td class="total"></td>
140
-                                        <?php if ( $use_taxes ) { ?>
140
+                                        <?php if ($use_taxes) { ?>
141 141
                                         <td class="tax"></td>
142 142
                                         <?php } ?>
143 143
                                         <td class="action"></td>
@@ -150,29 +150,29 @@  discard block
 block discarded – undo
150 150
                         <td colspan="<?php echo $cols; ?>"></td>
151 151
                     </tr>
152 152
                     <tr class="totals">
153
-                        <td colspan="<?php echo ( $cols - 4 ); ?>"></td>
153
+                        <td colspan="<?php echo ($cols - 4); ?>"></td>
154 154
                         <td colspan="4">
155 155
                             <table cellspacing="0" cellpadding="0">
156 156
                                 <tr class="subtotal">
157
-                                    <td class="name"><?php _e( 'Sub Total:', 'invoicing' );?></td>
158
-                                    <td class="total"><?php echo $subtotal;?></td>
157
+                                    <td class="name"><?php _e('Sub Total:', 'invoicing'); ?></td>
158
+                                    <td class="total"><?php echo $subtotal; ?></td>
159 159
                                     <td class="action"></td>
160 160
                                 </tr>
161 161
                                 <tr class="discount">
162
-                                    <td class="name"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice->ID ) ); ?>:</td>
163
-                                    <td class="total"><?php echo wpinv_discount( $invoice->ID, true, true ); ?></td>
162
+                                    <td class="name"><?php wpinv_get_discount_label(wpinv_discount_code($invoice->ID)); ?>:</td>
163
+                                    <td class="total"><?php echo wpinv_discount($invoice->ID, true, true); ?></td>
164 164
                                     <td class="action"></td>
165 165
                                 </tr>
166
-                                <?php if ( $use_taxes ) { ?>
166
+                                <?php if ($use_taxes) { ?>
167 167
                                 <tr class="tax">
168
-                                    <td class="name"><?php _e( 'Tax:', 'invoicing' );?></td>
169
-                                    <td class="total"><?php echo $tax;?></td>
168
+                                    <td class="name"><?php _e('Tax:', 'invoicing'); ?></td>
169
+                                    <td class="total"><?php echo $tax; ?></td>
170 170
                                     <td class="action"></td>
171 171
                                 </tr>
172 172
                                 <?php } ?>
173 173
                                 <tr class="total">
174
-                                    <td class="name"><?php echo apply_filters( 'wpinv_invoice_items_total_label', __( 'Invoice Total:', 'invoicing' ), $invoice );?></td>
175
-                                    <td class="total"><?php echo $total;?></td>
174
+                                    <td class="name"><?php echo apply_filters('wpinv_invoice_items_total_label', __('Invoice Total:', 'invoicing'), $invoice); ?></td>
175
+                                    <td class="total"><?php echo $total; ?></td>
176 176
                                     <td class="action"></td>
177 177
                                 </tr>
178 178
                             </table>
@@ -183,89 +183,89 @@  discard block
 block discarded – undo
183 183
             <div class="wpinv-actions">
184 184
                 <?php ob_start(); ?>
185 185
                 <?php
186
-                    if ( !$invoice->is_paid() && !$invoice->is_refunded() ) {
187
-                        if ( !$invoice->is_recurring() ) {
188
-                            echo wpinv_item_dropdown( array(
186
+                    if (!$invoice->is_paid() && !$invoice->is_refunded()) {
187
+                        if (!$invoice->is_recurring()) {
188
+                            echo wpinv_item_dropdown(array(
189 189
                                 'name'             => 'wpinv_invoice_item',
190 190
                                 'id'               => 'wpinv_invoice_item',
191 191
                                 'show_recurring'   => true,
192
-                            ) );
192
+                            ));
193 193
                     ?>
194
-                <input type="button" value="<?php echo sprintf(esc_attr__( 'Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e( 'Create new item', 'invoicing' );?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e( 'Recalculate Totals', 'invoicing' );?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals">
194
+                <input type="button" value="<?php echo sprintf(esc_attr__('Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e('Create new item', 'invoicing'); ?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e('Recalculate Totals', 'invoicing'); ?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals">
195 195
                     <?php } ?>
196
-                <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?>
197
-                <?php $item_actions = ob_get_clean(); echo apply_filters( 'wpinv_invoice_items_actions_content', $item_actions, $invoice, $post ); ?>
196
+                <?php do_action('wpinv_invoice_items_actions', $invoice); ?>
197
+                <?php $item_actions = ob_get_clean(); echo apply_filters('wpinv_invoice_items_actions_content', $item_actions, $invoice, $post); ?>
198 198
             </div>
199 199
         </div>
200 200
         <?php
201 201
     }
202 202
 
203
-    public static function prices( $post ) {        
203
+    public static function prices($post) {        
204 204
         $symbol         = wpinv_currency_symbol();
205 205
         $position       = wpinv_currency_position();
206
-        $item           = new WPInv_Item( $post->ID );
206
+        $item           = new WPInv_Item($post->ID);
207 207
 
208 208
         $price          = $item->get_price();
209 209
         $is_recurring   = $item->is_recurring();
210 210
         $period         = $item->get_recurring_period();
211
-        $interval       = absint( $item->get_recurring_interval() );
212
-        $times          = absint( $item->get_recurring_limit() );
211
+        $interval       = absint($item->get_recurring_interval());
212
+        $times          = absint($item->get_recurring_limit());
213 213
         $free_trial     = $item->has_free_trial();
214 214
         $trial_interval = $item->get_trial_interval();
215 215
         $trial_period   = $item->get_trial_period();
216 216
 
217 217
         $intervals      = array();
218
-        for ( $i = 1; $i <= 90; $i++ ) {
218
+        for ($i = 1; $i <= 90; $i++) {
219 219
             $intervals[$i] = $i;
220 220
         }
221 221
 
222
-        $interval       = $interval > 0 ? $interval : 1;
222
+        $interval = $interval > 0 ? $interval : 1;
223 223
 
224 224
         $class = $is_recurring ? 'wpinv-recurring-y' : 'wpinv-recurring-n';
225 225
         ?>
226
-        <p class="wpinv-row-prices"><?php echo ( $position != 'right' ? $symbol . '&nbsp;' : '' );?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount( 0 ); ?>" value="<?php echo $price;?>" id="wpinv_item_price" name="wpinv_item_price" class="medium-text wpi-field-price wpi-price" <?php disabled( $item->is_editable(), false ); ?> /><?php echo ( $position == 'right' ? '&nbsp;' . $symbol : '' );?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce( 'wpinv_item_meta_box_save' ) ;?>" />
227
-        <?php do_action( 'wpinv_prices_metabox_price', $item ); ?>
226
+        <p class="wpinv-row-prices"><?php echo ($position != 'right' ? $symbol . '&nbsp;' : ''); ?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount(0); ?>" value="<?php echo $price; ?>" id="wpinv_item_price" name="wpinv_item_price" class="medium-text wpi-field-price wpi-price" <?php disabled($item->is_editable(), false); ?> /><?php echo ($position == 'right' ? '&nbsp;' . $symbol : ''); ?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce('wpinv_item_meta_box_save'); ?>" />
227
+        <?php do_action('wpinv_prices_metabox_price', $item); ?>
228 228
         </p>
229 229
         <p class="wpinv-row-is-recurring">
230 230
             <label for="wpinv_is_recurring">
231
-                <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked( 1, $is_recurring ); ?> />
232
-                <?php echo apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Is Recurring Item?', 'invoicing' ) ); ?>
231
+                <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked(1, $is_recurring); ?> />
232
+                <?php echo apply_filters('wpinv_is_recurring_toggle_text', __('Is Recurring Item?', 'invoicing')); ?>
233 233
             </label>
234
-            <?php do_action( 'wpinv_prices_metabox_is_recurring_field', $item ); ?>
234
+            <?php do_action('wpinv_prices_metabox_is_recurring_field', $item); ?>
235 235
         </p>
236
-        <p class="wpinv-row-recurring-fields <?php echo $class;?>">
237
-            <label class="wpinv-period" for="wpinv_recurring_period"><?php _e( 'Recurring', 'invoicing' );?> <select class="wpinv-select " id="wpinv_recurring_period" name="wpinv_recurring_period"><option value="D" data-text="<?php esc_attr_e( 'day(s)', 'invoicing' ); ?>" <?php selected( 'D', $period );?>><?php _e( 'Daily', 'invoicing' ); ?></option><option value="W" data-text="<?php esc_attr_e( 'week(s)', 'invoicing' ); ?>" <?php selected( 'W', $period );?>><?php _e( 'Weekly', 'invoicing' ); ?></option><option value="M" data-text="<?php esc_attr_e( 'month(s)', 'invoicing' ); ?>" <?php selected( 'M', $period );?>><?php _e( 'Monthly', 'invoicing' ); ?></option><option value="Y" data-text="<?php esc_attr_e( 'year(s)', 'invoicing' ); ?>" <?php selected( 'Y', $period );?>><?php _e( 'Yearly', 'invoicing' ); ?></option></select></label>
238
-            <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e( 'at every', 'invoicing' );?> <?php echo wpinv_html_select( array(
236
+        <p class="wpinv-row-recurring-fields <?php echo $class; ?>">
237
+            <label class="wpinv-period" for="wpinv_recurring_period"><?php _e('Recurring', 'invoicing'); ?> <select class="wpinv-select " id="wpinv_recurring_period" name="wpinv_recurring_period"><option value="D" data-text="<?php esc_attr_e('day(s)', 'invoicing'); ?>" <?php selected('D', $period); ?>><?php _e('Daily', 'invoicing'); ?></option><option value="W" data-text="<?php esc_attr_e('week(s)', 'invoicing'); ?>" <?php selected('W', $period); ?>><?php _e('Weekly', 'invoicing'); ?></option><option value="M" data-text="<?php esc_attr_e('month(s)', 'invoicing'); ?>" <?php selected('M', $period); ?>><?php _e('Monthly', 'invoicing'); ?></option><option value="Y" data-text="<?php esc_attr_e('year(s)', 'invoicing'); ?>" <?php selected('Y', $period); ?>><?php _e('Yearly', 'invoicing'); ?></option></select></label>
238
+            <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e('at every', 'invoicing'); ?> <?php echo wpinv_html_select(array(
239 239
                 'options'          => $intervals,
240 240
                 'name'             => 'wpinv_recurring_interval',
241 241
                 'id'               => 'wpinv_recurring_interval',
242 242
                 'selected'         => $interval,
243 243
                 'show_option_all'  => false,
244 244
                 'show_option_none' => false
245
-            ) ); ?> <span id="wpinv_interval_text"><?php _e( 'day(s)', 'invoicing' );?></span></label>
246
-            <label class="wpinv-times" for="wpinv_recurring_limit"> <?php _e( 'for', 'invoicing' );?> <input class="small-text" type="number" value="<?php echo $times;?>" size="4" id="wpinv_recurring_limit" name="wpinv_recurring_limit" step="1" min="0"> <?php _e( 'time(s) <i>(select 0 for recurring forever until cancelled</i>)', 'invoicing' );?></label>
245
+            )); ?> <span id="wpinv_interval_text"><?php _e('day(s)', 'invoicing'); ?></span></label>
246
+            <label class="wpinv-times" for="wpinv_recurring_limit"> <?php _e('for', 'invoicing'); ?> <input class="small-text" type="number" value="<?php echo $times; ?>" size="4" id="wpinv_recurring_limit" name="wpinv_recurring_limit" step="1" min="0"> <?php _e('time(s) <i>(select 0 for recurring forever until cancelled</i>)', 'invoicing'); ?></label>
247 247
             <span class="clear wpi-trial-clr"></span>
248 248
             <label class="wpinv-free-trial" for="wpinv_free_trial">
249
-                <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked( true, (bool)$free_trial ); ?> /> 
250
-                <?php echo __( 'Offer free trial for', 'invoicing' ); ?>
249
+                <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked(true, (bool)$free_trial); ?> /> 
250
+                <?php echo __('Offer free trial for', 'invoicing'); ?>
251 251
             </label>
252 252
             <label class="wpinv-trial-interval" for="wpinv_trial_interval">
253
-                <input class="small-text" type="number" value="<?php echo $trial_interval;?>" size="4" id="wpinv_trial_interval" name="wpinv_trial_interval" step="1" min="1"> <select class="wpinv-select" id="wpinv_trial_period" name="wpinv_trial_period"><option value="D" <?php selected( 'D', $trial_period );?>><?php _e( 'day(s)', 'invoicing' ); ?></option><option value="W" <?php selected( 'W', $trial_period );?>><?php _e( 'week(s)', 'invoicing' ); ?></option><option value="M" <?php selected( 'M', $trial_period );?>><?php _e( 'month(s)', 'invoicing' ); ?></option><option value="Y" <?php selected( 'Y', $trial_period );?>><?php _e( 'year(s)', 'invoicing' ); ?></option></select>
253
+                <input class="small-text" type="number" value="<?php echo $trial_interval; ?>" size="4" id="wpinv_trial_interval" name="wpinv_trial_interval" step="1" min="1"> <select class="wpinv-select" id="wpinv_trial_period" name="wpinv_trial_period"><option value="D" <?php selected('D', $trial_period); ?>><?php _e('day(s)', 'invoicing'); ?></option><option value="W" <?php selected('W', $trial_period); ?>><?php _e('week(s)', 'invoicing'); ?></option><option value="M" <?php selected('M', $trial_period); ?>><?php _e('month(s)', 'invoicing'); ?></option><option value="Y" <?php selected('Y', $trial_period); ?>><?php _e('year(s)', 'invoicing'); ?></option></select>
254 254
             </label>
255
-            <?php do_action( 'wpinv_prices_metabox_recurring_fields', $item ); ?>
255
+            <?php do_action('wpinv_prices_metabox_recurring_fields', $item); ?>
256 256
         </p>
257
-        <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type( $post->ID ); ?>" />
258
-        <?php do_action( 'wpinv_item_price_field', $post->ID ); ?>
257
+        <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type($post->ID); ?>" />
258
+        <?php do_action('wpinv_item_price_field', $post->ID); ?>
259 259
         <?php
260 260
     }
261 261
 
262
-    public static function vat_rules( $post ) {
262
+    public static function vat_rules($post) {
263 263
         global $wpinv_euvat;
264 264
 
265
-        $rule_type = $wpinv_euvat->get_item_rule( $post->ID );
265
+        $rule_type = $wpinv_euvat->get_item_rule($post->ID);
266 266
         ?>
267
-        <p><label for="wpinv_vat_rules"><strong><?php _e( 'Select how VAT rules will be applied:', 'invoicing' );?></strong></label>&nbsp;&nbsp;&nbsp;
268
-        <?php echo wpinv_html_select( array(
267
+        <p><label for="wpinv_vat_rules"><strong><?php _e('Select how VAT rules will be applied:', 'invoicing'); ?></strong></label>&nbsp;&nbsp;&nbsp;
268
+        <?php echo wpinv_html_select(array(
269 269
                     'options'          => $wpinv_euvat->get_rules(),
270 270
                     'name'             => 'wpinv_vat_rules',
271 271
                     'id'               => 'wpinv_vat_rules',
@@ -273,19 +273,19 @@  discard block
 block discarded – undo
273 273
                     'show_option_all'  => false,
274 274
                     'show_option_none' => false,
275 275
                     'class'            => 'gdmbx2-text-medium wpinv-vat-rules',
276
-                ) ); ?>
276
+                )); ?>
277 277
         </p>
278
-        <p class="wpi-m0"><?php _e( 'When you select physical product rules, only consumers and businesses in your country will be charged VAT.  The VAT rate used will be the rate in your country.', 'invoicing' ); ?></p>
279
-        <p class="wpi-m0"><?php _e( 'If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer.  Only businesses in your country will be charged VAT.', 'invoicing' ); ?></p>
278
+        <p class="wpi-m0"><?php _e('When you select physical product rules, only consumers and businesses in your country will be charged VAT.  The VAT rate used will be the rate in your country.', 'invoicing'); ?></p>
279
+        <p class="wpi-m0"><?php _e('If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer.  Only businesses in your country will be charged VAT.', 'invoicing'); ?></p>
280 280
         <?php
281 281
     }
282 282
 
283
-    public static function vat_classes( $post ) {
283
+    public static function vat_classes($post) {
284 284
         global $wpinv_euvat;
285 285
         
286
-        $vat_class = $wpinv_euvat->get_item_class( $post->ID );
286
+        $vat_class = $wpinv_euvat->get_item_class($post->ID);
287 287
         ?>
288
-        <p><?php echo wpinv_html_select( array(
288
+        <p><?php echo wpinv_html_select(array(
289 289
                     'options'          => $wpinv_euvat->get_all_classes(),
290 290
                     'name'             => 'wpinv_vat_class',
291 291
                     'id'               => 'wpinv_vat_class',
@@ -293,18 +293,18 @@  discard block
 block discarded – undo
293 293
                     'show_option_all'  => false,
294 294
                     'show_option_none' => false,
295 295
                     'class'            => 'gdmbx2-text-medium wpinv-vat-class',
296
-                ) ); ?>
296
+                )); ?>
297 297
         </p>
298
-        <p class="wpi-m0"><?php _e( 'Select the VAT rate class to use for this invoice item.', 'invoicing' ); ?></p>
298
+        <p class="wpi-m0"><?php _e('Select the VAT rate class to use for this invoice item.', 'invoicing'); ?></p>
299 299
         <?php
300 300
     }
301 301
 
302
-    public static function item_info( $post ) {
303
-        $item_type = wpinv_get_item_type( $post->ID );
304
-        do_action( 'wpinv_item_info_metabox_before', $post );
302
+    public static function item_info($post) {
303
+        $item_type = wpinv_get_item_type($post->ID);
304
+        do_action('wpinv_item_info_metabox_before', $post);
305 305
         ?>
306
-        <p><label for="wpinv_item_type"><strong><?php _e( 'Type:', 'invoicing' );?></strong></label>&nbsp;&nbsp;&nbsp;
307
-        <?php echo wpinv_html_select( array(
306
+        <p><label for="wpinv_item_type"><strong><?php _e('Type:', 'invoicing'); ?></strong></label>&nbsp;&nbsp;&nbsp;
307
+        <?php echo wpinv_html_select(array(
308 308
                     'options'          => wpinv_get_item_types(),
309 309
                     'name'             => 'wpinv_item_type',
310 310
                     'id'               => 'wpinv_item_type',
@@ -312,114 +312,114 @@  discard block
 block discarded – undo
312 312
                     'show_option_all'  => false,
313 313
                     'show_option_none' => false,
314 314
                     'class'            => 'gdmbx2-text-medium wpinv-item-type',
315
-                ) ); ?>
315
+                )); ?>
316 316
         </p>
317
-        <p class="wpi-m0"><?php _e( 'Select item type.', 'invoicing' );?><br><?php _e( '<b>Standard:</b> Standard item type', 'invoicing' );?><br><?php _e( '<b>Fee:</b> Like Registration Fee, Sign up Fee etc.', 'invoicing' );?></p>
317
+        <p class="wpi-m0"><?php _e('Select item type.', 'invoicing'); ?><br><?php _e('<b>Standard:</b> Standard item type', 'invoicing'); ?><br><?php _e('<b>Fee:</b> Like Registration Fee, Sign up Fee etc.', 'invoicing'); ?></p>
318 318
         <?php
319
-        do_action( 'wpinv_item_info_metabox_after', $post );
319
+        do_action('wpinv_item_info_metabox_after', $post);
320 320
     }
321 321
 
322
-    public static function meta_values( $post ) {
323
-        $meta_keys = apply_filters( 'wpinv_show_meta_values_for_keys', array(
322
+    public static function meta_values($post) {
323
+        $meta_keys = apply_filters('wpinv_show_meta_values_for_keys', array(
324 324
             'type',
325 325
             'custom_id'
326
-        ) );
326
+        ));
327 327
 
328
-        if ( empty( $meta_keys ) ) {
328
+        if (empty($meta_keys)) {
329 329
             return;
330 330
         }
331 331
 
332
-        do_action( 'wpinv_meta_values_metabox_before', $post );
332
+        do_action('wpinv_meta_values_metabox_before', $post);
333 333
 
334
-        foreach ( $meta_keys as $meta_key ) {
334
+        foreach ($meta_keys as $meta_key) {
335 335
             ?>
336
-            <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta( $post->ID, '_wpinv_' . $meta_key, true ); ?></label></p>
336
+            <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta($post->ID, '_wpinv_' . $meta_key, true); ?></label></p>
337 337
             <?php 
338 338
         }
339 339
 
340
-        do_action( 'wpinv_meta_values_metabox_after', $post );
340
+        do_action('wpinv_meta_values_metabox_after', $post);
341 341
     }
342 342
 
343
-    public static function save( $post_id, $data, $post ) {
344
-        $invoice        = new WPInv_Invoice( $post_id );
343
+    public static function save($post_id, $data, $post) {
344
+        $invoice        = new WPInv_Invoice($post_id);
345 345
 
346 346
         // Billing
347
-        $first_name     = sanitize_text_field( $data['wpinv_first_name'] );
348
-        $last_name      = sanitize_text_field( $data['wpinv_last_name'] );
349
-        $company        = sanitize_text_field( $data['wpinv_company'] );
350
-        $vat_number     = sanitize_text_field( $data['wpinv_vat_number'] );
351
-        $phone          = sanitize_text_field( $data['wpinv_phone'] );
352
-        $address        = sanitize_text_field( $data['wpinv_address'] );
353
-        $city           = sanitize_text_field( $data['wpinv_city'] );
354
-        $zip            = sanitize_text_field( $data['wpinv_zip'] );
355
-        $country        = sanitize_text_field( $data['wpinv_country'] );
356
-        $state          = sanitize_text_field( $data['wpinv_state'] );
347
+        $first_name     = sanitize_text_field($data['wpinv_first_name']);
348
+        $last_name      = sanitize_text_field($data['wpinv_last_name']);
349
+        $company        = sanitize_text_field($data['wpinv_company']);
350
+        $vat_number     = sanitize_text_field($data['wpinv_vat_number']);
351
+        $phone          = sanitize_text_field($data['wpinv_phone']);
352
+        $address        = sanitize_text_field($data['wpinv_address']);
353
+        $city           = sanitize_text_field($data['wpinv_city']);
354
+        $zip            = sanitize_text_field($data['wpinv_zip']);
355
+        $country        = sanitize_text_field($data['wpinv_country']);
356
+        $state          = sanitize_text_field($data['wpinv_state']);
357 357
 
358 358
         // Details
359
-        $status         = sanitize_text_field( $data['wpinv_status'] );
360
-        $old_status     = !empty( $data['original_post_status'] ) ? sanitize_text_field( $data['original_post_status'] ) : $status;
361
-        $number         = sanitize_text_field( $data['wpinv_number'] );
362
-        $due_date       = isset( $data['wpinv_due_date'] ) ? sanitize_text_field( $data['wpinv_due_date'] ) : '';
359
+        $status         = sanitize_text_field($data['wpinv_status']);
360
+        $old_status     = !empty($data['original_post_status']) ? sanitize_text_field($data['original_post_status']) : $status;
361
+        $number         = sanitize_text_field($data['wpinv_number']);
362
+        $due_date       = isset($data['wpinv_due_date']) ? sanitize_text_field($data['wpinv_due_date']) : '';
363 363
         //$discounts      = sanitize_text_field( $data['wpinv_discounts'] );
364 364
         //$discount       = sanitize_text_field( $data['wpinv_discount'] );
365 365
 
366
-        $ip             = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip();
366
+        $ip = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip();
367 367
 
368
-        $invoice->set( 'due_date', $due_date );
369
-        $invoice->set( 'first_name', $first_name );
370
-        $invoice->set( 'last_name', $last_name );
371
-        $invoice->set( 'company', $company );
372
-        $invoice->set( 'vat_number', $vat_number );
373
-        $invoice->set( 'phone', $phone );
374
-        $invoice->set( 'address', $address );
375
-        $invoice->set( 'city', $city );
376
-        $invoice->set( 'zip', $zip );
377
-        $invoice->set( 'country', $country );
378
-        $invoice->set( 'state', $state );
379
-        $invoice->set( 'status', $status );
368
+        $invoice->set('due_date', $due_date);
369
+        $invoice->set('first_name', $first_name);
370
+        $invoice->set('last_name', $last_name);
371
+        $invoice->set('company', $company);
372
+        $invoice->set('vat_number', $vat_number);
373
+        $invoice->set('phone', $phone);
374
+        $invoice->set('address', $address);
375
+        $invoice->set('city', $city);
376
+        $invoice->set('zip', $zip);
377
+        $invoice->set('country', $country);
378
+        $invoice->set('state', $state);
379
+        $invoice->set('status', $status);
380 380
         //$invoice->set( 'number', $number );
381 381
         //$invoice->set( 'discounts', $discounts );
382 382
         //$invoice->set( 'discount', $discount );
383
-        $invoice->set( 'ip', $ip );
383
+        $invoice->set('ip', $ip);
384 384
         $invoice->old_status = $_POST['original_post_status'];
385 385
         $invoice->currency = wpinv_get_currency();
386
-        if ( !empty( $data['wpinv_gateway'] ) ) {
387
-            $invoice->set( 'gateway', sanitize_text_field( $data['wpinv_gateway'] ) );
386
+        if (!empty($data['wpinv_gateway'])) {
387
+            $invoice->set('gateway', sanitize_text_field($data['wpinv_gateway']));
388 388
         }
389 389
         $saved = $invoice->save();
390 390
 
391 391
         // Check for payment notes
392
-        if ( !empty( $data['invoice_note'] ) ) {
393
-            $note               = wp_kses( $data['invoice_note'], array() );
394
-            $note_type          = sanitize_text_field( $data['invoice_note_type'] );
392
+        if (!empty($data['invoice_note'])) {
393
+            $note               = wp_kses($data['invoice_note'], array());
394
+            $note_type          = sanitize_text_field($data['invoice_note_type']);
395 395
             $is_customer_note   = $note_type == 'customer' ? 1 : 0;
396 396
 
397
-            wpinv_insert_payment_note( $invoice->ID, $note, $is_customer_note );
397
+            wpinv_insert_payment_note($invoice->ID, $note, $is_customer_note);
398 398
         }
399 399
 
400 400
         // Update user address if empty.
401
-        if ( $saved && !empty( $invoice ) ) {
402
-            if ( $user_id = $invoice->get_user_id() ) {
403
-                $user_address = wpinv_get_user_address( $user_id, false );
401
+        if ($saved && !empty($invoice)) {
402
+            if ($user_id = $invoice->get_user_id()) {
403
+                $user_address = wpinv_get_user_address($user_id, false);
404 404
 
405 405
                 if (empty($user_address['first_name'])) {
406
-                    update_user_meta( $user_id, '_wpinv_first_name', $first_name );
407
-                    update_user_meta( $user_id, '_wpinv_last_name', $last_name );
406
+                    update_user_meta($user_id, '_wpinv_first_name', $first_name);
407
+                    update_user_meta($user_id, '_wpinv_last_name', $last_name);
408 408
                 } else if (empty($user_address['last_name']) && $user_address['first_name'] == $first_name) {
409
-                    update_user_meta( $user_id, '_wpinv_last_name', $last_name );
409
+                    update_user_meta($user_id, '_wpinv_last_name', $last_name);
410 410
                 }
411 411
 
412 412
                 if (empty($user_address['address']) || empty($user_address['city']) || empty($user_address['state']) || empty($user_address['country'])) {
413
-                    update_user_meta( $user_id, '_wpinv_address', $address );
414
-                    update_user_meta( $user_id, '_wpinv_city', $city );
415
-                    update_user_meta( $user_id, '_wpinv_state', $state );
416
-                    update_user_meta( $user_id, '_wpinv_country', $country );
417
-                    update_user_meta( $user_id, '_wpinv_zip', $zip );
418
-                    update_user_meta( $user_id, '_wpinv_phone', $phone );
413
+                    update_user_meta($user_id, '_wpinv_address', $address);
414
+                    update_user_meta($user_id, '_wpinv_city', $city);
415
+                    update_user_meta($user_id, '_wpinv_state', $state);
416
+                    update_user_meta($user_id, '_wpinv_country', $country);
417
+                    update_user_meta($user_id, '_wpinv_zip', $zip);
418
+                    update_user_meta($user_id, '_wpinv_phone', $phone);
419 419
                 }
420 420
             }
421 421
 
422
-            do_action( 'wpinv_invoice_metabox_saved', $invoice );
422
+            do_action('wpinv_invoice_metabox_saved', $invoice);
423 423
         }
424 424
 
425 425
         return $saved;
Please login to merge, or discard this patch.
includes/admin/class-wpinv-users.php 2 patches
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 class WPInv_Admin_Users {
15 15
     private static $instance;
16 16
     
17 17
     public static function run() {
18
-        if ( !isset( self::$instance ) && !( self::$instance instanceof WPInv_Admin_Users ) ) {
18
+        if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Admin_Users)) {
19 19
             self::$instance = new WPInv_Admin_Users;
20 20
         }
21 21
 
@@ -23,8 +23,8 @@  discard block
 block discarded – undo
23 23
     }
24 24
     
25 25
     public function __construct() {
26
-        add_filter( 'manage_users_columns', array( $this, 'wpinv_add_user_column') );
27
-        add_filter( 'manage_users_custom_column', array( $this, 'wpinv_user_column_content') , 10, 3 );
26
+        add_filter('manage_users_columns', array($this, 'wpinv_add_user_column'));
27
+        add_filter('manage_users_custom_column', array($this, 'wpinv_user_column_content'), 10, 3);
28 28
     }
29 29
 
30 30
     /**
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
34 34
      *
35 35
      * @return mixed
36 36
      */
37
-    public function wpinv_add_user_column( $column ) {
38
-        $column['wpinvoicing'] = __('Invoicing','invoicing');
37
+    public function wpinv_add_user_column($column) {
38
+        $column['wpinvoicing'] = __('Invoicing', 'invoicing');
39 39
         return $column;
40 40
     }
41 41
 
@@ -48,10 +48,10 @@  discard block
 block discarded – undo
48 48
      *
49 49
      * @return string
50 50
      */
51
-    function wpinv_user_column_content( $val, $column_name, $user_id ) {
51
+    function wpinv_user_column_content($val, $column_name, $user_id) {
52 52
         switch ($column_name) {
53 53
             case 'wpinvoicing' :
54
-                return $this->get_user_invoices( $user_id );
54
+                return $this->get_user_invoices($user_id);
55 55
                 break;
56 56
             default:
57 57
         }
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
      *
66 66
      * @return string
67 67
      */
68
-    public function get_user_invoices($user_id){
68
+    public function get_user_invoices($user_id) {
69 69
         $output = '';
70 70
         $wp_query_args = array(
71 71
             'post_type'      => 'wpi_invoice',
@@ -74,14 +74,14 @@  discard block
 block discarded – undo
74 74
             'fields'         => 'ids',
75 75
             'author'         => $user_id,
76 76
         );
77
-        $invoices = new WP_Query( $wp_query_args );
78
-        $count = absint( $invoices->found_posts );
77
+        $invoices = new WP_Query($wp_query_args);
78
+        $count = absint($invoices->found_posts);
79 79
 
80
-        if(empty($count)){
81
-            $output .= __('No Invoice(s)','invoicing');
82
-        }else{
83
-            $link_url = admin_url( "edit.php?post_type=wpi_invoice&author=".absint($user_id) );
84
-            $link_text = sprintf( __('Invoices ( %d )', 'invoicing'), $count );
80
+        if (empty($count)) {
81
+            $output .= __('No Invoice(s)', 'invoicing');
82
+        } else {
83
+            $link_url = admin_url("edit.php?post_type=wpi_invoice&author=" . absint($user_id));
84
+            $link_text = sprintf(__('Invoices ( %d )', 'invoicing'), $count);
85 85
             $output .= "<a href='$link_url' >$link_text</a>";
86 86
         }
87 87
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@
 block discarded – undo
79 79
 
80 80
         if(empty($count)){
81 81
             $output .= __('No Invoice(s)','invoicing');
82
-        }else{
82
+        } else{
83 83
             $link_url = admin_url( "edit.php?post_type=wpi_invoice&author=".absint($user_id) );
84 84
             $link_text = sprintf( __('Invoices ( %d )', 'invoicing'), $count );
85 85
             $output .= "<a href='$link_url' >$link_text</a>";
Please login to merge, or discard this patch.
invoicing.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -12,19 +12,19 @@
 block discarded – undo
12 12
 */
13 13
 
14 14
 // MUST have WordPress.
15
-if ( !defined( 'WPINC' ) ) {
16
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
15
+if (!defined('WPINC')) {
16
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
17 17
 }
18 18
 
19
-if ( !defined( 'WPINV_VERSION' ) ) {
20
-    define( 'WPINV_VERSION', '1.0.6' );
19
+if (!defined('WPINV_VERSION')) {
20
+    define('WPINV_VERSION', '1.0.6');
21 21
 }
22 22
 
23
-if ( !defined( 'WPINV_PLUGIN_FILE' ) ) {
24
-    define( 'WPINV_PLUGIN_FILE', __FILE__ );
23
+if (!defined('WPINV_PLUGIN_FILE')) {
24
+    define('WPINV_PLUGIN_FILE', __FILE__);
25 25
 }
26 26
 
27
-require plugin_dir_path( __FILE__ ) . 'includes/class-wpinv.php';
27
+require plugin_dir_path(__FILE__) . 'includes/class-wpinv.php';
28 28
 
29 29
 function wpinv_run() {
30 30
     global $invoicing;
Please login to merge, or discard this patch.
vendor/ayecode/wp-super-duper/wp-super-duper.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -811,7 +811,7 @@
 block discarded – undo
811 811
 		/**
812 812
 		 * Output the JS for building the dynamic Guntenberg block.
813 813
 		 *
814
-		 * @return mixed
814
+		 * @return string
815 815
 		 */
816 816
 		public function block() {
817 817
 			ob_start();
Please login to merge, or discard this patch.
Indentation   +990 added lines, -990 removed lines patch added patch discarded remove patch
@@ -1,164 +1,164 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) {
3
-	exit;
3
+    exit;
4 4
 }
5 5
 
6 6
 if ( ! class_exists( 'WP_Super_Duper' ) ) {
7 7
 
8 8
 
9
-	/**
10
-	 * A Class to be able to create a Widget, Shortcode or Block to be able to output content for WordPress.
11
-	 *
12
-	 * Should not be called direct but extended instead.
13
-	 *
14
-	 * Class WP_Super_Duper
15
-	 * @ver 1.0.2
16
-	 */
17
-	class WP_Super_Duper extends WP_Widget {
9
+    /**
10
+     * A Class to be able to create a Widget, Shortcode or Block to be able to output content for WordPress.
11
+     *
12
+     * Should not be called direct but extended instead.
13
+     *
14
+     * Class WP_Super_Duper
15
+     * @ver 1.0.2
16
+     */
17
+    class WP_Super_Duper extends WP_Widget {
18 18
 
19 19
 
20
-		public $version = "1.0.2";
21
-		public $block_code;
22
-		public $options;
23
-		public $base_id;
24
-		public $arguments = array();
25
-		public $instance = array();
26
-		private $class_name;
20
+        public $version = "1.0.2";
21
+        public $block_code;
22
+        public $options;
23
+        public $base_id;
24
+        public $arguments = array();
25
+        public $instance = array();
26
+        private $class_name;
27 27
 
28
-		/**
29
-		 * Take the array options and use them to build.
30
-		 */
31
-		public function __construct( $options ) {
32
-			global $sd_widgets;
28
+        /**
29
+         * Take the array options and use them to build.
30
+         */
31
+        public function __construct( $options ) {
32
+            global $sd_widgets;
33 33
 
34 34
 
35 35
 
36
-			//print_r($options);exit;
37
-			$sd_widgets[$options['base_id']] = array('name'=> $options['name'],'class_name'=>$options['class_name']);
38
-			$this->base_id = $options['base_id'];
39
-			// lets filter the options before we do anything
40
-			$options       = apply_filters( "wp_super_duper_options", $options );
41
-			$options       = apply_filters( "wp_super_duper_options_{$this->base_id}", $options );
42
-			$options       = $this->add_name_from_key( $options );
43
-			$this->options = $options;
36
+            //print_r($options);exit;
37
+            $sd_widgets[$options['base_id']] = array('name'=> $options['name'],'class_name'=>$options['class_name']);
38
+            $this->base_id = $options['base_id'];
39
+            // lets filter the options before we do anything
40
+            $options       = apply_filters( "wp_super_duper_options", $options );
41
+            $options       = apply_filters( "wp_super_duper_options_{$this->base_id}", $options );
42
+            $options       = $this->add_name_from_key( $options );
43
+            $this->options = $options;
44 44
 
45
-			$this->base_id   = $options['base_id'];
46
-			$this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array();
45
+            $this->base_id   = $options['base_id'];
46
+            $this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array();
47 47
 
48 48
 
49
-			// init parent
50
-			parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] );
49
+            // init parent
50
+            parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] );
51 51
 
52 52
 
53
-			if ( isset( $options['class_name'] ) ) {
54
-				// register widget
55
-				$this->class_name = $options['class_name'];
53
+            if ( isset( $options['class_name'] ) ) {
54
+                // register widget
55
+                $this->class_name = $options['class_name'];
56 56
 
57
-				// register shortcode
58
-				$this->register_shortcode();
57
+                // register shortcode
58
+                $this->register_shortcode();
59 59
 
60
-				// register block
61
-				//$this->register_block();
62
-				add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) );
63
-			}
60
+                // register block
61
+                //$this->register_block();
62
+                add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) );
63
+            }
64 64
 
65
-			// add the CSS and JS we need ONCE
66
-			global $sd_widget_scripts;
65
+            // add the CSS and JS we need ONCE
66
+            global $sd_widget_scripts;
67 67
 
68
-			if ( ! $sd_widget_scripts ) {
69
-				wp_add_inline_script( 'admin-widgets', $this->widget_js() );
70
-				wp_add_inline_script( 'customize-controls', $this->widget_js() );
71
-				wp_add_inline_style( 'widgets', $this->widget_css() );
68
+            if ( ! $sd_widget_scripts ) {
69
+                wp_add_inline_script( 'admin-widgets', $this->widget_js() );
70
+                wp_add_inline_script( 'customize-controls', $this->widget_js() );
71
+                wp_add_inline_style( 'widgets', $this->widget_css() );
72 72
 
73
-				// seems ashame to add this for one icon but i love it :(
74
-				//wp_register_script('font-awesome', 'https://use.fontawesome.com/releases/v5.4.1/js/all.js', array('font-awesome-shim'), $this->version);
75
-				//wp_register_script('font-awesome-shim', 'https://use.fontawesome.com/releases/v5.4.1/js/v4-shims.js', array(), $this->version);
73
+                // seems ashame to add this for one icon but i love it :(
74
+                //wp_register_script('font-awesome', 'https://use.fontawesome.com/releases/v5.4.1/js/all.js', array('font-awesome-shim'), $this->version);
75
+                //wp_register_script('font-awesome-shim', 'https://use.fontawesome.com/releases/v5.4.1/js/v4-shims.js', array(), $this->version);
76 76
 
77
-				//echo '###';
78
-				$sd_widget_scripts = true;
77
+                //echo '###';
78
+                $sd_widget_scripts = true;
79 79
 
80
-				// add shortcode insert button once
81
-				add_action( 'media_buttons',array( $this, 'shortcode_insert_button' ) );
82
-				//if( !wp_doing_ajax() ){
83
-				add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) );
84
-				//}
80
+                // add shortcode insert button once
81
+                add_action( 'media_buttons',array( $this, 'shortcode_insert_button' ) );
82
+                //if( !wp_doing_ajax() ){
83
+                add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) );
84
+                //}
85 85
 
86
-			}
86
+            }
87 87
 
88
-			do_action( 'wp_super_duper_widget_init', $options, $this );
88
+            do_action( 'wp_super_duper_widget_init', $options, $this );
89 89
 
90
-		}
90
+        }
91 91
 
92
-		/**
93
-		 * Get widget settings.
94
-		 *
95
-		 * @since 2.0.0
96
-		 */
97
-		public static function get_widget_settings(){
98
-			global $sd_widgets;
92
+        /**
93
+         * Get widget settings.
94
+         *
95
+         * @since 2.0.0
96
+         */
97
+        public static function get_widget_settings(){
98
+            global $sd_widgets;
99 99
 //			print_r($_REQUEST);
100 100
 //			echo '####';
101 101
 
102
-			$shortcode = isset($_REQUEST['shortcode']) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes($_REQUEST['shortcode']) : '';
103
-			if(!$shortcode){wp_die();}
104
-			$widget_args = isset($sd_widgets[$shortcode]) ? $sd_widgets[$shortcode] :'';
105
-			if(!$widget_args){wp_die();}
106
-			$class_name = isset($widget_args['class_name']) && $widget_args['class_name'] ? $widget_args['class_name'] : '';
107
-			if(!$class_name){wp_die();}
102
+            $shortcode = isset($_REQUEST['shortcode']) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes($_REQUEST['shortcode']) : '';
103
+            if(!$shortcode){wp_die();}
104
+            $widget_args = isset($sd_widgets[$shortcode]) ? $sd_widgets[$shortcode] :'';
105
+            if(!$widget_args){wp_die();}
106
+            $class_name = isset($widget_args['class_name']) && $widget_args['class_name'] ? $widget_args['class_name'] : '';
107
+            if(!$class_name){wp_die();}
108 108
 
109 109
 
110 110
 
111
-			//print_r( $sd_widgets );
111
+            //print_r( $sd_widgets );
112 112
 
113 113
 
114
-			// invoke an instance method
114
+            // invoke an instance method
115 115
 //			$instance = new Instance();
116 116
 //			call_user_func( array( $instance, 'method' ) );
117
-			$widget = new $class_name;
117
+            $widget = new $class_name;
118 118
 
119 119
 //			print_r($widget->form(array()));
120
-			ob_start();
121
-			$widget->form(array());
122
-			$form = ob_get_clean();
123
-			echo "<form id='$shortcode'>".$form."<div class=\"widget-control-save\"></div></form>";
120
+            ob_start();
121
+            $widget->form(array());
122
+            $form = ob_get_clean();
123
+            echo "<form id='$shortcode'>".$form."<div class=\"widget-control-save\"></div></form>";
124 124
 //			echo "<div id='sd-shortcode-output'></div>";
125 125
 
126
-			echo "<style>".$widget->widget_css()."</style>";
127
-			echo "<script>".$widget->widget_js()."</script>";
128
-			?>
126
+            echo "<style>".$widget->widget_css()."</style>";
127
+            echo "<script>".$widget->widget_js()."</script>";
128
+            ?>
129 129
 			<?php
130
-			wp_die();
131
-		}
132
-
133
-		/**
134
-		 * Insert button in shortcode.
135
-		 *
136
-		 * @since 2.0.0
137
-		 *
138
-		 * @param string $editor_id Optional. Shortcode editor id. Default null.
139
-		 * @param string $insert_shortcode_function Optional. Insert shotcode function. Default null.
140
-		 */
141
-		public static function shortcode_insert_button($editor_id = '',$insert_shortcode_function=''){
142
-			global $sd_widgets,$shortcode_insert_button_once;
143
-			if($shortcode_insert_button_once){return;}
144
-			add_thickbox();
145
-			?>
130
+            wp_die();
131
+        }
132
+
133
+        /**
134
+         * Insert button in shortcode.
135
+         *
136
+         * @since 2.0.0
137
+         *
138
+         * @param string $editor_id Optional. Shortcode editor id. Default null.
139
+         * @param string $insert_shortcode_function Optional. Insert shotcode function. Default null.
140
+         */
141
+        public static function shortcode_insert_button($editor_id = '',$insert_shortcode_function=''){
142
+            global $sd_widgets,$shortcode_insert_button_once;
143
+            if($shortcode_insert_button_once){return;}
144
+            add_thickbox();
145
+            ?>
146 146
 			<div id="super-duper-content" style="display:none;">
147 147
 
148 148
 				<div class="sd-shortcode-left-wrap">
149 149
 					<?php
150
-					//print_r( $sd_widgets );
151
-					asort($sd_widgets );
152
-					if(!empty($sd_widgets)){
153
-						echo '<select onchange="sd_get_shortcode_options(this);">';
154
-						echo "<option>".__('Select shortcode')."</option>";
155
-						foreach($sd_widgets as $shortcode => $class){
156
-							echo "<option value='".esc_attr($shortcode)."'>".esc_attr($shortcode)." (".esc_attr($class['name']).")</option>";
157
-						}
158
-						echo "</select>";
159
-
160
-					}
161
-					?>
150
+                    //print_r( $sd_widgets );
151
+                    asort($sd_widgets );
152
+                    if(!empty($sd_widgets)){
153
+                        echo '<select onchange="sd_get_shortcode_options(this);">';
154
+                        echo "<option>".__('Select shortcode')."</option>";
155
+                        foreach($sd_widgets as $shortcode => $class){
156
+                            echo "<option value='".esc_attr($shortcode)."'>".esc_attr($shortcode)." (".esc_attr($class['name']).")</option>";
157
+                        }
158
+                        echo "</select>";
159
+
160
+                    }
161
+                    ?>
162 162
 					<div class="sd-shortcode-settings"></div>
163 163
 
164 164
 				</div>
@@ -196,16 +196,16 @@  discard block
 block discarded – undo
196 196
 			<script>
197 197
 
198 198
 				<?php
199
-				if(!empty($insert_shortcode_function)){
200
-					echo $insert_shortcode_function;
201
-				}else{
202
-
203
-				/**
204
-				 * Function for super duper insert shortcode.
205
-				 *
206
-				 * @since 2.0.0
207
-				 */
208
-				?>
199
+                if(!empty($insert_shortcode_function)){
200
+                    echo $insert_shortcode_function;
201
+                }else{
202
+
203
+                /**
204
+                 * Function for super duper insert shortcode.
205
+                 *
206
+                 * @since 2.0.0
207
+                 */
208
+                ?>
209 209
 				function sd_insert_shortcode(){
210 210
 					$shortcode = jQuery('#sd-shortcode-output').val();
211 211
 					if($shortcode){
@@ -345,12 +345,12 @@  discard block
 block discarded – undo
345 345
 				}
346 346
 			</script>
347 347
 			<?php
348
-			$shortcode_insert_button_once = true;
349
-		}
348
+            $shortcode_insert_button_once = true;
349
+        }
350 350
 
351
-		public function widget_css() {
352
-			ob_start();
353
-			?>
351
+        public function widget_css() {
352
+            ob_start();
353
+            ?>
354 354
 			<style>
355 355
 				/*body {display: none;}*/
356 356
 				.sd-advanced-setting {
@@ -372,21 +372,21 @@  discard block
 block discarded – undo
372 372
 				}
373 373
 			</style>
374 374
 			<?php
375
-			$output = ob_get_clean();
375
+            $output = ob_get_clean();
376 376
 
377
-			/*
377
+            /*
378 378
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
379 379
 			 */
380 380
 
381
-			return str_replace( array(
382
-				'<style>',
383
-				'</style>'
384
-			), '', $output );
385
-		}
381
+            return str_replace( array(
382
+                '<style>',
383
+                '</style>'
384
+            ), '', $output );
385
+        }
386 386
 
387
-		public function widget_js() {
388
-			ob_start();
389
-			?>
387
+        public function widget_js() {
388
+            ob_start();
389
+            ?>
390 390
 			<script>
391 391
 
392 392
 				/**
@@ -542,280 +542,280 @@  discard block
 block discarded – undo
542 542
 				<?php do_action( 'wp_super_duper_widget_js', $this ); ?>
543 543
 			</script>
544 544
 			<?php
545
-			$output = ob_get_clean();
545
+            $output = ob_get_clean();
546 546
 
547
-			/*
547
+            /*
548 548
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
549 549
 			 */
550 550
 
551
-			return str_replace( array(
552
-				'<script>',
553
-				'</script>'
554
-			), '', $output );
555
-		}
556
-
557
-
558
-		/**
559
-		 * Set the name from the argument key.
560
-		 *
561
-		 * @param $options
562
-		 *
563
-		 * @return mixed
564
-		 */
565
-		private function add_name_from_key( $options, $arguments = false ) {
566
-			if ( ! empty( $options['arguments'] ) ) {
567
-				foreach ( $options['arguments'] as $key => $val ) {
568
-					$options['arguments'][ $key ]['name'] = $key;
569
-				}
570
-			} elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) {
571
-				foreach ( $options as $key => $val ) {
572
-					$options[ $key ]['name'] = $key;
573
-				}
574
-			}
575
-
576
-			return $options;
577
-		}
578
-
579
-		/**
580
-		 * Register the parent shortcode.
581
-		 *
582
-		 * @since 2.0.0
583
-		 */
584
-		public function register_shortcode() {
585
-			add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) );
586
-			add_action( 'wp_ajax_super_duper_output_shortcode', array( __CLASS__, 'render_shortcode' ) );
587
-		}
588
-
589
-		/**
590
-		 * Render the shortcode via ajax so we can return it to Gutenberg.
591
-		 *
592
-		 * @since 2.0.0
593
-		 */
594
-		public static function render_shortcode() {
595
-
596
-			check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true );
597
-			if ( ! current_user_can( 'manage_options' ) ) {
598
-				wp_die();
599
-			}
600
-
601
-			// we might need the $post value here so lets set it.
602
-			if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) {
603
-				$post_obj = get_post( absint( $_POST['post_id'] ) );
604
-				if ( ! empty( $post_obj ) && empty( $post ) ) {
605
-					global $post;
606
-					$post = $post_obj;
607
-				}
608
-			}
609
-
610
-			if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) {
611
-				$shortcode_name   = sanitize_title_with_dashes( $_POST['shortcode'] );
612
-				$attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array();
613
-				$attributes       = '';
614
-				if ( ! empty( $attributes_array ) ) {
615
-					foreach ( $attributes_array as $key => $value ) {
616
-						$attributes .= " " . sanitize_title_with_dashes( $key ) . "='" . wp_slash( $value ) . "' ";
617
-					}
618
-				}
619
-
620
-				$shortcode = "[" . $shortcode_name . " " . $attributes . "]";
621
-
622
-				echo do_shortcode( $shortcode );
623
-
624
-			}
625
-			wp_die();
626
-		}
627
-
628
-		/**
629
-		 * Output the shortcode.
630
-		 *
631
-		 * @param array $args
632
-		 * @param string $content
633
-		 */
634
-		public function shortcode_output( $args = array(), $content = '' ) {
635
-			$args = self::argument_values( $args );
636
-
637
-			// add extra argument so we know its a output to gutenberg
638
-			//$args
639
-			$args = $this->string_to_bool( $args );
640
-
641
-
642
-			$calss = isset($this->options['widget_ops']['classname']) ? esc_attr($this->options['widget_ops']['classname']) : '';
643
-
644
-			$calss = apply_filters( 'wp_super_duper_div_classname', $calss, $args, $this );
645
-			$calss = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $calss, $args, $this );
646
-
647
-			$attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
648
-			$attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
649
-
650
-			$shortcode_args = array();
651
-			$output = '';
652
-			$no_wrap = isset($this->options['no_wrap']) && $this->options['no_wrap'] ?  true : false;
653
-			$main_content = $this->output( $args, $shortcode_args, $content );
654
-			if($main_content && !$no_wrap){
655
-				// wrap the shortcode in a dive with the same class as the widget
656
-				$output .= '<div class="'.$calss.'" ' . $attrs . '>';
657
-				if(!empty($args['title'])){
658
-					// if its a shortcode and there is a title try to grab the title wrappers
659
-					$shortcode_args = array('before_title'=>'', 'after_title' => '');
660
-					if(empty($instance)){
661
-						global $wp_registered_sidebars;
662
-						if(!empty($wp_registered_sidebars)){
663
-							foreach($wp_registered_sidebars as $sidebar){
664
-								if(!empty($sidebar['before_title'])){
665
-									$shortcode_args['before_title'] = $sidebar['before_title'];
666
-									$shortcode_args['after_title'] = $sidebar['after_title'];
667
-									break;
668
-								}
669
-							}
670
-						}
671
-					}
672
-					$output .= $this->output_title($shortcode_args,$args);
673
-				}
674
-				$output .= $main_content;
675
-				$output .= '</div>';
676
-			}elseif($main_content && $no_wrap){
677
-				$output .= $main_content;
678
-			}
679
-
680
-			return $output;
681
-		}
682
-
683
-
684
-		/**
685
-		 * Sometimes booleans values can be turned to strings, so we fix that.
686
-		 *
687
-		 * @param $options
688
-		 *
689
-		 * @return mixed
690
-		 */
691
-		public function string_to_bool( $options ) {
692
-			// convert bool strings to booleans
693
-			foreach ( $options as $key => $val ) {
694
-				if ( $val == 'false' ) {
695
-					$options[ $key ] = false;
696
-				} elseif ( $val == 'true' ) {
697
-					$options[ $key ] = true;
698
-				}
699
-			}
700
-
701
-			return $options;
702
-		}
703
-
704
-		/**
705
-		 * Get the argument values that are also filterable.
706
-		 *
707
-		 * @param $instance
708
-		 *
709
-		 * @return array
710
-		 */
711
-		public function argument_values( $instance ) {
712
-			$argument_values = array();
713
-
714
-			// set widget instance
715
-			$this->instance = $instance;
716
-
717
-			if ( empty( $this->arguments ) ) {
718
-				$this->arguments = $this->get_arguments();
719
-			}
720
-
721
-			if ( ! empty( $this->arguments ) ) {
722
-				foreach ( $this->arguments as $key => $args ) {
723
-					// set the input name from the key
724
-					$args['name'] = $key;
725
-					//
726
-					$argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : '';
727
-					if ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) {
728
-						$argument_values[ $key ] = $args['default'];
729
-					}
730
-				}
731
-			}
732
-
733
-			return $argument_values;
734
-		}
735
-
736
-		/**
737
-		 * Set arguments in super duper.
738
-		 *
739
-		 * @since 2.0.0
740
-		 *
741
-		 * @return array Set arguments.
742
-		 */
743
-		public function set_arguments() {
744
-			return $this->arguments;
745
-		}
746
-
747
-		/**
748
-		 * Get arguments in super duper.
749
-		 *
750
-		 * @since 2.0.0
751
-		 *
752
-		 * @return array Get arguments.
753
-		 */
754
-		public function get_arguments() {
755
-			if ( empty( $this->arguments ) ) {
756
-				$this->arguments =  $this->set_arguments();
757
-			}
758
-
759
-			$this->arguments = apply_filters('wp_super_duper_arguments',$this->arguments,$this->options, $this->instance);
760
-			$this->arguments = $this->add_name_from_key( $this->arguments, true );
761
-
762
-
763
-			return $this->arguments;
764
-		}
765
-
766
-		/**
767
-		 * This is the main output class for all 3 items, widget, shortcode and block, it is extended in the calling class.
768
-		 *
769
-		 * @param array $args
770
-		 * @param array $widget_args
771
-		 * @param string $content
772
-		 */
773
-		public function output( $args = array(), $widget_args = array(), $content = '' ) {
774
-
775
-		}
776
-
777
-		/**
778
-		 * Add the dyanmic block code inline when the wp-block in enqueued.
779
-		 */
780
-		public function register_block() {
781
-			wp_add_inline_script( 'wp-blocks', $this->block() );
782
-		}
783
-
784
-
785
-		/**
786
-		 * Check if we need to show advanced options.
787
-		 *
788
-		 * @return bool
789
-		 */
790
-		public function block_show_advanced() {
791
-			//$this->arguments
792
-			$show      = false;
793
-			$arguments = $this->arguments;
794
-
795
-			if(empty($arguments)){
796
-				$arguments = $this->get_arguments();
797
-			}
798
-
799
-			if ( ! empty( $arguments ) ) {
800
-				foreach ( $arguments as $argument ) {
801
-					if ( isset( $argument['advanced'] ) && $argument['advanced'] ) {
802
-						$show = true;
803
-					}
804
-				}
805
-			}
806
-
807
-			return $show;
808
-		}
809
-
810
-
811
-		/**
812
-		 * Output the JS for building the dynamic Guntenberg block.
813
-		 *
814
-		 * @return mixed
815
-		 */
816
-		public function block() {
817
-			ob_start();
818
-			?>
551
+            return str_replace( array(
552
+                '<script>',
553
+                '</script>'
554
+            ), '', $output );
555
+        }
556
+
557
+
558
+        /**
559
+         * Set the name from the argument key.
560
+         *
561
+         * @param $options
562
+         *
563
+         * @return mixed
564
+         */
565
+        private function add_name_from_key( $options, $arguments = false ) {
566
+            if ( ! empty( $options['arguments'] ) ) {
567
+                foreach ( $options['arguments'] as $key => $val ) {
568
+                    $options['arguments'][ $key ]['name'] = $key;
569
+                }
570
+            } elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) {
571
+                foreach ( $options as $key => $val ) {
572
+                    $options[ $key ]['name'] = $key;
573
+                }
574
+            }
575
+
576
+            return $options;
577
+        }
578
+
579
+        /**
580
+         * Register the parent shortcode.
581
+         *
582
+         * @since 2.0.0
583
+         */
584
+        public function register_shortcode() {
585
+            add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) );
586
+            add_action( 'wp_ajax_super_duper_output_shortcode', array( __CLASS__, 'render_shortcode' ) );
587
+        }
588
+
589
+        /**
590
+         * Render the shortcode via ajax so we can return it to Gutenberg.
591
+         *
592
+         * @since 2.0.0
593
+         */
594
+        public static function render_shortcode() {
595
+
596
+            check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true );
597
+            if ( ! current_user_can( 'manage_options' ) ) {
598
+                wp_die();
599
+            }
600
+
601
+            // we might need the $post value here so lets set it.
602
+            if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) {
603
+                $post_obj = get_post( absint( $_POST['post_id'] ) );
604
+                if ( ! empty( $post_obj ) && empty( $post ) ) {
605
+                    global $post;
606
+                    $post = $post_obj;
607
+                }
608
+            }
609
+
610
+            if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) {
611
+                $shortcode_name   = sanitize_title_with_dashes( $_POST['shortcode'] );
612
+                $attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array();
613
+                $attributes       = '';
614
+                if ( ! empty( $attributes_array ) ) {
615
+                    foreach ( $attributes_array as $key => $value ) {
616
+                        $attributes .= " " . sanitize_title_with_dashes( $key ) . "='" . wp_slash( $value ) . "' ";
617
+                    }
618
+                }
619
+
620
+                $shortcode = "[" . $shortcode_name . " " . $attributes . "]";
621
+
622
+                echo do_shortcode( $shortcode );
623
+
624
+            }
625
+            wp_die();
626
+        }
627
+
628
+        /**
629
+         * Output the shortcode.
630
+         *
631
+         * @param array $args
632
+         * @param string $content
633
+         */
634
+        public function shortcode_output( $args = array(), $content = '' ) {
635
+            $args = self::argument_values( $args );
636
+
637
+            // add extra argument so we know its a output to gutenberg
638
+            //$args
639
+            $args = $this->string_to_bool( $args );
640
+
641
+
642
+            $calss = isset($this->options['widget_ops']['classname']) ? esc_attr($this->options['widget_ops']['classname']) : '';
643
+
644
+            $calss = apply_filters( 'wp_super_duper_div_classname', $calss, $args, $this );
645
+            $calss = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $calss, $args, $this );
646
+
647
+            $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
648
+            $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
649
+
650
+            $shortcode_args = array();
651
+            $output = '';
652
+            $no_wrap = isset($this->options['no_wrap']) && $this->options['no_wrap'] ?  true : false;
653
+            $main_content = $this->output( $args, $shortcode_args, $content );
654
+            if($main_content && !$no_wrap){
655
+                // wrap the shortcode in a dive with the same class as the widget
656
+                $output .= '<div class="'.$calss.'" ' . $attrs . '>';
657
+                if(!empty($args['title'])){
658
+                    // if its a shortcode and there is a title try to grab the title wrappers
659
+                    $shortcode_args = array('before_title'=>'', 'after_title' => '');
660
+                    if(empty($instance)){
661
+                        global $wp_registered_sidebars;
662
+                        if(!empty($wp_registered_sidebars)){
663
+                            foreach($wp_registered_sidebars as $sidebar){
664
+                                if(!empty($sidebar['before_title'])){
665
+                                    $shortcode_args['before_title'] = $sidebar['before_title'];
666
+                                    $shortcode_args['after_title'] = $sidebar['after_title'];
667
+                                    break;
668
+                                }
669
+                            }
670
+                        }
671
+                    }
672
+                    $output .= $this->output_title($shortcode_args,$args);
673
+                }
674
+                $output .= $main_content;
675
+                $output .= '</div>';
676
+            }elseif($main_content && $no_wrap){
677
+                $output .= $main_content;
678
+            }
679
+
680
+            return $output;
681
+        }
682
+
683
+
684
+        /**
685
+         * Sometimes booleans values can be turned to strings, so we fix that.
686
+         *
687
+         * @param $options
688
+         *
689
+         * @return mixed
690
+         */
691
+        public function string_to_bool( $options ) {
692
+            // convert bool strings to booleans
693
+            foreach ( $options as $key => $val ) {
694
+                if ( $val == 'false' ) {
695
+                    $options[ $key ] = false;
696
+                } elseif ( $val == 'true' ) {
697
+                    $options[ $key ] = true;
698
+                }
699
+            }
700
+
701
+            return $options;
702
+        }
703
+
704
+        /**
705
+         * Get the argument values that are also filterable.
706
+         *
707
+         * @param $instance
708
+         *
709
+         * @return array
710
+         */
711
+        public function argument_values( $instance ) {
712
+            $argument_values = array();
713
+
714
+            // set widget instance
715
+            $this->instance = $instance;
716
+
717
+            if ( empty( $this->arguments ) ) {
718
+                $this->arguments = $this->get_arguments();
719
+            }
720
+
721
+            if ( ! empty( $this->arguments ) ) {
722
+                foreach ( $this->arguments as $key => $args ) {
723
+                    // set the input name from the key
724
+                    $args['name'] = $key;
725
+                    //
726
+                    $argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : '';
727
+                    if ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) {
728
+                        $argument_values[ $key ] = $args['default'];
729
+                    }
730
+                }
731
+            }
732
+
733
+            return $argument_values;
734
+        }
735
+
736
+        /**
737
+         * Set arguments in super duper.
738
+         *
739
+         * @since 2.0.0
740
+         *
741
+         * @return array Set arguments.
742
+         */
743
+        public function set_arguments() {
744
+            return $this->arguments;
745
+        }
746
+
747
+        /**
748
+         * Get arguments in super duper.
749
+         *
750
+         * @since 2.0.0
751
+         *
752
+         * @return array Get arguments.
753
+         */
754
+        public function get_arguments() {
755
+            if ( empty( $this->arguments ) ) {
756
+                $this->arguments =  $this->set_arguments();
757
+            }
758
+
759
+            $this->arguments = apply_filters('wp_super_duper_arguments',$this->arguments,$this->options, $this->instance);
760
+            $this->arguments = $this->add_name_from_key( $this->arguments, true );
761
+
762
+
763
+            return $this->arguments;
764
+        }
765
+
766
+        /**
767
+         * This is the main output class for all 3 items, widget, shortcode and block, it is extended in the calling class.
768
+         *
769
+         * @param array $args
770
+         * @param array $widget_args
771
+         * @param string $content
772
+         */
773
+        public function output( $args = array(), $widget_args = array(), $content = '' ) {
774
+
775
+        }
776
+
777
+        /**
778
+         * Add the dyanmic block code inline when the wp-block in enqueued.
779
+         */
780
+        public function register_block() {
781
+            wp_add_inline_script( 'wp-blocks', $this->block() );
782
+        }
783
+
784
+
785
+        /**
786
+         * Check if we need to show advanced options.
787
+         *
788
+         * @return bool
789
+         */
790
+        public function block_show_advanced() {
791
+            //$this->arguments
792
+            $show      = false;
793
+            $arguments = $this->arguments;
794
+
795
+            if(empty($arguments)){
796
+                $arguments = $this->get_arguments();
797
+            }
798
+
799
+            if ( ! empty( $arguments ) ) {
800
+                foreach ( $arguments as $argument ) {
801
+                    if ( isset( $argument['advanced'] ) && $argument['advanced'] ) {
802
+                        $show = true;
803
+                    }
804
+                }
805
+            }
806
+
807
+            return $show;
808
+        }
809
+
810
+
811
+        /**
812
+         * Output the JS for building the dynamic Guntenberg block.
813
+         *
814
+         * @return mixed
815
+         */
816
+        public function block() {
817
+            ob_start();
818
+            ?>
819 819
 			<script>
820 820
 				/**
821 821
 				 * BLOCK: Basic
@@ -854,67 +854,67 @@  discard block
 block discarded – undo
854 854
 						icon: '<?php echo isset( $this->options['block-icon'] ) ? esc_attr( $this->options['block-icon'] ) : 'shield-alt';?>', // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/.
855 855
 						category: '<?php echo isset( $this->options['block-category'] ) ? esc_attr( $this->options['block-category'] ) : 'common';?>', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed.
856 856
 						<?php if ( isset( $this->options['block-keywords'] ) ) {
857
-						echo "keywords : " . $this->options['block-keywords'] . ",";
858
-					}?>
857
+                        echo "keywords : " . $this->options['block-keywords'] . ",";
858
+                    }?>
859 859
 
860 860
 						<?php
861 861
 
862
-						$show_advanced = $this->block_show_advanced();
863
-
864
-						$show_alignment = false;
865
-
866
-						if ( ! empty( $this->arguments ) ) {
867
-							echo "attributes : {";
868
-
869
-							if ( $show_advanced ) {
870
-								echo "show_advanced: {";
871
-								echo "	type: 'boolean',";
872
-								echo "  default: false,";
873
-								echo "},";
874
-							}
875
-
876
-							foreach ( $this->arguments as $key => $args ) {
877
-
878
-								// set if we should show alignment
879
-								if ( $key == 'alignment' ) {
880
-									$show_alignment = true;
881
-								}
882
-
883
-								$extra = '';
884
-
885
-								if ( $args['type'] == 'checkbox' ) {
886
-									$type    = 'boolean';
887
-									$default = isset( $args['default'] ) && "'" . $args['default'] . "'" ? 'true' : 'false';
888
-								} elseif ( $args['type'] == 'number' ) {
889
-									$type    = 'number';
890
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
891
-								} elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) {
892
-									$type    = 'array';
893
-									if(is_array($args['default'])){
894
-										$default = isset( $args['default'] ) ? "['" . implode("','", $args['default']) . "']" : "[]";
895
-									}else{
896
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
897
-									}
898
-								} elseif ( $args['type'] == 'multiselect' ) {
899
-									$type    = 'array';
900
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
901
-								} else {
902
-									$type    = 'string';
903
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
904
-								}
905
-								echo $key . " : {";
906
-								echo "type : '$type',";
907
-								echo "default : $default,";
908
-								echo "},";
909
-							}
910
-
911
-							echo "content : {type : 'string',default: 'Please select the attributes in the block settings'},";
912
-
913
-							echo "},";
914
-
915
-						}
916
-
917
-						?>
862
+                        $show_advanced = $this->block_show_advanced();
863
+
864
+                        $show_alignment = false;
865
+
866
+                        if ( ! empty( $this->arguments ) ) {
867
+                            echo "attributes : {";
868
+
869
+                            if ( $show_advanced ) {
870
+                                echo "show_advanced: {";
871
+                                echo "	type: 'boolean',";
872
+                                echo "  default: false,";
873
+                                echo "},";
874
+                            }
875
+
876
+                            foreach ( $this->arguments as $key => $args ) {
877
+
878
+                                // set if we should show alignment
879
+                                if ( $key == 'alignment' ) {
880
+                                    $show_alignment = true;
881
+                                }
882
+
883
+                                $extra = '';
884
+
885
+                                if ( $args['type'] == 'checkbox' ) {
886
+                                    $type    = 'boolean';
887
+                                    $default = isset( $args['default'] ) && "'" . $args['default'] . "'" ? 'true' : 'false';
888
+                                } elseif ( $args['type'] == 'number' ) {
889
+                                    $type    = 'number';
890
+                                    $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
891
+                                } elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) {
892
+                                    $type    = 'array';
893
+                                    if(is_array($args['default'])){
894
+                                        $default = isset( $args['default'] ) ? "['" . implode("','", $args['default']) . "']" : "[]";
895
+                                    }else{
896
+                                        $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
897
+                                    }
898
+                                } elseif ( $args['type'] == 'multiselect' ) {
899
+                                    $type    = 'array';
900
+                                    $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
901
+                                } else {
902
+                                    $type    = 'string';
903
+                                    $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
904
+                                }
905
+                                echo $key . " : {";
906
+                                echo "type : '$type',";
907
+                                echo "default : $default,";
908
+                                echo "},";
909
+                            }
910
+
911
+                            echo "content : {type : 'string',default: 'Please select the attributes in the block settings'},";
912
+
913
+                            echo "},";
914
+
915
+                        }
916
+
917
+                        ?>
918 918
 
919 919
 						// The "edit" property must be a valid function.
920 920
 						edit: function (props) {
@@ -933,8 +933,8 @@  discard block
 block discarded – undo
933 933
 										'shortcode': '<?php echo $this->options['base_id'];?>',
934 934
 										'attributes': props.attributes,
935 935
 										'post_id': <?php global $post; if ( isset( $post->ID ) ) {
936
-										echo $post->ID;
937
-									}?>,
936
+                                        echo $post->ID;
937
+                                    }?>,
938 938
 										'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>'
939 939
 									};
940 940
 
@@ -976,10 +976,10 @@  discard block
 block discarded – undo
976 976
 
977 977
 									<?php
978 978
 
979
-									if(! empty( $this->arguments )){
979
+                                    if(! empty( $this->arguments )){
980 980
 
981
-									if ( $show_advanced ) {
982
-									?>
981
+                                    if ( $show_advanced ) {
982
+                                    ?>
983 983
 									el(
984 984
 										wp.components.ToggleControl,
985 985
 										{
@@ -992,65 +992,65 @@  discard block
 block discarded – undo
992 992
 									),
993 993
 									<?php
994 994
 
995
-									}
996
-
997
-									foreach($this->arguments as $key => $args){
998
-									$custom_attributes = !empty($args['custom_attributes']) ? $this->array_to_attributes($args['custom_attributes']) : '';
999
-									$options = '';
1000
-									$extra = '';
1001
-									$require = '';
1002
-									$onchange = "props.setAttributes({ $key: $key } )";
1003
-									$value = "props.attributes.$key";
1004
-									$text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'color' );
1005
-									if ( in_array( $args['type'], $text_type ) ) {
1006
-										$type = 'TextControl';
1007
-									} elseif ( $args['type'] == 'checkbox' ) {
1008
-										$type = 'CheckboxControl';
1009
-										$extra .= "checked: props.attributes.$key,";
1010
-										$onchange = "props.setAttributes({ $key: ! props.attributes.$key } )";
1011
-									} elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) {
1012
-										$type = 'SelectControl';
1013
-										if ( ! empty( $args['options'] ) ) {
1014
-											$options .= "options  : [";
1015
-											foreach ( $args['options'] as $option_val => $option_label ) {
1016
-												$options .= "{ value : '" . esc_attr( $option_val ) . "',     label : '" . esc_attr( $option_label ) . "'     },";
1017
-											}
1018
-											$options .= "],";
1019
-										}
1020
-										if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
1021
-											$extra .= ' multiple: true, ';
1022
-											//$onchange = "props.setAttributes({ $key: ['edit'] } )";
1023
-											//$value = "['edit', 'delete']";
1024
-										}
1025
-									} elseif ( $args['type'] == 'alignment' ) {
1026
-										$type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example
1027
-									} else {
1028
-										continue;// if we have not implemented the control then don't break the JS.
1029
-									}
1030
-
1031
-									// add show only if advanced
1032
-									if ( ! empty( $args['advanced'] ) ) {
1033
-										echo "props.attributes.show_advanced && ";
1034
-									}
1035
-									// add setting require if defined
1036
-									if ( ! empty( $args['element_require'] ) ) {
1037
-										echo $this->block_props_replace( $args['element_require'], true ) . " && ";
1038
-									}
1039
-									?>
995
+                                    }
996
+
997
+                                    foreach($this->arguments as $key => $args){
998
+                                    $custom_attributes = !empty($args['custom_attributes']) ? $this->array_to_attributes($args['custom_attributes']) : '';
999
+                                    $options = '';
1000
+                                    $extra = '';
1001
+                                    $require = '';
1002
+                                    $onchange = "props.setAttributes({ $key: $key } )";
1003
+                                    $value = "props.attributes.$key";
1004
+                                    $text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'color' );
1005
+                                    if ( in_array( $args['type'], $text_type ) ) {
1006
+                                        $type = 'TextControl';
1007
+                                    } elseif ( $args['type'] == 'checkbox' ) {
1008
+                                        $type = 'CheckboxControl';
1009
+                                        $extra .= "checked: props.attributes.$key,";
1010
+                                        $onchange = "props.setAttributes({ $key: ! props.attributes.$key } )";
1011
+                                    } elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) {
1012
+                                        $type = 'SelectControl';
1013
+                                        if ( ! empty( $args['options'] ) ) {
1014
+                                            $options .= "options  : [";
1015
+                                            foreach ( $args['options'] as $option_val => $option_label ) {
1016
+                                                $options .= "{ value : '" . esc_attr( $option_val ) . "',     label : '" . esc_attr( $option_label ) . "'     },";
1017
+                                            }
1018
+                                            $options .= "],";
1019
+                                        }
1020
+                                        if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
1021
+                                            $extra .= ' multiple: true, ';
1022
+                                            //$onchange = "props.setAttributes({ $key: ['edit'] } )";
1023
+                                            //$value = "['edit', 'delete']";
1024
+                                        }
1025
+                                    } elseif ( $args['type'] == 'alignment' ) {
1026
+                                        $type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example
1027
+                                    } else {
1028
+                                        continue;// if we have not implemented the control then don't break the JS.
1029
+                                    }
1030
+
1031
+                                    // add show only if advanced
1032
+                                    if ( ! empty( $args['advanced'] ) ) {
1033
+                                        echo "props.attributes.show_advanced && ";
1034
+                                    }
1035
+                                    // add setting require if defined
1036
+                                    if ( ! empty( $args['element_require'] ) ) {
1037
+                                        echo $this->block_props_replace( $args['element_require'], true ) . " && ";
1038
+                                    }
1039
+                                    ?>
1040 1040
 									el(
1041 1041
 										wp.components.<?php echo esc_attr( $type );?>,
1042 1042
 										{
1043 1043
 											label: '<?php echo esc_attr( $args['title'] );?>',
1044 1044
 											help: '<?php if ( isset( $args['desc'] ) ) {
1045
-												echo esc_attr( $args['desc'] );
1046
-											}?>',
1045
+                                                echo esc_attr( $args['desc'] );
1046
+                                            }?>',
1047 1047
 											value: <?php echo $value;?>,
1048 1048
 											<?php if ( $type == 'TextControl' && $args['type'] != 'text' ) {
1049
-											echo "type: '" . esc_attr( $args['type'] ) . "',";
1050
-										}?>
1049
+                                            echo "type: '" . esc_attr( $args['type'] ) . "',";
1050
+                                        }?>
1051 1051
 											<?php if ( ! empty( $args['placeholder'] ) ) {
1052
-											echo "placeholder: '" . esc_attr( $args['placeholder'] ) . "',";
1053
-										}?>
1052
+                                            echo "placeholder: '" . esc_attr( $args['placeholder'] ) . "',";
1053
+                                        }?>
1054 1054
 											<?php echo $options;?>
1055 1055
 											<?php echo $extra;?>
1056 1056
 											<?php echo $custom_attributes;?>
@@ -1060,27 +1060,27 @@  discard block
 block discarded – undo
1060 1060
 										}
1061 1061
 									),
1062 1062
 									<?php
1063
-									}
1064
-									}
1065
-									?>
1063
+                                    }
1064
+                                    }
1065
+                                    ?>
1066 1066
 
1067 1067
 								),
1068 1068
 
1069 1069
 								<?php
1070
-								// If the user sets block-output array then build it
1071
-								if ( ! empty( $this->options['block-output'] ) ) {
1072
-								$this->block_element( $this->options['block-output'] );
1073
-							}else{
1074
-								// if no block-output is set then we try and get the shortcode html output via ajax.
1075
-								?>
1070
+                                // If the user sets block-output array then build it
1071
+                                if ( ! empty( $this->options['block-output'] ) ) {
1072
+                                $this->block_element( $this->options['block-output'] );
1073
+                            }else{
1074
+                                // if no block-output is set then we try and get the shortcode html output via ajax.
1075
+                                ?>
1076 1076
 								el('div', {
1077 1077
 									dangerouslySetInnerHTML: {__html: onChangeContent()},
1078 1078
 									className: props.className,
1079 1079
 									style: {'min-height': '30px'}
1080 1080
 								})
1081 1081
 								<?php
1082
-								}
1083
-								?>
1082
+                                }
1083
+                                ?>
1084 1084
 							]; // end return
1085 1085
 						},
1086 1086
 
@@ -1097,17 +1097,17 @@  discard block
 block discarded – undo
1097 1097
 							var content = "[<?php echo $this->options['base_id'];?>";
1098 1098
 							<?php
1099 1099
 
1100
-							if(! empty( $this->arguments )){
1101
-							foreach($this->arguments as $key => $args){
1102
-							?>
1100
+                            if(! empty( $this->arguments )){
1101
+                            foreach($this->arguments as $key => $args){
1102
+                            ?>
1103 1103
 							if (attr.hasOwnProperty("<?php echo esc_attr( $key );?>")) {
1104 1104
 								content += " <?php echo esc_attr( $key );?>='" + attr.<?php echo esc_attr( $key );?>+ "' ";
1105 1105
 							}
1106 1106
 							<?php
1107
-							}
1108
-							}
1107
+                            }
1108
+                            }
1109 1109
 
1110
-							?>
1110
+                            ?>
1111 1111
 							content += "]";
1112 1112
 
1113 1113
 
@@ -1132,367 +1132,367 @@  discard block
 block discarded – undo
1132 1132
 				})();
1133 1133
 			</script>
1134 1134
 			<?php
1135
-			$output = ob_get_clean();
1135
+            $output = ob_get_clean();
1136 1136
 
1137
-			/*
1137
+            /*
1138 1138
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1139 1139
 			 */
1140 1140
 
1141
-			return str_replace( array(
1142
-				'<script>',
1143
-				'</script>'
1144
-			), '', $output );
1145
-		}
1146
-
1147
-		/**
1148
-		 * Convert an array of attributes to block string.
1149
-		 *
1150
-		 * @todo there is prob a faster way to do this, also we could add some validation here.
1151
-		 * @param $custom_attributes
1152
-		 *
1153
-		 * @return string
1154
-		 */
1155
-		public function array_to_attributes($custom_attributes, $html = false){
1156
-			$attributes = '';
1157
-			if(!empty($custom_attributes)){
1158
-
1159
-				if($html){
1160
-					foreach($custom_attributes as $key => $val){
1161
-						$attributes .= " $key='$val' ";
1162
-					}
1163
-				}else{
1164
-					foreach($custom_attributes as $key => $val){
1165
-						$attributes .= "'$key': '$val',";
1166
-					}
1167
-				}
1168
-			}
1169
-
1170
-			return $attributes;
1171
-		}
1172
-
1173
-
1174
-		/**
1175
-		 * A self looping function to create the output for JS block elements.
1176
-		 *
1177
-		 * This is what is output in the WP Editor visual view.
1178
-		 *
1179
-		 * @param $args
1180
-		 */
1181
-		public function block_element( $args ) {
1182
-
1183
-
1184
-			if ( ! empty( $args ) ) {
1185
-				foreach ( $args as $element => $new_args ) {
1186
-
1187
-					if ( is_array( $new_args ) ) { // its an element
1188
-
1189
-
1190
-						if ( isset( $new_args['element'] ) ) {
1191
-
1192
-							//print_r($new_args);
1193
-
1194
-							if ( isset( $new_args['element_require'] ) ) {
1195
-								echo str_replace( array(
1196
-										"'+",
1197
-										"+'"
1198
-									), '', $this->block_props_replace( $new_args['element_require'] ) ) . " &&  ";
1199
-								unset( $new_args['element_require'] );
1200
-							}
1201
-
1202
-							echo "\n el( '" . $new_args['element'] . "', {";
1203
-
1204
-							// get the attributes
1205
-							foreach ( $new_args as $new_key => $new_value ) {
1206
-
1207
-
1208
-								if ( $new_key == 'element' || $new_key == 'content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) {
1209
-									// do nothing
1210
-								} else {
1211
-									echo $this->block_element( array( $new_key => $new_value ) );
1212
-								}
1213
-							}
1214
-
1215
-							echo "},";// end attributes
1216
-
1217
-							// get the content
1218
-							$first_item = 0;
1219
-							foreach ( $new_args as $new_key => $new_value ) {
1220
-								if ( $new_key === 'content' || is_array( $new_value ) ) {
1221
-									//echo ",".$first_item;// separate the children
1222
-
1223
-
1224
-									if ( $first_item > 0 ) {
1225
-										//echo ",";// separate the children
1226
-									} else {
1227
-										//echo '####'.$first_item;
1228
-									}
1229
-
1230
-									if ( $new_key === 'content' ) {
1231
-										//print_r($new_args);
1232
-										echo "'" . $this->block_props_replace( $new_value ) . "'";
1233
-									}
1234
-
1235
-									if ( is_array( $new_value ) ) {
1236
-
1237
-										if ( isset( $new_value['element_require'] ) ) {
1238
-											echo str_replace( array(
1239
-													"'+",
1240
-													"+'"
1241
-												), '', $this->block_props_replace( $new_value['element_require'] ) ) . " &&  ";
1242
-											unset( $new_value['element_require'] );
1243
-										}
1244
-
1245
-										if ( isset( $new_value['element_repeat'] ) ) {
1246
-											$x = 1;
1247
-											while ( $x <= absint( $new_value['element_repeat'] ) ) {
1248
-												$this->block_element( array( '' => $new_value ) );
1249
-												$x ++;
1250
-											}
1251
-										} else {
1252
-											$this->block_element( array( '' => $new_value ) );
1253
-										}
1254
-										//print_r($new_value);
1255
-									}
1256
-									$first_item ++;
1257
-								}
1258
-							}
1259
-
1260
-							echo ")";// end content
1261
-
1262
-							//if($first_item>0){
1263
-							echo ", \n";
1264
-							//}
1265
-
1266
-
1267
-						}
1268
-						//$this->block_element($new_args);
1269
-					} else {
1270
-
1271
-						if ( substr( $element, 0, 3 ) === "if_" ) {
1272
-							echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ",";
1273
-						} elseif ( $element == 'style' ) {
1274
-							echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
1275
-						} else {
1276
-							echo $element . ": '" . $this->block_props_replace( $new_args ) . "',";
1277
-						}
1278
-
1279
-					}
1280
-
1281
-
1282
-				}
1283
-			}
1284
-		}
1285
-
1286
-		/**
1287
-		 * Replace block attributes placeholders with the proper naming.
1288
-		 *
1289
-		 * @param $string
1290
-		 *
1291
-		 * @return mixed
1292
-		 */
1293
-		public function block_props_replace( $string, $no_wrap = false ) {
1294
-
1295
-			if ( $no_wrap ) {
1296
-				$string = str_replace( array( "[%", "%]" ), array( "props.attributes.", "" ), $string );
1297
-			} else {
1298
-				$string = str_replace( array( "[%", "%]" ), array( "'+props.attributes.", "+'" ), $string );
1299
-			}
1300
-
1301
-			return $string;
1302
-		}
1303
-
1304
-		/**
1305
-		 * Outputs the content of the widget
1306
-		 *
1307
-		 * @param array $args
1308
-		 * @param array $instance
1309
-		 */
1310
-		public function widget( $args, $instance ) {
1311
-			// outputs the content of the widget
1312
-
1313
-			// get the filtered values
1314
-			$argument_values = $this->argument_values( $instance );
1315
-			$argument_values = $this->string_to_bool( $argument_values );
1316
-			$output = $this->output( $argument_values, $args );
1317
-
1318
-			if ( $output ) {
1319
-				// Before widget
1320
-				$before_widget = $args['before_widget'];
1321
-				$before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this );
1322
-				$before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this );
1323
-
1324
-				// After widget
1325
-				$after_widget = $args['after_widget'];
1326
-				$after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this );
1327
-				$after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this );
1328
-
1329
-				echo $before_widget;
1330
-				echo $this->output_title($args, $instance);
1331
-				echo $output;
1332
-				echo $after_widget;
1333
-			}
1334
-		}
1335
-
1336
-		/**
1337
-		 * Output the super title.
1338
-		 *
1339
-		 * @param $args
1340
-		 * @param array $instance
1341
-		 *
1342
-		 * @return string
1343
-		 */
1344
-		public function output_title($args, $instance = array()){
1345
-			$output = '';
1346
-			if ( ! empty( $instance['title'] ) ) {
1347
-				/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
1348
-				$title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
1349
-				$output = $args['before_title'] . $title . $args['after_title'];
1350
-			}
1351
-			return $output;
1352
-		}
1353
-
1354
-		/**
1355
-		 * Outputs the options form inputs for the widget.
1356
-		 *
1357
-		 * @param array $instance The widget options.
1358
-		 */
1359
-		public function form( $instance ) {
1360
-
1361
-			// set widget instance
1362
-			$this->instance = $instance;
1363
-
1364
-			// set it as a SD widget
1365
-			echo $this->widget_advanced_toggle();
1366
-
1367
-
1368
-			echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>";
1369
-			$arguments = $this->get_arguments();
1141
+            return str_replace( array(
1142
+                '<script>',
1143
+                '</script>'
1144
+            ), '', $output );
1145
+        }
1146
+
1147
+        /**
1148
+         * Convert an array of attributes to block string.
1149
+         *
1150
+         * @todo there is prob a faster way to do this, also we could add some validation here.
1151
+         * @param $custom_attributes
1152
+         *
1153
+         * @return string
1154
+         */
1155
+        public function array_to_attributes($custom_attributes, $html = false){
1156
+            $attributes = '';
1157
+            if(!empty($custom_attributes)){
1158
+
1159
+                if($html){
1160
+                    foreach($custom_attributes as $key => $val){
1161
+                        $attributes .= " $key='$val' ";
1162
+                    }
1163
+                }else{
1164
+                    foreach($custom_attributes as $key => $val){
1165
+                        $attributes .= "'$key': '$val',";
1166
+                    }
1167
+                }
1168
+            }
1169
+
1170
+            return $attributes;
1171
+        }
1172
+
1173
+
1174
+        /**
1175
+         * A self looping function to create the output for JS block elements.
1176
+         *
1177
+         * This is what is output in the WP Editor visual view.
1178
+         *
1179
+         * @param $args
1180
+         */
1181
+        public function block_element( $args ) {
1182
+
1183
+
1184
+            if ( ! empty( $args ) ) {
1185
+                foreach ( $args as $element => $new_args ) {
1186
+
1187
+                    if ( is_array( $new_args ) ) { // its an element
1188
+
1189
+
1190
+                        if ( isset( $new_args['element'] ) ) {
1191
+
1192
+                            //print_r($new_args);
1193
+
1194
+                            if ( isset( $new_args['element_require'] ) ) {
1195
+                                echo str_replace( array(
1196
+                                        "'+",
1197
+                                        "+'"
1198
+                                    ), '', $this->block_props_replace( $new_args['element_require'] ) ) . " &&  ";
1199
+                                unset( $new_args['element_require'] );
1200
+                            }
1201
+
1202
+                            echo "\n el( '" . $new_args['element'] . "', {";
1203
+
1204
+                            // get the attributes
1205
+                            foreach ( $new_args as $new_key => $new_value ) {
1206
+
1207
+
1208
+                                if ( $new_key == 'element' || $new_key == 'content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) {
1209
+                                    // do nothing
1210
+                                } else {
1211
+                                    echo $this->block_element( array( $new_key => $new_value ) );
1212
+                                }
1213
+                            }
1214
+
1215
+                            echo "},";// end attributes
1216
+
1217
+                            // get the content
1218
+                            $first_item = 0;
1219
+                            foreach ( $new_args as $new_key => $new_value ) {
1220
+                                if ( $new_key === 'content' || is_array( $new_value ) ) {
1221
+                                    //echo ",".$first_item;// separate the children
1222
+
1223
+
1224
+                                    if ( $first_item > 0 ) {
1225
+                                        //echo ",";// separate the children
1226
+                                    } else {
1227
+                                        //echo '####'.$first_item;
1228
+                                    }
1229
+
1230
+                                    if ( $new_key === 'content' ) {
1231
+                                        //print_r($new_args);
1232
+                                        echo "'" . $this->block_props_replace( $new_value ) . "'";
1233
+                                    }
1234
+
1235
+                                    if ( is_array( $new_value ) ) {
1236
+
1237
+                                        if ( isset( $new_value['element_require'] ) ) {
1238
+                                            echo str_replace( array(
1239
+                                                    "'+",
1240
+                                                    "+'"
1241
+                                                ), '', $this->block_props_replace( $new_value['element_require'] ) ) . " &&  ";
1242
+                                            unset( $new_value['element_require'] );
1243
+                                        }
1244
+
1245
+                                        if ( isset( $new_value['element_repeat'] ) ) {
1246
+                                            $x = 1;
1247
+                                            while ( $x <= absint( $new_value['element_repeat'] ) ) {
1248
+                                                $this->block_element( array( '' => $new_value ) );
1249
+                                                $x ++;
1250
+                                            }
1251
+                                        } else {
1252
+                                            $this->block_element( array( '' => $new_value ) );
1253
+                                        }
1254
+                                        //print_r($new_value);
1255
+                                    }
1256
+                                    $first_item ++;
1257
+                                }
1258
+                            }
1259
+
1260
+                            echo ")";// end content
1261
+
1262
+                            //if($first_item>0){
1263
+                            echo ", \n";
1264
+                            //}
1265
+
1266
+
1267
+                        }
1268
+                        //$this->block_element($new_args);
1269
+                    } else {
1270
+
1271
+                        if ( substr( $element, 0, 3 ) === "if_" ) {
1272
+                            echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ",";
1273
+                        } elseif ( $element == 'style' ) {
1274
+                            echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
1275
+                        } else {
1276
+                            echo $element . ": '" . $this->block_props_replace( $new_args ) . "',";
1277
+                        }
1278
+
1279
+                    }
1280
+
1281
+
1282
+                }
1283
+            }
1284
+        }
1285
+
1286
+        /**
1287
+         * Replace block attributes placeholders with the proper naming.
1288
+         *
1289
+         * @param $string
1290
+         *
1291
+         * @return mixed
1292
+         */
1293
+        public function block_props_replace( $string, $no_wrap = false ) {
1294
+
1295
+            if ( $no_wrap ) {
1296
+                $string = str_replace( array( "[%", "%]" ), array( "props.attributes.", "" ), $string );
1297
+            } else {
1298
+                $string = str_replace( array( "[%", "%]" ), array( "'+props.attributes.", "+'" ), $string );
1299
+            }
1300
+
1301
+            return $string;
1302
+        }
1303
+
1304
+        /**
1305
+         * Outputs the content of the widget
1306
+         *
1307
+         * @param array $args
1308
+         * @param array $instance
1309
+         */
1310
+        public function widget( $args, $instance ) {
1311
+            // outputs the content of the widget
1312
+
1313
+            // get the filtered values
1314
+            $argument_values = $this->argument_values( $instance );
1315
+            $argument_values = $this->string_to_bool( $argument_values );
1316
+            $output = $this->output( $argument_values, $args );
1317
+
1318
+            if ( $output ) {
1319
+                // Before widget
1320
+                $before_widget = $args['before_widget'];
1321
+                $before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this );
1322
+                $before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this );
1323
+
1324
+                // After widget
1325
+                $after_widget = $args['after_widget'];
1326
+                $after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this );
1327
+                $after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this );
1328
+
1329
+                echo $before_widget;
1330
+                echo $this->output_title($args, $instance);
1331
+                echo $output;
1332
+                echo $after_widget;
1333
+            }
1334
+        }
1335
+
1336
+        /**
1337
+         * Output the super title.
1338
+         *
1339
+         * @param $args
1340
+         * @param array $instance
1341
+         *
1342
+         * @return string
1343
+         */
1344
+        public function output_title($args, $instance = array()){
1345
+            $output = '';
1346
+            if ( ! empty( $instance['title'] ) ) {
1347
+                /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
1348
+                $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
1349
+                $output = $args['before_title'] . $title . $args['after_title'];
1350
+            }
1351
+            return $output;
1352
+        }
1353
+
1354
+        /**
1355
+         * Outputs the options form inputs for the widget.
1356
+         *
1357
+         * @param array $instance The widget options.
1358
+         */
1359
+        public function form( $instance ) {
1360
+
1361
+            // set widget instance
1362
+            $this->instance = $instance;
1363
+
1364
+            // set it as a SD widget
1365
+            echo $this->widget_advanced_toggle();
1366
+
1367
+
1368
+            echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>";
1369
+            $arguments = $this->get_arguments();
1370 1370
 //			print_r($instance );
1371 1371
 //			echo '###';
1372 1372
 //			print_r($arguments  );
1373 1373
 
1374
-			if ( is_array( $arguments ) ) {
1375
-				foreach ( $arguments as $key => $args ) {
1376
-					$this->widget_inputs( $args, $instance );
1377
-				}
1378
-			}
1379
-		}
1380
-
1381
-		/**
1382
-		 * Get the hidden input that when added makes the advanced button show on widget settings.
1383
-		 *
1384
-		 * @return string
1385
-		 */
1386
-		public function widget_advanced_toggle() {
1387
-
1388
-			$output = '';
1389
-			if ( $this->block_show_advanced() ) {
1390
-				$val = 1;
1391
-			} else {
1392
-				$val = 0;
1393
-			}
1394
-			if($val){
1374
+            if ( is_array( $arguments ) ) {
1375
+                foreach ( $arguments as $key => $args ) {
1376
+                    $this->widget_inputs( $args, $instance );
1377
+                }
1378
+            }
1379
+        }
1380
+
1381
+        /**
1382
+         * Get the hidden input that when added makes the advanced button show on widget settings.
1383
+         *
1384
+         * @return string
1385
+         */
1386
+        public function widget_advanced_toggle() {
1387
+
1388
+            $output = '';
1389
+            if ( $this->block_show_advanced() ) {
1390
+                $val = 1;
1391
+            } else {
1392
+                $val = 0;
1393
+            }
1394
+            if($val){
1395 1395
 //				$output .=  '<span class="sd-advanced-button-container"><button class="button button-primary right sd-advanced-button" onclick="sd_toggle_advanced(this);return false;"><i class="fas fa-sliders-h" aria-hidden="true"></i></button></span>';
1396
-			}
1396
+            }
1397 1397
 
1398
-			$output .= "<input type='hidden'  class='sd-show-advanced' value='$val' />";
1398
+            $output .= "<input type='hidden'  class='sd-show-advanced' value='$val' />";
1399 1399
 
1400 1400
 
1401 1401
 
1402 1402
 
1403
-			return $output;
1403
+            return $output;
1404 1404
 
1405
-		}
1405
+        }
1406 1406
 
1407
-		/**
1408
-		 * Convert require element.
1409
-		 *
1410
-		 * @since 2.0.0
1411
-		 *
1412
-		 * @param string $input Input element.
1413
-		 * @return string $output
1414
-		 */
1415
-		public function convert_element_require( $input ) {
1407
+        /**
1408
+         * Convert require element.
1409
+         *
1410
+         * @since 2.0.0
1411
+         *
1412
+         * @param string $input Input element.
1413
+         * @return string $output
1414
+         */
1415
+        public function convert_element_require( $input ) {
1416 1416
 
1417
-			$input = str_replace( "'", '"', $input );// we only want double quotes
1417
+            $input = str_replace( "'", '"', $input );// we only want double quotes
1418 1418
 
1419
-			$output = esc_attr( str_replace( array( "[%", "%]" ), array(
1420
-				"jQuery(form).find('[data-argument=\"",
1421
-				"\"]').find('input,select').val()"
1422
-			), $input ) );
1419
+            $output = esc_attr( str_replace( array( "[%", "%]" ), array(
1420
+                "jQuery(form).find('[data-argument=\"",
1421
+                "\"]').find('input,select').val()"
1422
+            ), $input ) );
1423 1423
 
1424 1424
 
1425
-			return $output;
1426
-		}
1425
+            return $output;
1426
+        }
1427 1427
 
1428
-		/**
1429
-		 * Builds the inputs for the widget options.
1430
-		 *
1431
-		 * @param $args
1432
-		 * @param $instance
1433
-		 */
1434
-		public function widget_inputs( $args, $instance ) {
1428
+        /**
1429
+         * Builds the inputs for the widget options.
1430
+         *
1431
+         * @param $args
1432
+         * @param $instance
1433
+         */
1434
+        public function widget_inputs( $args, $instance ) {
1435 1435
 
1436 1436
 //print_r($instance );echo '###';
1437 1437
 //print_r($args );
1438
-			$class           = "";
1439
-			$element_require = "";
1440
-			$custom_attributes = "";
1441
-
1442
-			// get value
1443
-			if ( isset( $instance[ $args['name'] ] ) ) {
1444
-				$value = $instance[ $args['name'] ];
1445
-			} elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) {
1446
-				$value = is_array($args['default']) ? array_map("esc_html",$args['default']) : esc_html( $args['default'] );
1447
-			} else {
1448
-				$value = '';
1449
-			}
1450
-
1451
-			// get placeholder
1452
-			if ( ! empty( $args['placeholder'] ) ) {
1453
-				$placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'";
1454
-			} else {
1455
-				$placeholder = '';
1456
-			}
1457
-
1458
-			// get if advanced
1459
-			if ( isset( $args['advanced'] ) && $args['advanced'] ) {
1460
-				$class .= " sd-advanced-setting ";
1461
-			}
1462
-
1463
-			// element_require
1464
-			if ( isset( $args['element_require'] ) && $args['element_require'] ) {
1465
-				$element_require = $args['element_require'];
1466
-			}
1467
-
1468
-			// custom_attributes
1469
-			if( isset( $args['custom_attributes']) && $args['custom_attributes']){
1470
-				$custom_attributes = $this->array_to_attributes($args['custom_attributes'],true);
1471
-			}
1472
-
1473
-
1474
-
1475
-
1476
-			// before wrapper
1477
-			?>
1438
+            $class           = "";
1439
+            $element_require = "";
1440
+            $custom_attributes = "";
1441
+
1442
+            // get value
1443
+            if ( isset( $instance[ $args['name'] ] ) ) {
1444
+                $value = $instance[ $args['name'] ];
1445
+            } elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) {
1446
+                $value = is_array($args['default']) ? array_map("esc_html",$args['default']) : esc_html( $args['default'] );
1447
+            } else {
1448
+                $value = '';
1449
+            }
1450
+
1451
+            // get placeholder
1452
+            if ( ! empty( $args['placeholder'] ) ) {
1453
+                $placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'";
1454
+            } else {
1455
+                $placeholder = '';
1456
+            }
1457
+
1458
+            // get if advanced
1459
+            if ( isset( $args['advanced'] ) && $args['advanced'] ) {
1460
+                $class .= " sd-advanced-setting ";
1461
+            }
1462
+
1463
+            // element_require
1464
+            if ( isset( $args['element_require'] ) && $args['element_require'] ) {
1465
+                $element_require = $args['element_require'];
1466
+            }
1467
+
1468
+            // custom_attributes
1469
+            if( isset( $args['custom_attributes']) && $args['custom_attributes']){
1470
+                $custom_attributes = $this->array_to_attributes($args['custom_attributes'],true);
1471
+            }
1472
+
1473
+
1474
+
1475
+
1476
+            // before wrapper
1477
+            ?>
1478 1478
 			<p class="sd-argument <?php echo esc_attr( $class ); ?>"
1479 1479
 			   data-argument='<?php echo esc_attr( $args['name'] ); ?>'
1480 1480
 			   data-element_require='<?php if ( $element_require ) {
1481
-				   echo $this->convert_element_require( $element_require );
1482
-			   } ?>'
1481
+                    echo $this->convert_element_require( $element_require );
1482
+                } ?>'
1483 1483
 			>
1484 1484
 				<?php
1485 1485
 
1486
-				switch ( $args['type'] ) {
1487
-					//array('text','password','number','email','tel','url','color')
1488
-					case "text":
1489
-					case "password":
1490
-					case "number":
1491
-					case "email":
1492
-					case "tel":
1493
-					case "url":
1494
-					case "color":
1495
-						?>
1486
+                switch ( $args['type'] ) {
1487
+                    //array('text','password','number','email','tel','url','color')
1488
+                    case "text":
1489
+                    case "password":
1490
+                    case "number":
1491
+                    case "email":
1492
+                    case "tel":
1493
+                    case "url":
1494
+                    case "color":
1495
+                        ?>
1496 1496
 						<label
1497 1497
 							for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
1498 1498
 						<input <?php echo $placeholder; ?> class="widefat"
@@ -1503,11 +1503,11 @@  discard block
 block discarded – undo
1503 1503
 							                               value="<?php echo esc_attr( $value ); ?>">
1504 1504
 						<?php
1505 1505
 
1506
-						break;
1507
-					case "select":
1508
-						$multiple = isset( $args['multiple'] ) && $args['multiple']  ? true : false;
1509
-						if($multiple){if(empty($value)){$value = array();}}
1510
-						?>
1506
+                        break;
1507
+                    case "select":
1508
+                        $multiple = isset( $args['multiple'] ) && $args['multiple']  ? true : false;
1509
+                        if($multiple){if(empty($value)){$value = array();}}
1510
+                        ?>
1511 1511
 						<label
1512 1512
 							for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
1513 1513
 						<select <?php echo $placeholder; ?> class="widefat"
@@ -1515,28 +1515,28 @@  discard block
 block discarded – undo
1515 1515
 							                                id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
1516 1516
 							                                name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); if($multiple){echo "[]";}?>"
1517 1517
 							<?php if ($multiple) {
1518
-								echo "multiple";
1519
-							} //@todo not implemented yet due to gutenberg not supporting it
1520
-							?>
1518
+                                echo "multiple";
1519
+                            } //@todo not implemented yet due to gutenberg not supporting it
1520
+                            ?>
1521 1521
 						>
1522 1522
 							<?php
1523 1523
 
1524 1524
 
1525
-							if ( ! empty( $args['options'] ) ) {
1526
-								foreach ( $args['options'] as $val => $label ) {
1525
+                            if ( ! empty( $args['options'] ) ) {
1526
+                                foreach ( $args['options'] as $val => $label ) {
1527 1527
 //									print_r($value);
1528 1528
 //									echo '@@@'.print_r($val,true),'@@@';
1529 1529
 //									echo '###'.$value.'###';
1530
-									if ($multiple) {$selected = in_array($val,$value) ? 'selected="selected"' : ''; }else{$selected = selected( $value, $val, false );}
1531
-									echo "<option value='$val' " . $selected . ">$label</option>";
1532
-								}
1533
-							}
1534
-							?>
1530
+                                    if ($multiple) {$selected = in_array($val,$value) ? 'selected="selected"' : ''; }else{$selected = selected( $value, $val, false );}
1531
+                                    echo "<option value='$val' " . $selected . ">$label</option>";
1532
+                                }
1533
+                            }
1534
+                            ?>
1535 1535
 						</select>
1536 1536
 						<?php
1537
-						break;
1538
-					case "checkbox":
1539
-						?>
1537
+                        break;
1538
+                    case "checkbox":
1539
+                        ?>
1540 1540
 						<input <?php echo $placeholder; ?>
1541 1541
 							<?php checked( 1, $value, true ) ?>
1542 1542
 							<?php echo $custom_attributes;?>
@@ -1546,110 +1546,110 @@  discard block
 block discarded – undo
1546 1546
 						<label
1547 1547
 							for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
1548 1548
 						<?php
1549
-						break;
1550
-					case "hidden":
1551
-						?>
1549
+                        break;
1550
+                    case "hidden":
1551
+                        ?>
1552 1552
 						<input id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
1553 1553
 						       name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="hidden"
1554 1554
 						       value="<?php echo esc_attr( $value ); ?>">
1555 1555
 						<?php
1556
-						break;
1557
-					default:
1558
-						echo "No input type found!"; // @todo we need to add more input types.
1559
-				}
1556
+                        break;
1557
+                    default:
1558
+                        echo "No input type found!"; // @todo we need to add more input types.
1559
+                }
1560 1560
 
1561
-				// after wrapper
1562
-				?>
1561
+                // after wrapper
1562
+                ?>
1563 1563
 			</p>
1564 1564
 			<?php
1565 1565
 
1566
-		}
1567
-
1568
-
1569
-		/**
1570
-		 * Get the widget input description html.
1571
-		 *
1572
-		 * @param $args
1573
-		 *
1574
-		 * @return string
1575
-		 * @todo, need to make its own tooltip script
1576
-		 */
1577
-		public function widget_field_desc( $args ) {
1578
-
1579
-			$description = '';
1580
-			if ( isset( $args['desc'] ) && $args['desc'] ) {
1581
-				if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) {
1582
-					$description = $this->desc_tip( $args['desc'] );
1583
-				} else {
1584
-					$description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>';
1585
-				}
1586
-			}
1587
-
1588
-			return $description;
1589
-		}
1590
-
1591
-
1592
-		/**
1593
-		 * Get the tool tip html.
1594
-		 *
1595
-		 * @param $tip
1596
-		 * @param bool $allow_html
1597
-		 *
1598
-		 * @return string
1599
-		 */
1600
-		function desc_tip( $tip, $allow_html = false ) {
1601
-			if ( $allow_html ) {
1602
-				$tip = $this->sanitize_tooltip( $tip );
1603
-			} else {
1604
-				$tip = esc_attr( $tip );
1605
-			}
1606
-
1607
-			return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
1608
-		}
1609
-
1610
-		/**
1611
-		 * Sanitize a string destined to be a tooltip.
1612
-		 *
1613
-		 * @param string $var
1614
-		 *
1615
-		 * @return string
1616
-		 */
1617
-		public function sanitize_tooltip( $var ) {
1618
-			return htmlspecialchars( wp_kses( html_entity_decode( $var ), array(
1619
-				'br'     => array(),
1620
-				'em'     => array(),
1621
-				'strong' => array(),
1622
-				'small'  => array(),
1623
-				'span'   => array(),
1624
-				'ul'     => array(),
1625
-				'li'     => array(),
1626
-				'ol'     => array(),
1627
-				'p'      => array(),
1628
-			) ) );
1629
-		}
1630
-
1631
-		/**
1632
-		 * Processing widget options on save
1633
-		 *
1634
-		 * @param array $new_instance The new options
1635
-		 * @param array $old_instance The previous options
1636
-		 *
1637
-		 * @return array
1638
-		 * @todo we should add some sanitation here.
1639
-		 */
1640
-		public function update( $new_instance, $old_instance ) {
1566
+        }
1567
+
1568
+
1569
+        /**
1570
+         * Get the widget input description html.
1571
+         *
1572
+         * @param $args
1573
+         *
1574
+         * @return string
1575
+         * @todo, need to make its own tooltip script
1576
+         */
1577
+        public function widget_field_desc( $args ) {
1578
+
1579
+            $description = '';
1580
+            if ( isset( $args['desc'] ) && $args['desc'] ) {
1581
+                if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) {
1582
+                    $description = $this->desc_tip( $args['desc'] );
1583
+                } else {
1584
+                    $description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>';
1585
+                }
1586
+            }
1587
+
1588
+            return $description;
1589
+        }
1590
+
1591
+
1592
+        /**
1593
+         * Get the tool tip html.
1594
+         *
1595
+         * @param $tip
1596
+         * @param bool $allow_html
1597
+         *
1598
+         * @return string
1599
+         */
1600
+        function desc_tip( $tip, $allow_html = false ) {
1601
+            if ( $allow_html ) {
1602
+                $tip = $this->sanitize_tooltip( $tip );
1603
+            } else {
1604
+                $tip = esc_attr( $tip );
1605
+            }
1606
+
1607
+            return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
1608
+        }
1609
+
1610
+        /**
1611
+         * Sanitize a string destined to be a tooltip.
1612
+         *
1613
+         * @param string $var
1614
+         *
1615
+         * @return string
1616
+         */
1617
+        public function sanitize_tooltip( $var ) {
1618
+            return htmlspecialchars( wp_kses( html_entity_decode( $var ), array(
1619
+                'br'     => array(),
1620
+                'em'     => array(),
1621
+                'strong' => array(),
1622
+                'small'  => array(),
1623
+                'span'   => array(),
1624
+                'ul'     => array(),
1625
+                'li'     => array(),
1626
+                'ol'     => array(),
1627
+                'p'      => array(),
1628
+            ) ) );
1629
+        }
1630
+
1631
+        /**
1632
+         * Processing widget options on save
1633
+         *
1634
+         * @param array $new_instance The new options
1635
+         * @param array $old_instance The previous options
1636
+         *
1637
+         * @return array
1638
+         * @todo we should add some sanitation here.
1639
+         */
1640
+        public function update( $new_instance, $old_instance ) {
1641 1641
 //			print_r($new_instance);
1642 1642
 //			print_r($old_instance);
1643 1643
 //			exit;
1644
-			//save the widget
1645
-			$instance = array_merge( (array) $old_instance, (array) $new_instance );
1644
+            //save the widget
1645
+            $instance = array_merge( (array) $old_instance, (array) $new_instance );
1646 1646
 
1647
-			// set widget instance
1648
-			$this->instance = $instance;
1647
+            // set widget instance
1648
+            $this->instance = $instance;
1649 1649
 
1650
-			if(empty($this->arguments)){
1651
-				$this->get_arguments();
1652
-			}
1650
+            if(empty($this->arguments)){
1651
+                $this->get_arguments();
1652
+            }
1653 1653
 
1654 1654
 
1655 1655
 //			print_r($new_instance);
@@ -1658,18 +1658,18 @@  discard block
 block discarded – undo
1658 1658
 //			print_r($this->arguments);
1659 1659
 //			exit;
1660 1660
 
1661
-			// check for checkboxes
1662
-			if ( ! empty( $this->arguments ) ) {
1663
-				foreach ( $this->arguments as $argument ) {
1664
-					if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) {
1665
-						$instance[ $argument['name'] ] = '0';
1666
-					}
1667
-				}
1668
-			}
1661
+            // check for checkboxes
1662
+            if ( ! empty( $this->arguments ) ) {
1663
+                foreach ( $this->arguments as $argument ) {
1664
+                    if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) {
1665
+                        $instance[ $argument['name'] ] = '0';
1666
+                    }
1667
+                }
1668
+            }
1669 1669
 
1670
-			return $instance;
1671
-		}
1670
+            return $instance;
1671
+        }
1672 1672
 
1673
-	}
1673
+    }
1674 1674
 
1675 1675
 }
Please login to merge, or discard this patch.
Spacing   +298 added lines, -298 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
6
-if ( ! class_exists( 'WP_Super_Duper' ) ) {
6
+if (!class_exists('WP_Super_Duper')) {
7 7
 
8 8
 
9 9
 	/**
@@ -28,29 +28,29 @@  discard block
 block discarded – undo
28 28
 		/**
29 29
 		 * Take the array options and use them to build.
30 30
 		 */
31
-		public function __construct( $options ) {
31
+		public function __construct($options) {
32 32
 			global $sd_widgets;
33 33
 
34 34
 
35 35
 
36 36
 			//print_r($options);exit;
37
-			$sd_widgets[$options['base_id']] = array('name'=> $options['name'],'class_name'=>$options['class_name']);
37
+			$sd_widgets[$options['base_id']] = array('name'=> $options['name'], 'class_name'=>$options['class_name']);
38 38
 			$this->base_id = $options['base_id'];
39 39
 			// lets filter the options before we do anything
40
-			$options       = apply_filters( "wp_super_duper_options", $options );
41
-			$options       = apply_filters( "wp_super_duper_options_{$this->base_id}", $options );
42
-			$options       = $this->add_name_from_key( $options );
40
+			$options       = apply_filters("wp_super_duper_options", $options);
41
+			$options       = apply_filters("wp_super_duper_options_{$this->base_id}", $options);
42
+			$options       = $this->add_name_from_key($options);
43 43
 			$this->options = $options;
44 44
 
45 45
 			$this->base_id   = $options['base_id'];
46
-			$this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array();
46
+			$this->arguments = isset($options['arguments']) ? $options['arguments'] : array();
47 47
 
48 48
 
49 49
 			// init parent
50
-			parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] );
50
+			parent::__construct($options['base_id'], $options['name'], $options['widget_ops']);
51 51
 
52 52
 
53
-			if ( isset( $options['class_name'] ) ) {
53
+			if (isset($options['class_name'])) {
54 54
 				// register widget
55 55
 				$this->class_name = $options['class_name'];
56 56
 
@@ -59,16 +59,16 @@  discard block
 block discarded – undo
59 59
 
60 60
 				// register block
61 61
 				//$this->register_block();
62
-				add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) );
62
+				add_action('admin_enqueue_scripts', array($this, 'register_block'));
63 63
 			}
64 64
 
65 65
 			// add the CSS and JS we need ONCE
66 66
 			global $sd_widget_scripts;
67 67
 
68
-			if ( ! $sd_widget_scripts ) {
69
-				wp_add_inline_script( 'admin-widgets', $this->widget_js() );
70
-				wp_add_inline_script( 'customize-controls', $this->widget_js() );
71
-				wp_add_inline_style( 'widgets', $this->widget_css() );
68
+			if (!$sd_widget_scripts) {
69
+				wp_add_inline_script('admin-widgets', $this->widget_js());
70
+				wp_add_inline_script('customize-controls', $this->widget_js());
71
+				wp_add_inline_style('widgets', $this->widget_css());
72 72
 
73 73
 				// seems ashame to add this for one icon but i love it :(
74 74
 				//wp_register_script('font-awesome', 'https://use.fontawesome.com/releases/v5.4.1/js/all.js', array('font-awesome-shim'), $this->version);
@@ -78,14 +78,14 @@  discard block
 block discarded – undo
78 78
 				$sd_widget_scripts = true;
79 79
 
80 80
 				// add shortcode insert button once
81
-				add_action( 'media_buttons',array( $this, 'shortcode_insert_button' ) );
81
+				add_action('media_buttons', array($this, 'shortcode_insert_button'));
82 82
 				//if( !wp_doing_ajax() ){
83
-				add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) );
83
+				add_action('wp_ajax_super_duper_get_widget_settings', array(__CLASS__, 'get_widget_settings'));
84 84
 				//}
85 85
 
86 86
 			}
87 87
 
88
-			do_action( 'wp_super_duper_widget_init', $options, $this );
88
+			do_action('wp_super_duper_widget_init', $options, $this);
89 89
 
90 90
 		}
91 91
 
@@ -94,17 +94,17 @@  discard block
 block discarded – undo
94 94
 		 *
95 95
 		 * @since 2.0.0
96 96
 		 */
97
-		public static function get_widget_settings(){
97
+		public static function get_widget_settings() {
98 98
 			global $sd_widgets;
99 99
 //			print_r($_REQUEST);
100 100
 //			echo '####';
101 101
 
102 102
 			$shortcode = isset($_REQUEST['shortcode']) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes($_REQUEST['shortcode']) : '';
103
-			if(!$shortcode){wp_die();}
104
-			$widget_args = isset($sd_widgets[$shortcode]) ? $sd_widgets[$shortcode] :'';
105
-			if(!$widget_args){wp_die();}
103
+			if (!$shortcode) {wp_die(); }
104
+			$widget_args = isset($sd_widgets[$shortcode]) ? $sd_widgets[$shortcode] : '';
105
+			if (!$widget_args) {wp_die(); }
106 106
 			$class_name = isset($widget_args['class_name']) && $widget_args['class_name'] ? $widget_args['class_name'] : '';
107
-			if(!$class_name){wp_die();}
107
+			if (!$class_name) {wp_die(); }
108 108
 
109 109
 
110 110
 
@@ -120,11 +120,11 @@  discard block
 block discarded – undo
120 120
 			ob_start();
121 121
 			$widget->form(array());
122 122
 			$form = ob_get_clean();
123
-			echo "<form id='$shortcode'>".$form."<div class=\"widget-control-save\"></div></form>";
123
+			echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>";
124 124
 //			echo "<div id='sd-shortcode-output'></div>";
125 125
 
126
-			echo "<style>".$widget->widget_css()."</style>";
127
-			echo "<script>".$widget->widget_js()."</script>";
126
+			echo "<style>" . $widget->widget_css() . "</style>";
127
+			echo "<script>" . $widget->widget_js() . "</script>";
128 128
 			?>
129 129
 			<?php
130 130
 			wp_die();
@@ -138,9 +138,9 @@  discard block
 block discarded – undo
138 138
 		 * @param string $editor_id Optional. Shortcode editor id. Default null.
139 139
 		 * @param string $insert_shortcode_function Optional. Insert shotcode function. Default null.
140 140
 		 */
141
-		public static function shortcode_insert_button($editor_id = '',$insert_shortcode_function=''){
142
-			global $sd_widgets,$shortcode_insert_button_once;
143
-			if($shortcode_insert_button_once){return;}
141
+		public static function shortcode_insert_button($editor_id = '', $insert_shortcode_function = '') {
142
+			global $sd_widgets, $shortcode_insert_button_once;
143
+			if ($shortcode_insert_button_once) {return; }
144 144
 			add_thickbox();
145 145
 			?>
146 146
 			<div id="super-duper-content" style="display:none;">
@@ -148,12 +148,12 @@  discard block
 block discarded – undo
148 148
 				<div class="sd-shortcode-left-wrap">
149 149
 					<?php
150 150
 					//print_r( $sd_widgets );
151
-					asort($sd_widgets );
152
-					if(!empty($sd_widgets)){
151
+					asort($sd_widgets);
152
+					if (!empty($sd_widgets)) {
153 153
 						echo '<select onchange="sd_get_shortcode_options(this);">';
154
-						echo "<option>".__('Select shortcode')."</option>";
155
-						foreach($sd_widgets as $shortcode => $class){
156
-							echo "<option value='".esc_attr($shortcode)."'>".esc_attr($shortcode)." (".esc_attr($class['name']).")</option>";
154
+						echo "<option>" . __('Select shortcode') . "</option>";
155
+						foreach ($sd_widgets as $shortcode => $class) {
156
+							echo "<option value='" . esc_attr($shortcode) . "'>" . esc_attr($shortcode) . " (" . esc_attr($class['name']) . ")</option>";
157 157
 						}
158 158
 						echo "</select>";
159 159
 
@@ -166,15 +166,15 @@  discard block
 block discarded – undo
166 166
 				<div  class="sd-shortcode-right-wrap">
167 167
 					<textarea id='sd-shortcode-output' disabled></textarea>
168 168
 					<div id='sd-shortcode-output-actions'>
169
-						<button class="button" onclick="sd_insert_shortcode()"><?php _e('Insert shortcode');?></button>
170
-						<button class="button" onclick="sd_copy_to_clipboard()"><?php _e('Copy shortcode');?></button>
169
+						<button class="button" onclick="sd_insert_shortcode()"><?php _e('Insert shortcode'); ?></button>
170
+						<button class="button" onclick="sd_copy_to_clipboard()"><?php _e('Copy shortcode'); ?></button>
171 171
 					</div>
172 172
 				</div>
173 173
 
174 174
 			</div>
175 175
 
176 176
 
177
-			<a href="#TB_inline?width=100%&height=550&inlineId=super-duper-content" class="thickbox button super-duper-content-open" title="<?php _e('Add Shortcode');?>"><i class="fas fa-cubes" aria-hidden="true"></i></a>
177
+			<a href="#TB_inline?width=100%&height=550&inlineId=super-duper-content" class="thickbox button super-duper-content-open" title="<?php _e('Add Shortcode'); ?>"><i class="fas fa-cubes" aria-hidden="true"></i></a>
178 178
 
179 179
 			<style>
180 180
 				.sd-shortcode-left-wrap{
@@ -196,9 +196,9 @@  discard block
 block discarded – undo
196 196
 			<script>
197 197
 
198 198
 				<?php
199
-				if(!empty($insert_shortcode_function)){
199
+				if (!empty($insert_shortcode_function)) {
200 200
 					echo $insert_shortcode_function;
201
-				}else{
201
+				} else {
202 202
 
203 203
 				/**
204 204
 				 * Function for super duper insert shortcode.
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 							'shortcode': $short_code,
253 253
 							'attributes': 123,
254 254
 							'post_id': 321,
255
-							'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>'
255
+							'_ajax_nonce': '<?php echo wp_create_nonce('super_duper_output_shortcode'); ?>'
256 256
 						};
257 257
 
258 258
 						jQuery.post(ajaxurl, data, function (response) {
@@ -378,10 +378,10 @@  discard block
 block discarded – undo
378 378
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
379 379
 			 */
380 380
 
381
-			return str_replace( array(
381
+			return str_replace(array(
382 382
 				'<style>',
383 383
 				'</style>'
384
-			), '', $output );
384
+			), '', $output);
385 385
 		}
386 386
 
387 387
 		public function widget_js() {
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
 					});
540 540
 
541 541
 				}
542
-				<?php do_action( 'wp_super_duper_widget_js', $this ); ?>
542
+				<?php do_action('wp_super_duper_widget_js', $this); ?>
543 543
 			</script>
544 544
 			<?php
545 545
 			$output = ob_get_clean();
@@ -548,10 +548,10 @@  discard block
 block discarded – undo
548 548
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
549 549
 			 */
550 550
 
551
-			return str_replace( array(
551
+			return str_replace(array(
552 552
 				'<script>',
553 553
 				'</script>'
554
-			), '', $output );
554
+			), '', $output);
555 555
 		}
556 556
 
557 557
 
@@ -562,14 +562,14 @@  discard block
 block discarded – undo
562 562
 		 *
563 563
 		 * @return mixed
564 564
 		 */
565
-		private function add_name_from_key( $options, $arguments = false ) {
566
-			if ( ! empty( $options['arguments'] ) ) {
567
-				foreach ( $options['arguments'] as $key => $val ) {
568
-					$options['arguments'][ $key ]['name'] = $key;
565
+		private function add_name_from_key($options, $arguments = false) {
566
+			if (!empty($options['arguments'])) {
567
+				foreach ($options['arguments'] as $key => $val) {
568
+					$options['arguments'][$key]['name'] = $key;
569 569
 				}
570
-			} elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) {
571
-				foreach ( $options as $key => $val ) {
572
-					$options[ $key ]['name'] = $key;
570
+			} elseif ($arguments && is_array($options) && !empty($options)) {
571
+				foreach ($options as $key => $val) {
572
+					$options[$key]['name'] = $key;
573 573
 				}
574 574
 			}
575 575
 
@@ -582,8 +582,8 @@  discard block
 block discarded – undo
582 582
 		 * @since 2.0.0
583 583
 		 */
584 584
 		public function register_shortcode() {
585
-			add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) );
586
-			add_action( 'wp_ajax_super_duper_output_shortcode', array( __CLASS__, 'render_shortcode' ) );
585
+			add_shortcode($this->base_id, array($this, 'shortcode_output'));
586
+			add_action('wp_ajax_super_duper_output_shortcode', array(__CLASS__, 'render_shortcode'));
587 587
 		}
588 588
 
589 589
 		/**
@@ -593,33 +593,33 @@  discard block
 block discarded – undo
593 593
 		 */
594 594
 		public static function render_shortcode() {
595 595
 
596
-			check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true );
597
-			if ( ! current_user_can( 'manage_options' ) ) {
596
+			check_ajax_referer('super_duper_output_shortcode', '_ajax_nonce', true);
597
+			if (!current_user_can('manage_options')) {
598 598
 				wp_die();
599 599
 			}
600 600
 
601 601
 			// we might need the $post value here so lets set it.
602
-			if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) {
603
-				$post_obj = get_post( absint( $_POST['post_id'] ) );
604
-				if ( ! empty( $post_obj ) && empty( $post ) ) {
602
+			if (isset($_POST['post_id']) && $_POST['post_id']) {
603
+				$post_obj = get_post(absint($_POST['post_id']));
604
+				if (!empty($post_obj) && empty($post)) {
605 605
 					global $post;
606 606
 					$post = $post_obj;
607 607
 				}
608 608
 			}
609 609
 
610
-			if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) {
611
-				$shortcode_name   = sanitize_title_with_dashes( $_POST['shortcode'] );
612
-				$attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array();
610
+			if (isset($_POST['shortcode']) && $_POST['shortcode']) {
611
+				$shortcode_name   = sanitize_title_with_dashes($_POST['shortcode']);
612
+				$attributes_array = isset($_POST['attributes']) && $_POST['attributes'] ? $_POST['attributes'] : array();
613 613
 				$attributes       = '';
614
-				if ( ! empty( $attributes_array ) ) {
615
-					foreach ( $attributes_array as $key => $value ) {
616
-						$attributes .= " " . sanitize_title_with_dashes( $key ) . "='" . wp_slash( $value ) . "' ";
614
+				if (!empty($attributes_array)) {
615
+					foreach ($attributes_array as $key => $value) {
616
+						$attributes .= " " . sanitize_title_with_dashes($key) . "='" . wp_slash($value) . "' ";
617 617
 					}
618 618
 				}
619 619
 
620 620
 				$shortcode = "[" . $shortcode_name . " " . $attributes . "]";
621 621
 
622
-				echo do_shortcode( $shortcode );
622
+				echo do_shortcode($shortcode);
623 623
 
624 624
 			}
625 625
 			wp_die();
@@ -631,37 +631,37 @@  discard block
 block discarded – undo
631 631
 		 * @param array $args
632 632
 		 * @param string $content
633 633
 		 */
634
-		public function shortcode_output( $args = array(), $content = '' ) {
635
-			$args = self::argument_values( $args );
634
+		public function shortcode_output($args = array(), $content = '') {
635
+			$args = self::argument_values($args);
636 636
 
637 637
 			// add extra argument so we know its a output to gutenberg
638 638
 			//$args
639
-			$args = $this->string_to_bool( $args );
639
+			$args = $this->string_to_bool($args);
640 640
 
641 641
 
642 642
 			$calss = isset($this->options['widget_ops']['classname']) ? esc_attr($this->options['widget_ops']['classname']) : '';
643 643
 
644
-			$calss = apply_filters( 'wp_super_duper_div_classname', $calss, $args, $this );
645
-			$calss = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $calss, $args, $this );
644
+			$calss = apply_filters('wp_super_duper_div_classname', $calss, $args, $this);
645
+			$calss = apply_filters('wp_super_duper_div_classname_' . $this->base_id, $calss, $args, $this);
646 646
 
647
-			$attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
648
-			$attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
647
+			$attrs = apply_filters('wp_super_duper_div_attrs', '', $args, $this);
648
+			$attrs = apply_filters('wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this);
649 649
 
650 650
 			$shortcode_args = array();
651 651
 			$output = '';
652 652
 			$no_wrap = isset($this->options['no_wrap']) && $this->options['no_wrap'] ?  true : false;
653
-			$main_content = $this->output( $args, $shortcode_args, $content );
654
-			if($main_content && !$no_wrap){
653
+			$main_content = $this->output($args, $shortcode_args, $content);
654
+			if ($main_content && !$no_wrap) {
655 655
 				// wrap the shortcode in a dive with the same class as the widget
656
-				$output .= '<div class="'.$calss.'" ' . $attrs . '>';
657
-				if(!empty($args['title'])){
656
+				$output .= '<div class="' . $calss . '" ' . $attrs . '>';
657
+				if (!empty($args['title'])) {
658 658
 					// if its a shortcode and there is a title try to grab the title wrappers
659 659
 					$shortcode_args = array('before_title'=>'', 'after_title' => '');
660
-					if(empty($instance)){
660
+					if (empty($instance)) {
661 661
 						global $wp_registered_sidebars;
662
-						if(!empty($wp_registered_sidebars)){
663
-							foreach($wp_registered_sidebars as $sidebar){
664
-								if(!empty($sidebar['before_title'])){
662
+						if (!empty($wp_registered_sidebars)) {
663
+							foreach ($wp_registered_sidebars as $sidebar) {
664
+								if (!empty($sidebar['before_title'])) {
665 665
 									$shortcode_args['before_title'] = $sidebar['before_title'];
666 666
 									$shortcode_args['after_title'] = $sidebar['after_title'];
667 667
 									break;
@@ -669,11 +669,11 @@  discard block
 block discarded – undo
669 669
 							}
670 670
 						}
671 671
 					}
672
-					$output .= $this->output_title($shortcode_args,$args);
672
+					$output .= $this->output_title($shortcode_args, $args);
673 673
 				}
674 674
 				$output .= $main_content;
675 675
 				$output .= '</div>';
676
-			}elseif($main_content && $no_wrap){
676
+			}elseif ($main_content && $no_wrap) {
677 677
 				$output .= $main_content;
678 678
 			}
679 679
 
@@ -688,13 +688,13 @@  discard block
 block discarded – undo
688 688
 		 *
689 689
 		 * @return mixed
690 690
 		 */
691
-		public function string_to_bool( $options ) {
691
+		public function string_to_bool($options) {
692 692
 			// convert bool strings to booleans
693
-			foreach ( $options as $key => $val ) {
694
-				if ( $val == 'false' ) {
695
-					$options[ $key ] = false;
696
-				} elseif ( $val == 'true' ) {
697
-					$options[ $key ] = true;
693
+			foreach ($options as $key => $val) {
694
+				if ($val == 'false') {
695
+					$options[$key] = false;
696
+				} elseif ($val == 'true') {
697
+					$options[$key] = true;
698 698
 				}
699 699
 			}
700 700
 
@@ -708,24 +708,24 @@  discard block
 block discarded – undo
708 708
 		 *
709 709
 		 * @return array
710 710
 		 */
711
-		public function argument_values( $instance ) {
711
+		public function argument_values($instance) {
712 712
 			$argument_values = array();
713 713
 
714 714
 			// set widget instance
715 715
 			$this->instance = $instance;
716 716
 
717
-			if ( empty( $this->arguments ) ) {
717
+			if (empty($this->arguments)) {
718 718
 				$this->arguments = $this->get_arguments();
719 719
 			}
720 720
 
721
-			if ( ! empty( $this->arguments ) ) {
722
-				foreach ( $this->arguments as $key => $args ) {
721
+			if (!empty($this->arguments)) {
722
+				foreach ($this->arguments as $key => $args) {
723 723
 					// set the input name from the key
724 724
 					$args['name'] = $key;
725 725
 					//
726
-					$argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : '';
727
-					if ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) {
728
-						$argument_values[ $key ] = $args['default'];
726
+					$argument_values[$key] = isset($instance[$key]) ? $instance[$key] : '';
727
+					if ($argument_values[$key] == '' && isset($args['default'])) {
728
+						$argument_values[$key] = $args['default'];
729 729
 					}
730 730
 				}
731 731
 			}
@@ -752,12 +752,12 @@  discard block
 block discarded – undo
752 752
 		 * @return array Get arguments.
753 753
 		 */
754 754
 		public function get_arguments() {
755
-			if ( empty( $this->arguments ) ) {
756
-				$this->arguments =  $this->set_arguments();
755
+			if (empty($this->arguments)) {
756
+				$this->arguments = $this->set_arguments();
757 757
 			}
758 758
 
759
-			$this->arguments = apply_filters('wp_super_duper_arguments',$this->arguments,$this->options, $this->instance);
760
-			$this->arguments = $this->add_name_from_key( $this->arguments, true );
759
+			$this->arguments = apply_filters('wp_super_duper_arguments', $this->arguments, $this->options, $this->instance);
760
+			$this->arguments = $this->add_name_from_key($this->arguments, true);
761 761
 
762 762
 
763 763
 			return $this->arguments;
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
 		 * @param array $widget_args
771 771
 		 * @param string $content
772 772
 		 */
773
-		public function output( $args = array(), $widget_args = array(), $content = '' ) {
773
+		public function output($args = array(), $widget_args = array(), $content = '') {
774 774
 
775 775
 		}
776 776
 
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
 		 * Add the dyanmic block code inline when the wp-block in enqueued.
779 779
 		 */
780 780
 		public function register_block() {
781
-			wp_add_inline_script( 'wp-blocks', $this->block() );
781
+			wp_add_inline_script('wp-blocks', $this->block());
782 782
 		}
783 783
 
784 784
 
@@ -792,13 +792,13 @@  discard block
 block discarded – undo
792 792
 			$show      = false;
793 793
 			$arguments = $this->arguments;
794 794
 
795
-			if(empty($arguments)){
795
+			if (empty($arguments)) {
796 796
 				$arguments = $this->get_arguments();
797 797
 			}
798 798
 
799
-			if ( ! empty( $arguments ) ) {
800
-				foreach ( $arguments as $argument ) {
801
-					if ( isset( $argument['advanced'] ) && $argument['advanced'] ) {
799
+			if (!empty($arguments)) {
800
+				foreach ($arguments as $argument) {
801
+					if (isset($argument['advanced']) && $argument['advanced']) {
802 802
 						$show = true;
803 803
 					}
804 804
 				}
@@ -848,12 +848,12 @@  discard block
 block discarded – undo
848 848
 					 * @return {?WPBlock}          The block, if it has been successfully
849 849
 					 *                             registered; otherwise `undefined`.
850 850
 					 */
851
-					registerBlockType('<?php echo str_replace( "_", "-", sanitize_title_with_dashes( $this->options['textdomain'] ) . '/' . sanitize_title_with_dashes( $this->options['class_name'] ) );  ?>', { // Block name. Block names must be string that contains a namespace prefix. Example: my-plugin/my-custom-block.
852
-						title: '<?php echo $this->options['name'];?>', // Block title.
853
-						description: '<?php echo esc_attr( $this->options['widget_ops']['description'] )?>', // Block title.
854
-						icon: '<?php echo isset( $this->options['block-icon'] ) ? esc_attr( $this->options['block-icon'] ) : 'shield-alt';?>', // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/.
855
-						category: '<?php echo isset( $this->options['block-category'] ) ? esc_attr( $this->options['block-category'] ) : 'common';?>', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed.
856
-						<?php if ( isset( $this->options['block-keywords'] ) ) {
851
+					registerBlockType('<?php echo str_replace("_", "-", sanitize_title_with_dashes($this->options['textdomain']) . '/' . sanitize_title_with_dashes($this->options['class_name'])); ?>', { // Block name. Block names must be string that contains a namespace prefix. Example: my-plugin/my-custom-block.
852
+						title: '<?php echo $this->options['name']; ?>', // Block title.
853
+						description: '<?php echo esc_attr($this->options['widget_ops']['description'])?>', // Block title.
854
+						icon: '<?php echo isset($this->options['block-icon']) ? esc_attr($this->options['block-icon']) : 'shield-alt'; ?>', // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/.
855
+						category: '<?php echo isset($this->options['block-category']) ? esc_attr($this->options['block-category']) : 'common'; ?>', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed.
856
+						<?php if (isset($this->options['block-keywords'])) {
857 857
 						echo "keywords : " . $this->options['block-keywords'] . ",";
858 858
 					}?>
859 859
 
@@ -863,44 +863,44 @@  discard block
 block discarded – undo
863 863
 
864 864
 						$show_alignment = false;
865 865
 
866
-						if ( ! empty( $this->arguments ) ) {
866
+						if (!empty($this->arguments)) {
867 867
 							echo "attributes : {";
868 868
 
869
-							if ( $show_advanced ) {
869
+							if ($show_advanced) {
870 870
 								echo "show_advanced: {";
871 871
 								echo "	type: 'boolean',";
872 872
 								echo "  default: false,";
873 873
 								echo "},";
874 874
 							}
875 875
 
876
-							foreach ( $this->arguments as $key => $args ) {
876
+							foreach ($this->arguments as $key => $args) {
877 877
 
878 878
 								// set if we should show alignment
879
-								if ( $key == 'alignment' ) {
879
+								if ($key == 'alignment') {
880 880
 									$show_alignment = true;
881 881
 								}
882 882
 
883 883
 								$extra = '';
884 884
 
885
-								if ( $args['type'] == 'checkbox' ) {
885
+								if ($args['type'] == 'checkbox') {
886 886
 									$type    = 'boolean';
887
-									$default = isset( $args['default'] ) && "'" . $args['default'] . "'" ? 'true' : 'false';
888
-								} elseif ( $args['type'] == 'number' ) {
887
+									$default = isset($args['default']) && "'" . $args['default'] . "'" ? 'true' : 'false';
888
+								} elseif ($args['type'] == 'number') {
889 889
 									$type    = 'number';
890
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
891
-								} elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) {
890
+									$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
891
+								} elseif ($args['type'] == 'select' && !empty($args['multiple'])) {
892 892
 									$type    = 'array';
893
-									if(is_array($args['default'])){
894
-										$default = isset( $args['default'] ) ? "['" . implode("','", $args['default']) . "']" : "[]";
895
-									}else{
896
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
893
+									if (is_array($args['default'])) {
894
+										$default = isset($args['default']) ? "['" . implode("','", $args['default']) . "']" : "[]";
895
+									} else {
896
+										$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
897 897
 									}
898
-								} elseif ( $args['type'] == 'multiselect' ) {
898
+								} elseif ($args['type'] == 'multiselect') {
899 899
 									$type    = 'array';
900
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
900
+									$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
901 901
 								} else {
902 902
 									$type    = 'string';
903
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
903
+									$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
904 904
 								}
905 905
 								echo $key . " : {";
906 906
 								echo "type : '$type',";
@@ -930,12 +930,12 @@  discard block
 block discarded – undo
930 930
 									is_fetching = true;
931 931
 									var data = {
932 932
 										'action': 'super_duper_output_shortcode',
933
-										'shortcode': '<?php echo $this->options['base_id'];?>',
933
+										'shortcode': '<?php echo $this->options['base_id']; ?>',
934 934
 										'attributes': props.attributes,
935
-										'post_id': <?php global $post; if ( isset( $post->ID ) ) {
935
+										'post_id': <?php global $post; if (isset($post->ID)) {
936 936
 										echo $post->ID;
937 937
 									}?>,
938
-										'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>'
938
+										'_ajax_nonce': '<?php echo wp_create_nonce('super_duper_output_shortcode'); ?>'
939 939
 									};
940 940
 
941 941
 									jQuery.post(ajaxurl, data, function (response) {
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
 
959 959
 								el(wp.editor.BlockControls, {key: 'controls'},
960 960
 
961
-									<?php if($show_alignment){?>
961
+									<?php if ($show_alignment) {?>
962 962
 									el(
963 963
 										wp.editor.AlignmentToolbar,
964 964
 										{
@@ -976,9 +976,9 @@  discard block
 block discarded – undo
976 976
 
977 977
 									<?php
978 978
 
979
-									if(! empty( $this->arguments )){
979
+									if (!empty($this->arguments)) {
980 980
 
981
-									if ( $show_advanced ) {
981
+									if ($show_advanced) {
982 982
 									?>
983 983
 									el(
984 984
 										wp.components.ToggleControl,
@@ -994,68 +994,68 @@  discard block
 block discarded – undo
994 994
 
995 995
 									}
996 996
 
997
-									foreach($this->arguments as $key => $args){
997
+									foreach ($this->arguments as $key => $args) {
998 998
 									$custom_attributes = !empty($args['custom_attributes']) ? $this->array_to_attributes($args['custom_attributes']) : '';
999 999
 									$options = '';
1000 1000
 									$extra = '';
1001 1001
 									$require = '';
1002 1002
 									$onchange = "props.setAttributes({ $key: $key } )";
1003 1003
 									$value = "props.attributes.$key";
1004
-									$text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'color' );
1005
-									if ( in_array( $args['type'], $text_type ) ) {
1004
+									$text_type = array('text', 'password', 'number', 'email', 'tel', 'url', 'color');
1005
+									if (in_array($args['type'], $text_type)) {
1006 1006
 										$type = 'TextControl';
1007
-									} elseif ( $args['type'] == 'checkbox' ) {
1007
+									} elseif ($args['type'] == 'checkbox') {
1008 1008
 										$type = 'CheckboxControl';
1009 1009
 										$extra .= "checked: props.attributes.$key,";
1010 1010
 										$onchange = "props.setAttributes({ $key: ! props.attributes.$key } )";
1011
-									} elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) {
1011
+									} elseif ($args['type'] == 'select' || $args['type'] == 'multiselect') {
1012 1012
 										$type = 'SelectControl';
1013
-										if ( ! empty( $args['options'] ) ) {
1013
+										if (!empty($args['options'])) {
1014 1014
 											$options .= "options  : [";
1015
-											foreach ( $args['options'] as $option_val => $option_label ) {
1016
-												$options .= "{ value : '" . esc_attr( $option_val ) . "',     label : '" . esc_attr( $option_label ) . "'     },";
1015
+											foreach ($args['options'] as $option_val => $option_label) {
1016
+												$options .= "{ value : '" . esc_attr($option_val) . "',     label : '" . esc_attr($option_label) . "'     },";
1017 1017
 											}
1018 1018
 											$options .= "],";
1019 1019
 										}
1020
-										if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
1020
+										if (isset($args['multiple']) && $args['multiple']) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
1021 1021
 											$extra .= ' multiple: true, ';
1022 1022
 											//$onchange = "props.setAttributes({ $key: ['edit'] } )";
1023 1023
 											//$value = "['edit', 'delete']";
1024 1024
 										}
1025
-									} elseif ( $args['type'] == 'alignment' ) {
1025
+									} elseif ($args['type'] == 'alignment') {
1026 1026
 										$type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example
1027 1027
 									} else {
1028
-										continue;// if we have not implemented the control then don't break the JS.
1028
+										continue; // if we have not implemented the control then don't break the JS.
1029 1029
 									}
1030 1030
 
1031 1031
 									// add show only if advanced
1032
-									if ( ! empty( $args['advanced'] ) ) {
1032
+									if (!empty($args['advanced'])) {
1033 1033
 										echo "props.attributes.show_advanced && ";
1034 1034
 									}
1035 1035
 									// add setting require if defined
1036
-									if ( ! empty( $args['element_require'] ) ) {
1037
-										echo $this->block_props_replace( $args['element_require'], true ) . " && ";
1036
+									if (!empty($args['element_require'])) {
1037
+										echo $this->block_props_replace($args['element_require'], true) . " && ";
1038 1038
 									}
1039 1039
 									?>
1040 1040
 									el(
1041
-										wp.components.<?php echo esc_attr( $type );?>,
1041
+										wp.components.<?php echo esc_attr($type); ?>,
1042 1042
 										{
1043
-											label: '<?php echo esc_attr( $args['title'] );?>',
1044
-											help: '<?php if ( isset( $args['desc'] ) ) {
1045
-												echo esc_attr( $args['desc'] );
1043
+											label: '<?php echo esc_attr($args['title']); ?>',
1044
+											help: '<?php if (isset($args['desc'])) {
1045
+												echo esc_attr($args['desc']);
1046 1046
 											}?>',
1047
-											value: <?php echo $value;?>,
1048
-											<?php if ( $type == 'TextControl' && $args['type'] != 'text' ) {
1049
-											echo "type: '" . esc_attr( $args['type'] ) . "',";
1047
+											value: <?php echo $value; ?>,
1048
+											<?php if ($type == 'TextControl' && $args['type'] != 'text') {
1049
+											echo "type: '" . esc_attr($args['type']) . "',";
1050 1050
 										}?>
1051
-											<?php if ( ! empty( $args['placeholder'] ) ) {
1052
-											echo "placeholder: '" . esc_attr( $args['placeholder'] ) . "',";
1051
+											<?php if (!empty($args['placeholder'])) {
1052
+											echo "placeholder: '" . esc_attr($args['placeholder']) . "',";
1053 1053
 										}?>
1054
-											<?php echo $options;?>
1055
-											<?php echo $extra;?>
1056
-											<?php echo $custom_attributes;?>
1057
-											onChange: function ( <?php echo $key;?> ) {
1058
-												<?php echo $onchange;?>
1054
+											<?php echo $options; ?>
1055
+											<?php echo $extra; ?>
1056
+											<?php echo $custom_attributes; ?>
1057
+											onChange: function ( <?php echo $key; ?> ) {
1058
+												<?php echo $onchange; ?>
1059 1059
 											}
1060 1060
 										}
1061 1061
 									),
@@ -1068,9 +1068,9 @@  discard block
 block discarded – undo
1068 1068
 
1069 1069
 								<?php
1070 1070
 								// If the user sets block-output array then build it
1071
-								if ( ! empty( $this->options['block-output'] ) ) {
1072
-								$this->block_element( $this->options['block-output'] );
1073
-							}else{
1071
+								if (!empty($this->options['block-output'])) {
1072
+								$this->block_element($this->options['block-output']);
1073
+							} else {
1074 1074
 								// if no block-output is set then we try and get the shortcode html output via ajax.
1075 1075
 								?>
1076 1076
 								el('div', {
@@ -1094,14 +1094,14 @@  discard block
 block discarded – undo
1094 1094
 							var align = '';
1095 1095
 
1096 1096
 							// build the shortcode.
1097
-							var content = "[<?php echo $this->options['base_id'];?>";
1097
+							var content = "[<?php echo $this->options['base_id']; ?>";
1098 1098
 							<?php
1099 1099
 
1100
-							if(! empty( $this->arguments )){
1101
-							foreach($this->arguments as $key => $args){
1100
+							if (!empty($this->arguments)) {
1101
+							foreach ($this->arguments as $key => $args) {
1102 1102
 							?>
1103
-							if (attr.hasOwnProperty("<?php echo esc_attr( $key );?>")) {
1104
-								content += " <?php echo esc_attr( $key );?>='" + attr.<?php echo esc_attr( $key );?>+ "' ";
1103
+							if (attr.hasOwnProperty("<?php echo esc_attr($key); ?>")) {
1104
+								content += " <?php echo esc_attr($key); ?>='" + attr.<?php echo esc_attr($key); ?>+ "' ";
1105 1105
 							}
1106 1106
 							<?php
1107 1107
 							}
@@ -1138,10 +1138,10 @@  discard block
 block discarded – undo
1138 1138
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1139 1139
 			 */
1140 1140
 
1141
-			return str_replace( array(
1141
+			return str_replace(array(
1142 1142
 				'<script>',
1143 1143
 				'</script>'
1144
-			), '', $output );
1144
+			), '', $output);
1145 1145
 		}
1146 1146
 
1147 1147
 		/**
@@ -1152,16 +1152,16 @@  discard block
 block discarded – undo
1152 1152
 		 *
1153 1153
 		 * @return string
1154 1154
 		 */
1155
-		public function array_to_attributes($custom_attributes, $html = false){
1155
+		public function array_to_attributes($custom_attributes, $html = false) {
1156 1156
 			$attributes = '';
1157
-			if(!empty($custom_attributes)){
1157
+			if (!empty($custom_attributes)) {
1158 1158
 
1159
-				if($html){
1160
-					foreach($custom_attributes as $key => $val){
1159
+				if ($html) {
1160
+					foreach ($custom_attributes as $key => $val) {
1161 1161
 						$attributes .= " $key='$val' ";
1162 1162
 					}
1163
-				}else{
1164
-					foreach($custom_attributes as $key => $val){
1163
+				} else {
1164
+					foreach ($custom_attributes as $key => $val) {
1165 1165
 						$attributes .= "'$key': '$val',";
1166 1166
 					}
1167 1167
 				}
@@ -1178,86 +1178,86 @@  discard block
 block discarded – undo
1178 1178
 		 *
1179 1179
 		 * @param $args
1180 1180
 		 */
1181
-		public function block_element( $args ) {
1181
+		public function block_element($args) {
1182 1182
 
1183 1183
 
1184
-			if ( ! empty( $args ) ) {
1185
-				foreach ( $args as $element => $new_args ) {
1184
+			if (!empty($args)) {
1185
+				foreach ($args as $element => $new_args) {
1186 1186
 
1187
-					if ( is_array( $new_args ) ) { // its an element
1187
+					if (is_array($new_args)) { // its an element
1188 1188
 
1189 1189
 
1190
-						if ( isset( $new_args['element'] ) ) {
1190
+						if (isset($new_args['element'])) {
1191 1191
 
1192 1192
 							//print_r($new_args);
1193 1193
 
1194
-							if ( isset( $new_args['element_require'] ) ) {
1195
-								echo str_replace( array(
1194
+							if (isset($new_args['element_require'])) {
1195
+								echo str_replace(array(
1196 1196
 										"'+",
1197 1197
 										"+'"
1198
-									), '', $this->block_props_replace( $new_args['element_require'] ) ) . " &&  ";
1199
-								unset( $new_args['element_require'] );
1198
+									), '', $this->block_props_replace($new_args['element_require'])) . " &&  ";
1199
+								unset($new_args['element_require']);
1200 1200
 							}
1201 1201
 
1202 1202
 							echo "\n el( '" . $new_args['element'] . "', {";
1203 1203
 
1204 1204
 							// get the attributes
1205
-							foreach ( $new_args as $new_key => $new_value ) {
1205
+							foreach ($new_args as $new_key => $new_value) {
1206 1206
 
1207 1207
 
1208
-								if ( $new_key == 'element' || $new_key == 'content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) {
1208
+								if ($new_key == 'element' || $new_key == 'content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array($new_value)) {
1209 1209
 									// do nothing
1210 1210
 								} else {
1211
-									echo $this->block_element( array( $new_key => $new_value ) );
1211
+									echo $this->block_element(array($new_key => $new_value));
1212 1212
 								}
1213 1213
 							}
1214 1214
 
1215
-							echo "},";// end attributes
1215
+							echo "},"; // end attributes
1216 1216
 
1217 1217
 							// get the content
1218 1218
 							$first_item = 0;
1219
-							foreach ( $new_args as $new_key => $new_value ) {
1220
-								if ( $new_key === 'content' || is_array( $new_value ) ) {
1219
+							foreach ($new_args as $new_key => $new_value) {
1220
+								if ($new_key === 'content' || is_array($new_value)) {
1221 1221
 									//echo ",".$first_item;// separate the children
1222 1222
 
1223 1223
 
1224
-									if ( $first_item > 0 ) {
1224
+									if ($first_item > 0) {
1225 1225
 										//echo ",";// separate the children
1226 1226
 									} else {
1227 1227
 										//echo '####'.$first_item;
1228 1228
 									}
1229 1229
 
1230
-									if ( $new_key === 'content' ) {
1230
+									if ($new_key === 'content') {
1231 1231
 										//print_r($new_args);
1232
-										echo "'" . $this->block_props_replace( $new_value ) . "'";
1232
+										echo "'" . $this->block_props_replace($new_value) . "'";
1233 1233
 									}
1234 1234
 
1235
-									if ( is_array( $new_value ) ) {
1235
+									if (is_array($new_value)) {
1236 1236
 
1237
-										if ( isset( $new_value['element_require'] ) ) {
1238
-											echo str_replace( array(
1237
+										if (isset($new_value['element_require'])) {
1238
+											echo str_replace(array(
1239 1239
 													"'+",
1240 1240
 													"+'"
1241
-												), '', $this->block_props_replace( $new_value['element_require'] ) ) . " &&  ";
1242
-											unset( $new_value['element_require'] );
1241
+												), '', $this->block_props_replace($new_value['element_require'])) . " &&  ";
1242
+											unset($new_value['element_require']);
1243 1243
 										}
1244 1244
 
1245
-										if ( isset( $new_value['element_repeat'] ) ) {
1245
+										if (isset($new_value['element_repeat'])) {
1246 1246
 											$x = 1;
1247
-											while ( $x <= absint( $new_value['element_repeat'] ) ) {
1248
-												$this->block_element( array( '' => $new_value ) );
1249
-												$x ++;
1247
+											while ($x <= absint($new_value['element_repeat'])) {
1248
+												$this->block_element(array('' => $new_value));
1249
+												$x++;
1250 1250
 											}
1251 1251
 										} else {
1252
-											$this->block_element( array( '' => $new_value ) );
1252
+											$this->block_element(array('' => $new_value));
1253 1253
 										}
1254 1254
 										//print_r($new_value);
1255 1255
 									}
1256
-									$first_item ++;
1256
+									$first_item++;
1257 1257
 								}
1258 1258
 							}
1259 1259
 
1260
-							echo ")";// end content
1260
+							echo ")"; // end content
1261 1261
 
1262 1262
 							//if($first_item>0){
1263 1263
 							echo ", \n";
@@ -1268,12 +1268,12 @@  discard block
 block discarded – undo
1268 1268
 						//$this->block_element($new_args);
1269 1269
 					} else {
1270 1270
 
1271
-						if ( substr( $element, 0, 3 ) === "if_" ) {
1272
-							echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ",";
1273
-						} elseif ( $element == 'style' ) {
1274
-							echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
1271
+						if (substr($element, 0, 3) === "if_") {
1272
+							echo str_replace("if_", "", $element) . ": " . $this->block_props_replace($new_args, true) . ",";
1273
+						} elseif ($element == 'style') {
1274
+							echo $element . ": " . $this->block_props_replace($new_args) . ",";
1275 1275
 						} else {
1276
-							echo $element . ": '" . $this->block_props_replace( $new_args ) . "',";
1276
+							echo $element . ": '" . $this->block_props_replace($new_args) . "',";
1277 1277
 						}
1278 1278
 
1279 1279
 					}
@@ -1290,12 +1290,12 @@  discard block
 block discarded – undo
1290 1290
 		 *
1291 1291
 		 * @return mixed
1292 1292
 		 */
1293
-		public function block_props_replace( $string, $no_wrap = false ) {
1293
+		public function block_props_replace($string, $no_wrap = false) {
1294 1294
 
1295
-			if ( $no_wrap ) {
1296
-				$string = str_replace( array( "[%", "%]" ), array( "props.attributes.", "" ), $string );
1295
+			if ($no_wrap) {
1296
+				$string = str_replace(array("[%", "%]"), array("props.attributes.", ""), $string);
1297 1297
 			} else {
1298
-				$string = str_replace( array( "[%", "%]" ), array( "'+props.attributes.", "+'" ), $string );
1298
+				$string = str_replace(array("[%", "%]"), array("'+props.attributes.", "+'"), $string);
1299 1299
 			}
1300 1300
 
1301 1301
 			return $string;
@@ -1307,24 +1307,24 @@  discard block
 block discarded – undo
1307 1307
 		 * @param array $args
1308 1308
 		 * @param array $instance
1309 1309
 		 */
1310
-		public function widget( $args, $instance ) {
1310
+		public function widget($args, $instance) {
1311 1311
 			// outputs the content of the widget
1312 1312
 
1313 1313
 			// get the filtered values
1314
-			$argument_values = $this->argument_values( $instance );
1315
-			$argument_values = $this->string_to_bool( $argument_values );
1316
-			$output = $this->output( $argument_values, $args );
1314
+			$argument_values = $this->argument_values($instance);
1315
+			$argument_values = $this->string_to_bool($argument_values);
1316
+			$output = $this->output($argument_values, $args);
1317 1317
 
1318
-			if ( $output ) {
1318
+			if ($output) {
1319 1319
 				// Before widget
1320 1320
 				$before_widget = $args['before_widget'];
1321
-				$before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this );
1322
-				$before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this );
1321
+				$before_widget = apply_filters('wp_super_duper_before_widget', $before_widget, $args, $instance, $this);
1322
+				$before_widget = apply_filters('wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this);
1323 1323
 
1324 1324
 				// After widget
1325 1325
 				$after_widget = $args['after_widget'];
1326
-				$after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this );
1327
-				$after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this );
1326
+				$after_widget = apply_filters('wp_super_duper_after_widget', $after_widget, $args, $instance, $this);
1327
+				$after_widget = apply_filters('wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this);
1328 1328
 
1329 1329
 				echo $before_widget;
1330 1330
 				echo $this->output_title($args, $instance);
@@ -1341,11 +1341,11 @@  discard block
 block discarded – undo
1341 1341
 		 *
1342 1342
 		 * @return string
1343 1343
 		 */
1344
-		public function output_title($args, $instance = array()){
1344
+		public function output_title($args, $instance = array()) {
1345 1345
 			$output = '';
1346
-			if ( ! empty( $instance['title'] ) ) {
1346
+			if (!empty($instance['title'])) {
1347 1347
 				/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
1348
-				$title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
1348
+				$title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
1349 1349
 				$output = $args['before_title'] . $title . $args['after_title'];
1350 1350
 			}
1351 1351
 			return $output;
@@ -1356,7 +1356,7 @@  discard block
 block discarded – undo
1356 1356
 		 *
1357 1357
 		 * @param array $instance The widget options.
1358 1358
 		 */
1359
-		public function form( $instance ) {
1359
+		public function form($instance) {
1360 1360
 
1361 1361
 			// set widget instance
1362 1362
 			$this->instance = $instance;
@@ -1365,15 +1365,15 @@  discard block
 block discarded – undo
1365 1365
 			echo $this->widget_advanced_toggle();
1366 1366
 
1367 1367
 
1368
-			echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>";
1368
+			echo "<p>" . esc_attr($this->options['widget_ops']['description']) . "</p>";
1369 1369
 			$arguments = $this->get_arguments();
1370 1370
 //			print_r($instance );
1371 1371
 //			echo '###';
1372 1372
 //			print_r($arguments  );
1373 1373
 
1374
-			if ( is_array( $arguments ) ) {
1375
-				foreach ( $arguments as $key => $args ) {
1376
-					$this->widget_inputs( $args, $instance );
1374
+			if (is_array($arguments)) {
1375
+				foreach ($arguments as $key => $args) {
1376
+					$this->widget_inputs($args, $instance);
1377 1377
 				}
1378 1378
 			}
1379 1379
 		}
@@ -1386,12 +1386,12 @@  discard block
 block discarded – undo
1386 1386
 		public function widget_advanced_toggle() {
1387 1387
 
1388 1388
 			$output = '';
1389
-			if ( $this->block_show_advanced() ) {
1389
+			if ($this->block_show_advanced()) {
1390 1390
 				$val = 1;
1391 1391
 			} else {
1392 1392
 				$val = 0;
1393 1393
 			}
1394
-			if($val){
1394
+			if ($val) {
1395 1395
 //				$output .=  '<span class="sd-advanced-button-container"><button class="button button-primary right sd-advanced-button" onclick="sd_toggle_advanced(this);return false;"><i class="fas fa-sliders-h" aria-hidden="true"></i></button></span>';
1396 1396
 			}
1397 1397
 
@@ -1412,14 +1412,14 @@  discard block
 block discarded – undo
1412 1412
 		 * @param string $input Input element.
1413 1413
 		 * @return string $output
1414 1414
 		 */
1415
-		public function convert_element_require( $input ) {
1415
+		public function convert_element_require($input) {
1416 1416
 
1417
-			$input = str_replace( "'", '"', $input );// we only want double quotes
1417
+			$input = str_replace("'", '"', $input); // we only want double quotes
1418 1418
 
1419
-			$output = esc_attr( str_replace( array( "[%", "%]" ), array(
1419
+			$output = esc_attr(str_replace(array("[%", "%]"), array(
1420 1420
 				"jQuery(form).find('[data-argument=\"",
1421 1421
 				"\"]').find('input,select').val()"
1422
-			), $input ) );
1422
+			), $input));
1423 1423
 
1424 1424
 
1425 1425
 			return $output;
@@ -1431,7 +1431,7 @@  discard block
 block discarded – undo
1431 1431
 		 * @param $args
1432 1432
 		 * @param $instance
1433 1433
 		 */
1434
-		public function widget_inputs( $args, $instance ) {
1434
+		public function widget_inputs($args, $instance) {
1435 1435
 
1436 1436
 //print_r($instance );echo '###';
1437 1437
 //print_r($args );
@@ -1440,34 +1440,34 @@  discard block
 block discarded – undo
1440 1440
 			$custom_attributes = "";
1441 1441
 
1442 1442
 			// get value
1443
-			if ( isset( $instance[ $args['name'] ] ) ) {
1444
-				$value = $instance[ $args['name'] ];
1445
-			} elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) {
1446
-				$value = is_array($args['default']) ? array_map("esc_html",$args['default']) : esc_html( $args['default'] );
1443
+			if (isset($instance[$args['name']])) {
1444
+				$value = $instance[$args['name']];
1445
+			} elseif (!isset($instance[$args['name']]) && !empty($args['default'])) {
1446
+				$value = is_array($args['default']) ? array_map("esc_html", $args['default']) : esc_html($args['default']);
1447 1447
 			} else {
1448 1448
 				$value = '';
1449 1449
 			}
1450 1450
 
1451 1451
 			// get placeholder
1452
-			if ( ! empty( $args['placeholder'] ) ) {
1453
-				$placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'";
1452
+			if (!empty($args['placeholder'])) {
1453
+				$placeholder = "placeholder='" . esc_html($args['placeholder']) . "'";
1454 1454
 			} else {
1455 1455
 				$placeholder = '';
1456 1456
 			}
1457 1457
 
1458 1458
 			// get if advanced
1459
-			if ( isset( $args['advanced'] ) && $args['advanced'] ) {
1459
+			if (isset($args['advanced']) && $args['advanced']) {
1460 1460
 				$class .= " sd-advanced-setting ";
1461 1461
 			}
1462 1462
 
1463 1463
 			// element_require
1464
-			if ( isset( $args['element_require'] ) && $args['element_require'] ) {
1464
+			if (isset($args['element_require']) && $args['element_require']) {
1465 1465
 				$element_require = $args['element_require'];
1466 1466
 			}
1467 1467
 
1468 1468
 			// custom_attributes
1469
-			if( isset( $args['custom_attributes']) && $args['custom_attributes']){
1470
-				$custom_attributes = $this->array_to_attributes($args['custom_attributes'],true);
1469
+			if (isset($args['custom_attributes']) && $args['custom_attributes']) {
1470
+				$custom_attributes = $this->array_to_attributes($args['custom_attributes'], true);
1471 1471
 			}
1472 1472
 
1473 1473
 
@@ -1475,15 +1475,15 @@  discard block
 block discarded – undo
1475 1475
 
1476 1476
 			// before wrapper
1477 1477
 			?>
1478
-			<p class="sd-argument <?php echo esc_attr( $class ); ?>"
1479
-			   data-argument='<?php echo esc_attr( $args['name'] ); ?>'
1480
-			   data-element_require='<?php if ( $element_require ) {
1481
-				   echo $this->convert_element_require( $element_require );
1478
+			<p class="sd-argument <?php echo esc_attr($class); ?>"
1479
+			   data-argument='<?php echo esc_attr($args['name']); ?>'
1480
+			   data-element_require='<?php if ($element_require) {
1481
+				   echo $this->convert_element_require($element_require);
1482 1482
 			   } ?>'
1483 1483
 			>
1484 1484
 				<?php
1485 1485
 
1486
-				switch ( $args['type'] ) {
1486
+				switch ($args['type']) {
1487 1487
 					//array('text','password','number','email','tel','url','color')
1488 1488
 					case "text":
1489 1489
 					case "password":
@@ -1494,26 +1494,26 @@  discard block
 block discarded – undo
1494 1494
 					case "color":
1495 1495
 						?>
1496 1496
 						<label
1497
-							for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
1497
+							for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo esc_attr($args['title']); ?><?php echo $this->widget_field_desc($args); ?></label>
1498 1498
 						<input <?php echo $placeholder; ?> class="widefat"
1499
-							<?php echo $custom_attributes;?>
1500
-							                               id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
1501
-							                               name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>"
1502
-							                               type="<?php echo esc_attr( $args['type'] ); ?>"
1503
-							                               value="<?php echo esc_attr( $value ); ?>">
1499
+							<?php echo $custom_attributes; ?>
1500
+							                               id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"
1501
+							                               name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>"
1502
+							                               type="<?php echo esc_attr($args['type']); ?>"
1503
+							                               value="<?php echo esc_attr($value); ?>">
1504 1504
 						<?php
1505 1505
 
1506 1506
 						break;
1507 1507
 					case "select":
1508
-						$multiple = isset( $args['multiple'] ) && $args['multiple']  ? true : false;
1509
-						if($multiple){if(empty($value)){$value = array();}}
1508
+						$multiple = isset($args['multiple']) && $args['multiple'] ? true : false;
1509
+						if ($multiple) {if (empty($value)) {$value = array(); }}
1510 1510
 						?>
1511 1511
 						<label
1512
-							for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
1512
+							for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo esc_attr($args['title']); ?><?php echo $this->widget_field_desc($args); ?></label>
1513 1513
 						<select <?php echo $placeholder; ?> class="widefat"
1514
-							<?php echo $custom_attributes;?>
1515
-							                                id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
1516
-							                                name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); if($multiple){echo "[]";}?>"
1514
+							<?php echo $custom_attributes; ?>
1515
+							                                id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"
1516
+							                                name="<?php echo esc_attr($this->get_field_name($args['name'])); if ($multiple) {echo "[]"; }?>"
1517 1517
 							<?php if ($multiple) {
1518 1518
 								echo "multiple";
1519 1519
 							} //@todo not implemented yet due to gutenberg not supporting it
@@ -1522,12 +1522,12 @@  discard block
 block discarded – undo
1522 1522
 							<?php
1523 1523
 
1524 1524
 
1525
-							if ( ! empty( $args['options'] ) ) {
1526
-								foreach ( $args['options'] as $val => $label ) {
1525
+							if (!empty($args['options'])) {
1526
+								foreach ($args['options'] as $val => $label) {
1527 1527
 //									print_r($value);
1528 1528
 //									echo '@@@'.print_r($val,true),'@@@';
1529 1529
 //									echo '###'.$value.'###';
1530
-									if ($multiple) {$selected = in_array($val,$value) ? 'selected="selected"' : ''; }else{$selected = selected( $value, $val, false );}
1530
+									if ($multiple) {$selected = in_array($val, $value) ? 'selected="selected"' : ''; } else {$selected = selected($value, $val, false); }
1531 1531
 									echo "<option value='$val' " . $selected . ">$label</option>";
1532 1532
 								}
1533 1533
 							}
@@ -1538,20 +1538,20 @@  discard block
 block discarded – undo
1538 1538
 					case "checkbox":
1539 1539
 						?>
1540 1540
 						<input <?php echo $placeholder; ?>
1541
-							<?php checked( 1, $value, true ) ?>
1542
-							<?php echo $custom_attributes;?>
1543
-							class="widefat" id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
1544
-							name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="checkbox"
1541
+							<?php checked(1, $value, true) ?>
1542
+							<?php echo $custom_attributes; ?>
1543
+							class="widefat" id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"
1544
+							name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" type="checkbox"
1545 1545
 							value="1">
1546 1546
 						<label
1547
-							for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
1547
+							for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo esc_attr($args['title']); ?><?php echo $this->widget_field_desc($args); ?></label>
1548 1548
 						<?php
1549 1549
 						break;
1550 1550
 					case "hidden":
1551 1551
 						?>
1552
-						<input id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
1553
-						       name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="hidden"
1554
-						       value="<?php echo esc_attr( $value ); ?>">
1552
+						<input id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"
1553
+						       name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" type="hidden"
1554
+						       value="<?php echo esc_attr($value); ?>">
1555 1555
 						<?php
1556 1556
 						break;
1557 1557
 					default:
@@ -1574,14 +1574,14 @@  discard block
 block discarded – undo
1574 1574
 		 * @return string
1575 1575
 		 * @todo, need to make its own tooltip script
1576 1576
 		 */
1577
-		public function widget_field_desc( $args ) {
1577
+		public function widget_field_desc($args) {
1578 1578
 
1579 1579
 			$description = '';
1580
-			if ( isset( $args['desc'] ) && $args['desc'] ) {
1581
-				if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) {
1582
-					$description = $this->desc_tip( $args['desc'] );
1580
+			if (isset($args['desc']) && $args['desc']) {
1581
+				if (isset($args['desc_tip']) && $args['desc_tip']) {
1582
+					$description = $this->desc_tip($args['desc']);
1583 1583
 				} else {
1584
-					$description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>';
1584
+					$description = '<span class="description">' . wp_kses_post($args['desc']) . '</span>';
1585 1585
 				}
1586 1586
 			}
1587 1587
 
@@ -1597,11 +1597,11 @@  discard block
 block discarded – undo
1597 1597
 		 *
1598 1598
 		 * @return string
1599 1599
 		 */
1600
-		function desc_tip( $tip, $allow_html = false ) {
1601
-			if ( $allow_html ) {
1602
-				$tip = $this->sanitize_tooltip( $tip );
1600
+		function desc_tip($tip, $allow_html = false) {
1601
+			if ($allow_html) {
1602
+				$tip = $this->sanitize_tooltip($tip);
1603 1603
 			} else {
1604
-				$tip = esc_attr( $tip );
1604
+				$tip = esc_attr($tip);
1605 1605
 			}
1606 1606
 
1607 1607
 			return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
@@ -1614,8 +1614,8 @@  discard block
 block discarded – undo
1614 1614
 		 *
1615 1615
 		 * @return string
1616 1616
 		 */
1617
-		public function sanitize_tooltip( $var ) {
1618
-			return htmlspecialchars( wp_kses( html_entity_decode( $var ), array(
1617
+		public function sanitize_tooltip($var) {
1618
+			return htmlspecialchars(wp_kses(html_entity_decode($var), array(
1619 1619
 				'br'     => array(),
1620 1620
 				'em'     => array(),
1621 1621
 				'strong' => array(),
@@ -1625,7 +1625,7 @@  discard block
 block discarded – undo
1625 1625
 				'li'     => array(),
1626 1626
 				'ol'     => array(),
1627 1627
 				'p'      => array(),
1628
-			) ) );
1628
+			)));
1629 1629
 		}
1630 1630
 
1631 1631
 		/**
@@ -1637,17 +1637,17 @@  discard block
 block discarded – undo
1637 1637
 		 * @return array
1638 1638
 		 * @todo we should add some sanitation here.
1639 1639
 		 */
1640
-		public function update( $new_instance, $old_instance ) {
1640
+		public function update($new_instance, $old_instance) {
1641 1641
 //			print_r($new_instance);
1642 1642
 //			print_r($old_instance);
1643 1643
 //			exit;
1644 1644
 			//save the widget
1645
-			$instance = array_merge( (array) $old_instance, (array) $new_instance );
1645
+			$instance = array_merge((array)$old_instance, (array)$new_instance);
1646 1646
 
1647 1647
 			// set widget instance
1648 1648
 			$this->instance = $instance;
1649 1649
 
1650
-			if(empty($this->arguments)){
1650
+			if (empty($this->arguments)) {
1651 1651
 				$this->get_arguments();
1652 1652
 			}
1653 1653
 
@@ -1659,10 +1659,10 @@  discard block
 block discarded – undo
1659 1659
 //			exit;
1660 1660
 
1661 1661
 			// check for checkboxes
1662
-			if ( ! empty( $this->arguments ) ) {
1663
-				foreach ( $this->arguments as $argument ) {
1664
-					if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) {
1665
-						$instance[ $argument['name'] ] = '0';
1662
+			if (!empty($this->arguments)) {
1663
+				foreach ($this->arguments as $argument) {
1664
+					if (isset($argument['type']) && $argument['type'] == 'checkbox' && !isset($new_instance[$argument['name']])) {
1665
+						$instance[$argument['name']] = '0';
1666 1666
 					}
1667 1667
 				}
1668 1668
 			}
Please login to merge, or discard this patch.
Braces   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 				<?php
199 199
 				if(!empty($insert_shortcode_function)){
200 200
 					echo $insert_shortcode_function;
201
-				}else{
201
+				} else{
202 202
 
203 203
 				/**
204 204
 				 * Function for super duper insert shortcode.
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
 				}
674 674
 				$output .= $main_content;
675 675
 				$output .= '</div>';
676
-			}elseif($main_content && $no_wrap){
676
+			} elseif($main_content && $no_wrap){
677 677
 				$output .= $main_content;
678 678
 			}
679 679
 
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
 									$type    = 'array';
893 893
 									if(is_array($args['default'])){
894 894
 										$default = isset( $args['default'] ) ? "['" . implode("','", $args['default']) . "']" : "[]";
895
-									}else{
895
+									} else{
896 896
 										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
897 897
 									}
898 898
 								} elseif ( $args['type'] == 'multiselect' ) {
@@ -1070,7 +1070,7 @@  discard block
 block discarded – undo
1070 1070
 								// If the user sets block-output array then build it
1071 1071
 								if ( ! empty( $this->options['block-output'] ) ) {
1072 1072
 								$this->block_element( $this->options['block-output'] );
1073
-							}else{
1073
+							} else{
1074 1074
 								// if no block-output is set then we try and get the shortcode html output via ajax.
1075 1075
 								?>
1076 1076
 								el('div', {
@@ -1160,7 +1160,7 @@  discard block
 block discarded – undo
1160 1160
 					foreach($custom_attributes as $key => $val){
1161 1161
 						$attributes .= " $key='$val' ";
1162 1162
 					}
1163
-				}else{
1163
+				} else{
1164 1164
 					foreach($custom_attributes as $key => $val){
1165 1165
 						$attributes .= "'$key': '$val',";
1166 1166
 					}
@@ -1527,7 +1527,7 @@  discard block
 block discarded – undo
1527 1527
 //									print_r($value);
1528 1528
 //									echo '@@@'.print_r($val,true),'@@@';
1529 1529
 //									echo '###'.$value.'###';
1530
-									if ($multiple) {$selected = in_array($val,$value) ? 'selected="selected"' : ''; }else{$selected = selected( $value, $val, false );}
1530
+									if ($multiple) {$selected = in_array($val,$value) ? 'selected="selected"' : ''; } else{$selected = selected( $value, $val, false );}
1531 1531
 									echo "<option value='$val' " . $selected . ">$label</option>";
1532 1532
 								}
1533 1533
 							}
Please login to merge, or discard this patch.
vendor/composer/autoload_static.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -28,6 +28,9 @@
 block discarded – undo
28 28
         'WP_Super_Duper' => __DIR__ . '/..' . '/ayecode/wp-super-duper/wp-super-duper.php',
29 29
     );
30 30
 
31
+    /**
32
+     * @return callable
33
+     */
31 34
     public static function getInitializer(ClassLoader $loader)
32 35
     {
33 36
         return \Closure::bind(function () use ($loader) {
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -6,31 +6,31 @@
 block discarded – undo
6 6
 
7 7
 class ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5
8 8
 {
9
-    public static $files = array (
9
+    public static $files = array(
10 10
         '24583d3588ebda5228dd453cfaa070da' => __DIR__ . '/..' . '/ayecode/wp-font-awesome-settings/wp-font-awesome-settings.php',
11 11
     );
12 12
 
13
-    public static $prefixLengthsPsr4 = array (
13
+    public static $prefixLengthsPsr4 = array(
14 14
         'C' => 
15
-        array (
15
+        array(
16 16
             'Composer\\Installers\\' => 20,
17 17
         ),
18 18
     );
19 19
 
20
-    public static $prefixDirsPsr4 = array (
20
+    public static $prefixDirsPsr4 = array(
21 21
         'Composer\\Installers\\' => 
22
-        array (
22
+        array(
23 23
             0 => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers',
24 24
         ),
25 25
     );
26 26
 
27
-    public static $classMap = array (
27
+    public static $classMap = array(
28 28
         'WP_Super_Duper' => __DIR__ . '/..' . '/ayecode/wp-super-duper/wp-super-duper.php',
29 29
     );
30 30
 
31 31
     public static function getInitializer(ClassLoader $loader)
32 32
     {
33
-        return \Closure::bind(function () use ($loader) {
33
+        return \Closure::bind(function() use ($loader) {
34 34
             $loader->prefixLengthsPsr4 = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$prefixLengthsPsr4;
35 35
             $loader->prefixDirsPsr4 = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$prefixDirsPsr4;
36 36
             $loader->classMap = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$classMap;
Please login to merge, or discard this patch.
vendor/composer/ClassLoader.php 2 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -367,6 +367,10 @@
 block discarded – undo
367 367
         return $file;
368 368
     }
369 369
 
370
+    /**
371
+     * @param string $class
372
+     * @param string $ext
373
+     */
370 374
     private function findFileWithExtension($class, $ext)
371 375
     {
372 376
         // PSR-4 lookup
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -111,13 +111,13 @@  discard block
 block discarded – undo
111 111
         if (!$prefix) {
112 112
             if ($prepend) {
113 113
                 $this->fallbackDirsPsr0 = array_merge(
114
-                    (array) $paths,
114
+                    (array)$paths,
115 115
                     $this->fallbackDirsPsr0
116 116
                 );
117 117
             } else {
118 118
                 $this->fallbackDirsPsr0 = array_merge(
119 119
                     $this->fallbackDirsPsr0,
120
-                    (array) $paths
120
+                    (array)$paths
121 121
                 );
122 122
             }
123 123
 
@@ -126,19 +126,19 @@  discard block
 block discarded – undo
126 126
 
127 127
         $first = $prefix[0];
128 128
         if (!isset($this->prefixesPsr0[$first][$prefix])) {
129
-            $this->prefixesPsr0[$first][$prefix] = (array) $paths;
129
+            $this->prefixesPsr0[$first][$prefix] = (array)$paths;
130 130
 
131 131
             return;
132 132
         }
133 133
         if ($prepend) {
134 134
             $this->prefixesPsr0[$first][$prefix] = array_merge(
135
-                (array) $paths,
135
+                (array)$paths,
136 136
                 $this->prefixesPsr0[$first][$prefix]
137 137
             );
138 138
         } else {
139 139
             $this->prefixesPsr0[$first][$prefix] = array_merge(
140 140
                 $this->prefixesPsr0[$first][$prefix],
141
-                (array) $paths
141
+                (array)$paths
142 142
             );
143 143
         }
144 144
     }
@@ -159,13 +159,13 @@  discard block
 block discarded – undo
159 159
             // Register directories for the root namespace.
160 160
             if ($prepend) {
161 161
                 $this->fallbackDirsPsr4 = array_merge(
162
-                    (array) $paths,
162
+                    (array)$paths,
163 163
                     $this->fallbackDirsPsr4
164 164
                 );
165 165
             } else {
166 166
                 $this->fallbackDirsPsr4 = array_merge(
167 167
                     $this->fallbackDirsPsr4,
168
-                    (array) $paths
168
+                    (array)$paths
169 169
                 );
170 170
             }
171 171
         } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
@@ -175,18 +175,18 @@  discard block
 block discarded – undo
175 175
                 throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
176 176
             }
177 177
             $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
178
-            $this->prefixDirsPsr4[$prefix] = (array) $paths;
178
+            $this->prefixDirsPsr4[$prefix] = (array)$paths;
179 179
         } elseif ($prepend) {
180 180
             // Prepend directories for an already registered namespace.
181 181
             $this->prefixDirsPsr4[$prefix] = array_merge(
182
-                (array) $paths,
182
+                (array)$paths,
183 183
                 $this->prefixDirsPsr4[$prefix]
184 184
             );
185 185
         } else {
186 186
             // Append directories for an already registered namespace.
187 187
             $this->prefixDirsPsr4[$prefix] = array_merge(
188 188
                 $this->prefixDirsPsr4[$prefix],
189
-                (array) $paths
189
+                (array)$paths
190 190
             );
191 191
         }
192 192
     }
@@ -201,9 +201,9 @@  discard block
 block discarded – undo
201 201
     public function set($prefix, $paths)
202 202
     {
203 203
         if (!$prefix) {
204
-            $this->fallbackDirsPsr0 = (array) $paths;
204
+            $this->fallbackDirsPsr0 = (array)$paths;
205 205
         } else {
206
-            $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
206
+            $this->prefixesPsr0[$prefix[0]][$prefix] = (array)$paths;
207 207
         }
208 208
     }
209 209
 
@@ -219,14 +219,14 @@  discard block
 block discarded – undo
219 219
     public function setPsr4($prefix, $paths)
220 220
     {
221 221
         if (!$prefix) {
222
-            $this->fallbackDirsPsr4 = (array) $paths;
222
+            $this->fallbackDirsPsr4 = (array)$paths;
223 223
         } else {
224 224
             $length = strlen($prefix);
225 225
             if ('\\' !== $prefix[$length - 1]) {
226 226
                 throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
227 227
             }
228 228
             $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
229
-            $this->prefixDirsPsr4[$prefix] = (array) $paths;
229
+            $this->prefixDirsPsr4[$prefix] = (array)$paths;
230 230
         }
231 231
     }
232 232
 
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
             return false;
343 343
         }
344 344
         if (null !== $this->apcuPrefix) {
345
-            $file = apcu_fetch($this->apcuPrefix.$class, $hit);
345
+            $file = apcu_fetch($this->apcuPrefix . $class, $hit);
346 346
             if ($hit) {
347 347
                 return $file;
348 348
             }
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
         }
357 357
 
358 358
         if (null !== $this->apcuPrefix) {
359
-            apcu_add($this->apcuPrefix.$class, $file);
359
+            apcu_add($this->apcuPrefix . $class, $file);
360 360
         }
361 361
 
362 362
         if (false === $file) {
Please login to merge, or discard this patch.
vendor/ayecode/wp-font-awesome-settings/wp-font-awesome-settings.php 2 patches
Indentation   +340 added lines, -340 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  * Bail if we are not in WP.
14 14
  */
15 15
 if ( ! defined( 'ABSPATH' ) ) {
16
-	exit;
16
+    exit;
17 17
 }
18 18
 
19 19
 /**
@@ -21,272 +21,272 @@  discard block
 block discarded – undo
21 21
  */
22 22
 if ( ! class_exists( 'WP_Font_Awesome_Settings' ) ) {
23 23
 
24
-	/**
25
-	 * A Class to be able to change settings for Font Awesome.
26
-	 *
27
-	 * Class WP_Font_Awesome_Settings
28
-	 * @ver 1.0.7
29
-	 * @todo decide how to implement textdomain
30
-	 */
31
-	class WP_Font_Awesome_Settings {
32
-
33
-		/**
34
-		 * Class version version.
35
-		 *
36
-		 * @var string
37
-		 */
38
-		public $version = '1.0.7';
39
-
40
-		/**
41
-		 * Latest version of Font Awesome at time of publish published.
42
-		 *
43
-		 * @var string
44
-		 */
45
-		public $latest = "5.5.0";
46
-
47
-		/**
48
-		 * The title.
49
-		 *
50
-		 * @var string
51
-		 */
52
-		public $name = 'Font Awesome';
53
-
54
-		/**
55
-		 * Holds the settings values.
56
-		 *
57
-		 * @var array
58
-		 */
59
-		private $settings;
60
-
61
-		/**
62
-		 * WP_Font_Awesome_Settings instance.
63
-		 *
64
-		 * @access private
65
-		 * @since  1.0.0
66
-		 * @var    WP_Font_Awesome_Settings There can be only one!
67
-		 */
68
-		private static $instance = null;
69
-
70
-		/**
71
-		 * Main WP_Font_Awesome_Settings Instance.
72
-		 *
73
-		 * Ensures only one instance of WP_Font_Awesome_Settings is loaded or can be loaded.
74
-		 *
75
-		 * @since 1.0.0
76
-		 * @static
77
-		 * @return WP_Font_Awesome_Settings - Main instance.
78
-		 */
79
-		public static function instance() {
80
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) {
81
-				self::$instance = new WP_Font_Awesome_Settings;
82
-
83
-				add_action( 'init', array( self::$instance, 'init' ) ); // set settings
84
-
85
-				if ( is_admin() ) {
86
-					add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
87
-					add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
88
-				}
89
-
90
-				do_action( 'wp_font_awesome_settings_loaded' );
91
-			}
92
-
93
-			return self::$instance;
94
-		}
95
-
96
-		/**
97
-		 * Initiate the settings and add the required action hooks.
98
-		 */
99
-		public function init() {
100
-			$this->settings = $this->get_settings();
101
-
102
-			if ( $this->settings['type'] == 'CSS' ) {
103
-
104
-				if ( $this->settings['enqueue'] == '' || $this->settings['frontend'] ) {
105
-					add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );//echo '###';exit;
106
-				}
107
-
108
-				if ( $this->settings['enqueue'] == '' || $this->settings['backend'] ) {
109
-					add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
110
-				}
111
-
112
-			} else {
113
-
114
-				if ( $this->settings['enqueue'] == '' || $this->settings['frontend'] ) {
115
-					add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );//echo '###';exit;
116
-				}
117
-
118
-				if ( $this->settings['enqueue'] == '' || $this->settings['backend'] ) {
119
-					add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
120
-				}
121
-			}
122
-
123
-			// remove font awesome if set to do so
124
-			if ( $this->settings['dequeue'] == '1' ) {
125
-				add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 );
126
-			}
127
-
128
-		}
129
-
130
-		/**
131
-		 * Adds the Font Awesome styles.
132
-		 */
133
-		public function enqueue_style() {
134
-			// build url
135
-			$url = $this->get_url();
136
-
137
-			wp_deregister_style( 'font-awesome' ); // deregister in case its already there
138
-			wp_register_style( 'font-awesome', $url, array(), null );
139
-			wp_enqueue_style( 'font-awesome' );
140
-
141
-			if ( $this->settings['shims'] ) {
142
-				$url = $this->get_url( true );
143
-				wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there
144
-				wp_register_style( 'font-awesome-shims', $url, array(), null );
145
-				wp_enqueue_style( 'font-awesome-shims' );
146
-			}
147
-		}
148
-
149
-		/**
150
-		 * Adds the Font Awesome JS.
151
-		 */
152
-		public function enqueue_scripts() {
153
-			// build url
154
-			$url = $this->get_url();
155
-
156
-			wp_deregister_script( 'font-awesome' ); // deregister in case its already there
157
-			wp_register_script( 'font-awesome', $url, array(), null );
158
-			wp_enqueue_script( 'font-awesome' );
159
-
160
-			if ( $this->settings['shims'] ) {
161
-				$url = $this->get_url( true );
162
-				wp_deregister_script( 'font-awesome-shims' ); // deregister in case its already there
163
-				wp_register_script( 'font-awesome-shims', $url, array(), null );
164
-				wp_enqueue_script( 'font-awesome-shims' );
165
-			}
166
-		}
167
-
168
-		/**
169
-		 * Get the url of the Font Awesome files.
170
-		 *
171
-		 * @param bool $shims If this is a shim file or not.
172
-		 *
173
-		 * @return string The url to the file.
174
-		 */
175
-		public function get_url( $shims = false ) {
176
-			$script  = $shims ? 'v4-shims' : 'all';
177
-			$type    = $this->settings['type'];
178
-			$version = $this->settings['version'];
179
-
180
-			$url = "https://use.fontawesome.com/releases/"; // CDN
181
-			$url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
182
-			$url .= $type == 'CSS' ? 'css/' : 'js/'; // type
183
-			$url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type
184
-			$url .= "?wpfas=true"; // set our var so our version is not removed
185
-
186
-			return $url;
187
-		}
188
-
189
-		/**
190
-		 * Try and remove any other versions of Font Awesome added by other plugins/themes.
191
-		 *
192
-		 * Uses the clean_url filter to try and remove any other Font Awesome files added, it can also add pseudo-elements flag for the JS version.
193
-		 *
194
-		 * @param $url
195
-		 * @param $original_url
196
-		 * @param $_context
197
-		 *
198
-		 * @return string The filtered url.
199
-		 */
200
-		public function remove_font_awesome( $url, $original_url, $_context ) {
201
-
202
-			if ( $_context == 'display'
203
-			     && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
204
-			     && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
205
-			) {// it's a font-awesome-url (probably)
206
-
207
-				if ( strstr( $url, "wpfas=true" ) !== false ) {
208
-					if ( $this->settings['type'] == 'JS' ) {
209
-						if ( $this->settings['js-pseudo'] ) {
210
-							$url .= "' data-search-pseudo-elements defer='defer";
211
-						} else {
212
-							$url .= "' defer='defer";
213
-						}
214
-					}
215
-				} else {
216
-					$url = ''; // removing the url removes the file
217
-				}
218
-
219
-			}
220
-
221
-			return $url;
222
-		}
223
-
224
-		/**
225
-		 * Register the database settings with WordPress.
226
-		 */
227
-		public function register_settings() {
228
-			register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' );
229
-		}
230
-
231
-		/**
232
-		 * Add the WordPress settings menu item.
233
-		 */
234
-		public function menu_item() {
235
-			add_options_page( $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
236
-				$this,
237
-				'settings_page'
238
-			) );
239
-		}
240
-
241
-		/**
242
-		 * Get the current Font Awesome output settings.
243
-		 *
244
-		 * @return array The array of settings.
245
-		 */
246
-		public function get_settings() {
247
-
248
-			$db_settings = get_option( 'wp-font-awesome-settings' );
249
-
250
-			$defaults = array(
251
-				'type'      => 'CSS', // type to use, CSS or JS
252
-				'version'   => '', // latest
253
-				'enqueue'   => '', // front and backend
254
-				'shims'     => '1', // default on for now, @todo maybe change to off in 2020
255
-				'js-pseudo' => '0', // if the pseudo elements flag should be set (CPU intensive)
256
-				'dequeue'   => '0', // if we should try to remove other versions added by other plugins/themes
257
-			);
258
-
259
-			$settings = wp_parse_args( $db_settings, $defaults );
260
-
261
-			/**
262
-			 * Filter the Font Awesome settings.
263
-			 *
264
-			 * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
265
-			 */
266
-			return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults );
267
-		}
268
-
269
-
270
-		/**
271
-		 * The settings page html output.
272
-		 */
273
-		public function settings_page() {
274
-			if ( ! current_user_can( 'manage_options' ) ) {
275
-				wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
276
-			}
277
-
278
-			// a hidden way to force the update of the verison number vai api instead of waiting the 48 hours
279
-			if(isset($_REQUEST['force-version-check'])){
280
-				$this->get_latest_version($force_api = true);
281
-			}
282
-			?>
24
+    /**
25
+     * A Class to be able to change settings for Font Awesome.
26
+     *
27
+     * Class WP_Font_Awesome_Settings
28
+     * @ver 1.0.7
29
+     * @todo decide how to implement textdomain
30
+     */
31
+    class WP_Font_Awesome_Settings {
32
+
33
+        /**
34
+         * Class version version.
35
+         *
36
+         * @var string
37
+         */
38
+        public $version = '1.0.7';
39
+
40
+        /**
41
+         * Latest version of Font Awesome at time of publish published.
42
+         *
43
+         * @var string
44
+         */
45
+        public $latest = "5.5.0";
46
+
47
+        /**
48
+         * The title.
49
+         *
50
+         * @var string
51
+         */
52
+        public $name = 'Font Awesome';
53
+
54
+        /**
55
+         * Holds the settings values.
56
+         *
57
+         * @var array
58
+         */
59
+        private $settings;
60
+
61
+        /**
62
+         * WP_Font_Awesome_Settings instance.
63
+         *
64
+         * @access private
65
+         * @since  1.0.0
66
+         * @var    WP_Font_Awesome_Settings There can be only one!
67
+         */
68
+        private static $instance = null;
69
+
70
+        /**
71
+         * Main WP_Font_Awesome_Settings Instance.
72
+         *
73
+         * Ensures only one instance of WP_Font_Awesome_Settings is loaded or can be loaded.
74
+         *
75
+         * @since 1.0.0
76
+         * @static
77
+         * @return WP_Font_Awesome_Settings - Main instance.
78
+         */
79
+        public static function instance() {
80
+            if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) {
81
+                self::$instance = new WP_Font_Awesome_Settings;
82
+
83
+                add_action( 'init', array( self::$instance, 'init' ) ); // set settings
84
+
85
+                if ( is_admin() ) {
86
+                    add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
87
+                    add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
88
+                }
89
+
90
+                do_action( 'wp_font_awesome_settings_loaded' );
91
+            }
92
+
93
+            return self::$instance;
94
+        }
95
+
96
+        /**
97
+         * Initiate the settings and add the required action hooks.
98
+         */
99
+        public function init() {
100
+            $this->settings = $this->get_settings();
101
+
102
+            if ( $this->settings['type'] == 'CSS' ) {
103
+
104
+                if ( $this->settings['enqueue'] == '' || $this->settings['frontend'] ) {
105
+                    add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );//echo '###';exit;
106
+                }
107
+
108
+                if ( $this->settings['enqueue'] == '' || $this->settings['backend'] ) {
109
+                    add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
110
+                }
111
+
112
+            } else {
113
+
114
+                if ( $this->settings['enqueue'] == '' || $this->settings['frontend'] ) {
115
+                    add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );//echo '###';exit;
116
+                }
117
+
118
+                if ( $this->settings['enqueue'] == '' || $this->settings['backend'] ) {
119
+                    add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
120
+                }
121
+            }
122
+
123
+            // remove font awesome if set to do so
124
+            if ( $this->settings['dequeue'] == '1' ) {
125
+                add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 );
126
+            }
127
+
128
+        }
129
+
130
+        /**
131
+         * Adds the Font Awesome styles.
132
+         */
133
+        public function enqueue_style() {
134
+            // build url
135
+            $url = $this->get_url();
136
+
137
+            wp_deregister_style( 'font-awesome' ); // deregister in case its already there
138
+            wp_register_style( 'font-awesome', $url, array(), null );
139
+            wp_enqueue_style( 'font-awesome' );
140
+
141
+            if ( $this->settings['shims'] ) {
142
+                $url = $this->get_url( true );
143
+                wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there
144
+                wp_register_style( 'font-awesome-shims', $url, array(), null );
145
+                wp_enqueue_style( 'font-awesome-shims' );
146
+            }
147
+        }
148
+
149
+        /**
150
+         * Adds the Font Awesome JS.
151
+         */
152
+        public function enqueue_scripts() {
153
+            // build url
154
+            $url = $this->get_url();
155
+
156
+            wp_deregister_script( 'font-awesome' ); // deregister in case its already there
157
+            wp_register_script( 'font-awesome', $url, array(), null );
158
+            wp_enqueue_script( 'font-awesome' );
159
+
160
+            if ( $this->settings['shims'] ) {
161
+                $url = $this->get_url( true );
162
+                wp_deregister_script( 'font-awesome-shims' ); // deregister in case its already there
163
+                wp_register_script( 'font-awesome-shims', $url, array(), null );
164
+                wp_enqueue_script( 'font-awesome-shims' );
165
+            }
166
+        }
167
+
168
+        /**
169
+         * Get the url of the Font Awesome files.
170
+         *
171
+         * @param bool $shims If this is a shim file or not.
172
+         *
173
+         * @return string The url to the file.
174
+         */
175
+        public function get_url( $shims = false ) {
176
+            $script  = $shims ? 'v4-shims' : 'all';
177
+            $type    = $this->settings['type'];
178
+            $version = $this->settings['version'];
179
+
180
+            $url = "https://use.fontawesome.com/releases/"; // CDN
181
+            $url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
182
+            $url .= $type == 'CSS' ? 'css/' : 'js/'; // type
183
+            $url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type
184
+            $url .= "?wpfas=true"; // set our var so our version is not removed
185
+
186
+            return $url;
187
+        }
188
+
189
+        /**
190
+         * Try and remove any other versions of Font Awesome added by other plugins/themes.
191
+         *
192
+         * Uses the clean_url filter to try and remove any other Font Awesome files added, it can also add pseudo-elements flag for the JS version.
193
+         *
194
+         * @param $url
195
+         * @param $original_url
196
+         * @param $_context
197
+         *
198
+         * @return string The filtered url.
199
+         */
200
+        public function remove_font_awesome( $url, $original_url, $_context ) {
201
+
202
+            if ( $_context == 'display'
203
+                 && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
204
+                 && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
205
+            ) {// it's a font-awesome-url (probably)
206
+
207
+                if ( strstr( $url, "wpfas=true" ) !== false ) {
208
+                    if ( $this->settings['type'] == 'JS' ) {
209
+                        if ( $this->settings['js-pseudo'] ) {
210
+                            $url .= "' data-search-pseudo-elements defer='defer";
211
+                        } else {
212
+                            $url .= "' defer='defer";
213
+                        }
214
+                    }
215
+                } else {
216
+                    $url = ''; // removing the url removes the file
217
+                }
218
+
219
+            }
220
+
221
+            return $url;
222
+        }
223
+
224
+        /**
225
+         * Register the database settings with WordPress.
226
+         */
227
+        public function register_settings() {
228
+            register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' );
229
+        }
230
+
231
+        /**
232
+         * Add the WordPress settings menu item.
233
+         */
234
+        public function menu_item() {
235
+            add_options_page( $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
236
+                $this,
237
+                'settings_page'
238
+            ) );
239
+        }
240
+
241
+        /**
242
+         * Get the current Font Awesome output settings.
243
+         *
244
+         * @return array The array of settings.
245
+         */
246
+        public function get_settings() {
247
+
248
+            $db_settings = get_option( 'wp-font-awesome-settings' );
249
+
250
+            $defaults = array(
251
+                'type'      => 'CSS', // type to use, CSS or JS
252
+                'version'   => '', // latest
253
+                'enqueue'   => '', // front and backend
254
+                'shims'     => '1', // default on for now, @todo maybe change to off in 2020
255
+                'js-pseudo' => '0', // if the pseudo elements flag should be set (CPU intensive)
256
+                'dequeue'   => '0', // if we should try to remove other versions added by other plugins/themes
257
+            );
258
+
259
+            $settings = wp_parse_args( $db_settings, $defaults );
260
+
261
+            /**
262
+             * Filter the Font Awesome settings.
263
+             *
264
+             * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
265
+             */
266
+            return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults );
267
+        }
268
+
269
+
270
+        /**
271
+         * The settings page html output.
272
+         */
273
+        public function settings_page() {
274
+            if ( ! current_user_can( 'manage_options' ) ) {
275
+                wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
276
+            }
277
+
278
+            // a hidden way to force the update of the verison number vai api instead of waiting the 48 hours
279
+            if(isset($_REQUEST['force-version-check'])){
280
+                $this->get_latest_version($force_api = true);
281
+            }
282
+            ?>
283 283
 			<div class="wrap">
284 284
 				<h1><?php echo $this->name; ?></h1>
285 285
 				<form method="post" action="options.php">
286 286
 					<?php
287
-					settings_fields( 'wp-font-awesome-settings' );
288
-					do_settings_sections( 'wp-font-awesome-settings' );
289
-					?>
287
+                    settings_fields( 'wp-font-awesome-settings' );
288
+                    do_settings_sections( 'wp-font-awesome-settings' );
289
+                    ?>
290 290
 					<table class="form-table">
291 291
 						<tr valign="top">
292 292
 							<th scope="row"><label for="wpfas-type"><?php _e( 'Type' ); ?></label></th>
@@ -379,87 +379,87 @@  discard block
 block discarded – undo
379 379
 
380 380
 					</table>
381 381
 					<?php
382
-					submit_button();
383
-					?>
382
+                    submit_button();
383
+                    ?>
384 384
 				</form>
385 385
 
386 386
 				<div id="wpfas-version"><?php echo $this->version; ?></div>
387 387
 			</div>
388 388
 
389 389
 			<?php
390
-		}
391
-
392
-		/**
393
-		 * Check a version number is valid and if so return it or else return an empty string.
394
-		 *
395
-		 * @param $version string The version number to check.
396
-		 * @since 1.0.6
397
-		 *
398
-		 * @return string Either a valid version number or an empty string.
399
-		 */
400
-		public function validate_version_number( $version ) {
401
-
402
-			if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) {
403
-				// valid
404
-			} else {
405
-				$version = '';// not validated
406
-			}
407
-
408
-			return $version;
409
-		}
410
-
411
-
412
-		/**
413
-		 * Get the latest version of Font Awesome.
414
-		 *
415
-		 * We check for a cached bersion and if none we will check for a live version via API and then cache it for 48 hours.
416
-		 *
417
-		 * @since 1.0.7
418
-		 * @return mixed|string The latest version number found.
419
-		 */
420
-		public function get_latest_version($force_api = false) {
421
-			$latest_version = $this->latest;
422
-
423
-			$cache = get_transient( 'wp-font-awesome-settings-version' );
424
-
425
-			if ( $cache === false || $force_api) { // its not set
426
-				$api_ver = $this->get_latest_version_from_api();
427
-				if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) {
428
-					$latest_version = $api_ver;
429
-					set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS );
430
-				}
431
-			} elseif ( $this->validate_version_number( $cache ) ) {
432
-				if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) {
433
-					$latest_version = $cache;
434
-				}
435
-			}
436
-
437
-			return $latest_version;
438
-		}
439
-
440
-		/**
441
-		 * Get the latest Font Awesome version from the github API.
442
-		 *
443
-		 * @since 1.0.7
444
-		 * @return string The latest version number or `0` on API fail.
445
-		 */
446
-		public function get_latest_version_from_api() {
447
-			$version  = "0";
448
-			$response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" );
449
-			if ( ! is_wp_error( $response ) && is_array( $response ) ) {
450
-				$api_response = json_decode( wp_remote_retrieve_body( $response ), true );
451
-				if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) {
452
-					$version = $api_response['tag_name'];
453
-				}
454
-			}
455
-
456
-			return $version;
457
-		}
458
-
459
-	}
460
-
461
-	/**
462
-	 * Run the class if found.
463
-	 */
464
-	WP_Font_Awesome_Settings::instance();
390
+        }
391
+
392
+        /**
393
+         * Check a version number is valid and if so return it or else return an empty string.
394
+         *
395
+         * @param $version string The version number to check.
396
+         * @since 1.0.6
397
+         *
398
+         * @return string Either a valid version number or an empty string.
399
+         */
400
+        public function validate_version_number( $version ) {
401
+
402
+            if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) {
403
+                // valid
404
+            } else {
405
+                $version = '';// not validated
406
+            }
407
+
408
+            return $version;
409
+        }
410
+
411
+
412
+        /**
413
+         * Get the latest version of Font Awesome.
414
+         *
415
+         * We check for a cached bersion and if none we will check for a live version via API and then cache it for 48 hours.
416
+         *
417
+         * @since 1.0.7
418
+         * @return mixed|string The latest version number found.
419
+         */
420
+        public function get_latest_version($force_api = false) {
421
+            $latest_version = $this->latest;
422
+
423
+            $cache = get_transient( 'wp-font-awesome-settings-version' );
424
+
425
+            if ( $cache === false || $force_api) { // its not set
426
+                $api_ver = $this->get_latest_version_from_api();
427
+                if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) {
428
+                    $latest_version = $api_ver;
429
+                    set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS );
430
+                }
431
+            } elseif ( $this->validate_version_number( $cache ) ) {
432
+                if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) {
433
+                    $latest_version = $cache;
434
+                }
435
+            }
436
+
437
+            return $latest_version;
438
+        }
439
+
440
+        /**
441
+         * Get the latest Font Awesome version from the github API.
442
+         *
443
+         * @since 1.0.7
444
+         * @return string The latest version number or `0` on API fail.
445
+         */
446
+        public function get_latest_version_from_api() {
447
+            $version  = "0";
448
+            $response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" );
449
+            if ( ! is_wp_error( $response ) && is_array( $response ) ) {
450
+                $api_response = json_decode( wp_remote_retrieve_body( $response ), true );
451
+                if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) {
452
+                    $version = $api_response['tag_name'];
453
+                }
454
+            }
455
+
456
+            return $version;
457
+        }
458
+
459
+    }
460
+
461
+    /**
462
+     * Run the class if found.
463
+     */
464
+    WP_Font_Awesome_Settings::instance();
465 465
 }
466 466
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -12,14 +12,14 @@  discard block
 block discarded – undo
12 12
 /**
13 13
  * Bail if we are not in WP.
14 14
  */
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if (!defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
19 19
 /**
20 20
  * Only add if the class does not already exist.
21 21
  */
22
-if ( ! class_exists( 'WP_Font_Awesome_Settings' ) ) {
22
+if (!class_exists('WP_Font_Awesome_Settings')) {
23 23
 
24 24
 	/**
25 25
 	 * A Class to be able to change settings for Font Awesome.
@@ -77,17 +77,17 @@  discard block
 block discarded – undo
77 77
 		 * @return WP_Font_Awesome_Settings - Main instance.
78 78
 		 */
79 79
 		public static function instance() {
80
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) {
80
+			if (!isset(self::$instance) && !(self::$instance instanceof WP_Font_Awesome_Settings)) {
81 81
 				self::$instance = new WP_Font_Awesome_Settings;
82 82
 
83
-				add_action( 'init', array( self::$instance, 'init' ) ); // set settings
83
+				add_action('init', array(self::$instance, 'init')); // set settings
84 84
 
85
-				if ( is_admin() ) {
86
-					add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
87
-					add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
85
+				if (is_admin()) {
86
+					add_action('admin_menu', array(self::$instance, 'menu_item'));
87
+					add_action('admin_init', array(self::$instance, 'register_settings'));
88 88
 				}
89 89
 
90
-				do_action( 'wp_font_awesome_settings_loaded' );
90
+				do_action('wp_font_awesome_settings_loaded');
91 91
 			}
92 92
 
93 93
 			return self::$instance;
@@ -99,30 +99,30 @@  discard block
 block discarded – undo
99 99
 		public function init() {
100 100
 			$this->settings = $this->get_settings();
101 101
 
102
-			if ( $this->settings['type'] == 'CSS' ) {
102
+			if ($this->settings['type'] == 'CSS') {
103 103
 
104
-				if ( $this->settings['enqueue'] == '' || $this->settings['frontend'] ) {
105
-					add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );//echo '###';exit;
104
+				if ($this->settings['enqueue'] == '' || $this->settings['frontend']) {
105
+					add_action('wp_enqueue_scripts', array($this, 'enqueue_style'), 5000); //echo '###';exit;
106 106
 				}
107 107
 
108
-				if ( $this->settings['enqueue'] == '' || $this->settings['backend'] ) {
109
-					add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
108
+				if ($this->settings['enqueue'] == '' || $this->settings['backend']) {
109
+					add_action('admin_enqueue_scripts', array($this, 'enqueue_style'), 5000);
110 110
 				}
111 111
 
112 112
 			} else {
113 113
 
114
-				if ( $this->settings['enqueue'] == '' || $this->settings['frontend'] ) {
115
-					add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );//echo '###';exit;
114
+				if ($this->settings['enqueue'] == '' || $this->settings['frontend']) {
115
+					add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 5000); //echo '###';exit;
116 116
 				}
117 117
 
118
-				if ( $this->settings['enqueue'] == '' || $this->settings['backend'] ) {
119
-					add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
118
+				if ($this->settings['enqueue'] == '' || $this->settings['backend']) {
119
+					add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'), 5000);
120 120
 				}
121 121
 			}
122 122
 
123 123
 			// remove font awesome if set to do so
124
-			if ( $this->settings['dequeue'] == '1' ) {
125
-				add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 );
124
+			if ($this->settings['dequeue'] == '1') {
125
+				add_action('clean_url', array($this, 'remove_font_awesome'), 5000, 3);
126 126
 			}
127 127
 
128 128
 		}
@@ -134,15 +134,15 @@  discard block
 block discarded – undo
134 134
 			// build url
135 135
 			$url = $this->get_url();
136 136
 
137
-			wp_deregister_style( 'font-awesome' ); // deregister in case its already there
138
-			wp_register_style( 'font-awesome', $url, array(), null );
139
-			wp_enqueue_style( 'font-awesome' );
137
+			wp_deregister_style('font-awesome'); // deregister in case its already there
138
+			wp_register_style('font-awesome', $url, array(), null);
139
+			wp_enqueue_style('font-awesome');
140 140
 
141
-			if ( $this->settings['shims'] ) {
142
-				$url = $this->get_url( true );
143
-				wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there
144
-				wp_register_style( 'font-awesome-shims', $url, array(), null );
145
-				wp_enqueue_style( 'font-awesome-shims' );
141
+			if ($this->settings['shims']) {
142
+				$url = $this->get_url(true);
143
+				wp_deregister_style('font-awesome-shims'); // deregister in case its already there
144
+				wp_register_style('font-awesome-shims', $url, array(), null);
145
+				wp_enqueue_style('font-awesome-shims');
146 146
 			}
147 147
 		}
148 148
 
@@ -153,15 +153,15 @@  discard block
 block discarded – undo
153 153
 			// build url
154 154
 			$url = $this->get_url();
155 155
 
156
-			wp_deregister_script( 'font-awesome' ); // deregister in case its already there
157
-			wp_register_script( 'font-awesome', $url, array(), null );
158
-			wp_enqueue_script( 'font-awesome' );
156
+			wp_deregister_script('font-awesome'); // deregister in case its already there
157
+			wp_register_script('font-awesome', $url, array(), null);
158
+			wp_enqueue_script('font-awesome');
159 159
 
160
-			if ( $this->settings['shims'] ) {
161
-				$url = $this->get_url( true );
162
-				wp_deregister_script( 'font-awesome-shims' ); // deregister in case its already there
163
-				wp_register_script( 'font-awesome-shims', $url, array(), null );
164
-				wp_enqueue_script( 'font-awesome-shims' );
160
+			if ($this->settings['shims']) {
161
+				$url = $this->get_url(true);
162
+				wp_deregister_script('font-awesome-shims'); // deregister in case its already there
163
+				wp_register_script('font-awesome-shims', $url, array(), null);
164
+				wp_enqueue_script('font-awesome-shims');
165 165
 			}
166 166
 		}
167 167
 
@@ -172,13 +172,13 @@  discard block
 block discarded – undo
172 172
 		 *
173 173
 		 * @return string The url to the file.
174 174
 		 */
175
-		public function get_url( $shims = false ) {
175
+		public function get_url($shims = false) {
176 176
 			$script  = $shims ? 'v4-shims' : 'all';
177 177
 			$type    = $this->settings['type'];
178 178
 			$version = $this->settings['version'];
179 179
 
180 180
 			$url = "https://use.fontawesome.com/releases/"; // CDN
181
-			$url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
181
+			$url .= !empty($version) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
182 182
 			$url .= $type == 'CSS' ? 'css/' : 'js/'; // type
183 183
 			$url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type
184 184
 			$url .= "?wpfas=true"; // set our var so our version is not removed
@@ -197,16 +197,16 @@  discard block
 block discarded – undo
197 197
 		 *
198 198
 		 * @return string The filtered url.
199 199
 		 */
200
-		public function remove_font_awesome( $url, $original_url, $_context ) {
200
+		public function remove_font_awesome($url, $original_url, $_context) {
201 201
 
202
-			if ( $_context == 'display'
203
-			     && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
204
-			     && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
202
+			if ($_context == 'display'
203
+			     && (strstr($url, "fontawesome") !== false || strstr($url, "font-awesome") !== false)
204
+			     && (strstr($url, ".js") !== false || strstr($url, ".css") !== false)
205 205
 			) {// it's a font-awesome-url (probably)
206 206
 
207
-				if ( strstr( $url, "wpfas=true" ) !== false ) {
208
-					if ( $this->settings['type'] == 'JS' ) {
209
-						if ( $this->settings['js-pseudo'] ) {
207
+				if (strstr($url, "wpfas=true") !== false) {
208
+					if ($this->settings['type'] == 'JS') {
209
+						if ($this->settings['js-pseudo']) {
210 210
 							$url .= "' data-search-pseudo-elements defer='defer";
211 211
 						} else {
212 212
 							$url .= "' defer='defer";
@@ -225,17 +225,17 @@  discard block
 block discarded – undo
225 225
 		 * Register the database settings with WordPress.
226 226
 		 */
227 227
 		public function register_settings() {
228
-			register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' );
228
+			register_setting('wp-font-awesome-settings', 'wp-font-awesome-settings');
229 229
 		}
230 230
 
231 231
 		/**
232 232
 		 * Add the WordPress settings menu item.
233 233
 		 */
234 234
 		public function menu_item() {
235
-			add_options_page( $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
235
+			add_options_page($this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
236 236
 				$this,
237 237
 				'settings_page'
238
-			) );
238
+			));
239 239
 		}
240 240
 
241 241
 		/**
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 		 */
246 246
 		public function get_settings() {
247 247
 
248
-			$db_settings = get_option( 'wp-font-awesome-settings' );
248
+			$db_settings = get_option('wp-font-awesome-settings');
249 249
 
250 250
 			$defaults = array(
251 251
 				'type'      => 'CSS', // type to use, CSS or JS
@@ -256,14 +256,14 @@  discard block
 block discarded – undo
256 256
 				'dequeue'   => '0', // if we should try to remove other versions added by other plugins/themes
257 257
 			);
258 258
 
259
-			$settings = wp_parse_args( $db_settings, $defaults );
259
+			$settings = wp_parse_args($db_settings, $defaults);
260 260
 
261 261
 			/**
262 262
 			 * Filter the Font Awesome settings.
263 263
 			 *
264 264
 			 * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
265 265
 			 */
266
-			return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults );
266
+			return $this->settings = apply_filters('wp-font-awesome-settings', $settings, $db_settings, $defaults);
267 267
 		}
268 268
 
269 269
 
@@ -271,12 +271,12 @@  discard block
 block discarded – undo
271 271
 		 * The settings page html output.
272 272
 		 */
273 273
 		public function settings_page() {
274
-			if ( ! current_user_can( 'manage_options' ) ) {
275
-				wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
274
+			if (!current_user_can('manage_options')) {
275
+				wp_die(__('You do not have sufficient permissions to access this page.'));
276 276
 			}
277 277
 
278 278
 			// a hidden way to force the update of the verison number vai api instead of waiting the 48 hours
279
-			if(isset($_REQUEST['force-version-check'])){
279
+			if (isset($_REQUEST['force-version-check'])) {
280 280
 				$this->get_latest_version($force_api = true);
281 281
 			}
282 282
 			?>
@@ -284,43 +284,43 @@  discard block
 block discarded – undo
284 284
 				<h1><?php echo $this->name; ?></h1>
285 285
 				<form method="post" action="options.php">
286 286
 					<?php
287
-					settings_fields( 'wp-font-awesome-settings' );
288
-					do_settings_sections( 'wp-font-awesome-settings' );
287
+					settings_fields('wp-font-awesome-settings');
288
+					do_settings_sections('wp-font-awesome-settings');
289 289
 					?>
290 290
 					<table class="form-table">
291 291
 						<tr valign="top">
292
-							<th scope="row"><label for="wpfas-type"><?php _e( 'Type' ); ?></label></th>
292
+							<th scope="row"><label for="wpfas-type"><?php _e('Type'); ?></label></th>
293 293
 							<td>
294 294
 								<select name="wp-font-awesome-settings[type]" id="wpfas-type">
295 295
 									<option
296
-										value="CSS" <?php selected( $this->settings['type'], 'CSS' ); ?>><?php _e( 'CSS (default)' ); ?></option>
297
-									<option value="JS" <?php selected( $this->settings['type'], 'JS' ); ?>>JS</option>
296
+										value="CSS" <?php selected($this->settings['type'], 'CSS'); ?>><?php _e('CSS (default)'); ?></option>
297
+									<option value="JS" <?php selected($this->settings['type'], 'JS'); ?>>JS</option>
298 298
 								</select>
299 299
 							</td>
300 300
 						</tr>
301 301
 
302 302
 						<tr valign="top">
303
-							<th scope="row"><label for="wpfas-version"><?php _e( 'Version' ); ?></label></th>
303
+							<th scope="row"><label for="wpfas-version"><?php _e('Version'); ?></label></th>
304 304
 							<td>
305 305
 								<select name="wp-font-awesome-settings[version]" id="wpfas-version">
306 306
 									<option
307
-										value="" <?php selected( $this->settings['version'], '' ); ?>><?php echo sprintf( __( 'Latest - %s (default)' ), $this->get_latest_version() ); ?></option>
308
-									<option value="5.5.0" <?php selected( $this->settings['version'], '5.5.0' ); ?>>
307
+										value="" <?php selected($this->settings['version'], ''); ?>><?php echo sprintf(__('Latest - %s (default)'), $this->get_latest_version()); ?></option>
308
+									<option value="5.5.0" <?php selected($this->settings['version'], '5.5.0'); ?>>
309 309
 										5.5.0
310 310
 									</option>
311
-									<option value="5.4.0" <?php selected( $this->settings['version'], '5.4.0' ); ?>>
311
+									<option value="5.4.0" <?php selected($this->settings['version'], '5.4.0'); ?>>
312 312
 										5.4.0
313 313
 									</option>
314
-									<option value="5.3.0" <?php selected( $this->settings['version'], '5.3.0' ); ?>>
314
+									<option value="5.3.0" <?php selected($this->settings['version'], '5.3.0'); ?>>
315 315
 										5.3.0
316 316
 									</option>
317
-									<option value="5.2.0" <?php selected( $this->settings['version'], '5.2.0' ); ?>>
317
+									<option value="5.2.0" <?php selected($this->settings['version'], '5.2.0'); ?>>
318 318
 										5.2.0
319 319
 									</option>
320
-									<option value="5.1.0" <?php selected( $this->settings['version'], '5.1.0' ); ?>>
320
+									<option value="5.1.0" <?php selected($this->settings['version'], '5.1.0'); ?>>
321 321
 										5.1.0
322 322
 									</option>
323
-									<option value="4.7.0" <?php selected( $this->settings['version'], '4.7.0' ); ?>>
323
+									<option value="4.7.0" <?php selected($this->settings['version'], '4.7.0'); ?>>
324 324
 										4.7.1 (CSS only)
325 325
 									</option>
326 326
 								</select>
@@ -328,51 +328,51 @@  discard block
 block discarded – undo
328 328
 						</tr>
329 329
 
330 330
 						<tr valign="top">
331
-							<th scope="row"><label for="wpfas-enqueue"><?php _e( 'Enqueue' ); ?></label></th>
331
+							<th scope="row"><label for="wpfas-enqueue"><?php _e('Enqueue'); ?></label></th>
332 332
 							<td>
333 333
 								<select name="wp-font-awesome-settings[enqueue]" id="wpfas-enqueue">
334 334
 									<option
335
-										value="" <?php selected( $this->settings['enqueue'], '' ); ?>><?php _e( 'Frontend + Backend (default)' ); ?></option>
335
+										value="" <?php selected($this->settings['enqueue'], ''); ?>><?php _e('Frontend + Backend (default)'); ?></option>
336 336
 									<option
337
-										value="frontend" <?php selected( $this->settings['enqueue'], 'frontend' ); ?>><?php _e( 'Frontend' ); ?></option>
337
+										value="frontend" <?php selected($this->settings['enqueue'], 'frontend'); ?>><?php _e('Frontend'); ?></option>
338 338
 									<option
339
-										value="backend" <?php selected( $this->settings['enqueue'], 'backend' ); ?>><?php _e( 'Backend' ); ?></option>
339
+										value="backend" <?php selected($this->settings['enqueue'], 'backend'); ?>><?php _e('Backend'); ?></option>
340 340
 								</select>
341 341
 							</td>
342 342
 						</tr>
343 343
 
344 344
 						<tr valign="top">
345 345
 							<th scope="row"><label
346
-									for="wpfas-shims"><?php _e( 'Enable v4 shims compatibility' ); ?></label></th>
346
+									for="wpfas-shims"><?php _e('Enable v4 shims compatibility'); ?></label></th>
347 347
 							<td>
348 348
 								<input type="hidden" name="wp-font-awesome-settings[shims]" value="0"/>
349 349
 								<input type="checkbox" name="wp-font-awesome-settings[shims]"
350
-								       value="1" <?php checked( $this->settings['shims'], '1' ); ?> id="wpfas-shims"/>
351
-								<span><?php _e( 'This enables v4 classes to work with v5, sort of like a band-aid until everyone has updated everything to v5.' ); ?></span>
350
+								       value="1" <?php checked($this->settings['shims'], '1'); ?> id="wpfas-shims"/>
351
+								<span><?php _e('This enables v4 classes to work with v5, sort of like a band-aid until everyone has updated everything to v5.'); ?></span>
352 352
 							</td>
353 353
 						</tr>
354 354
 
355 355
 						<tr valign="top">
356 356
 							<th scope="row"><label
357
-									for="wpfas-js-pseudo"><?php _e( 'Enable JS pseudo elements (not recommended)' ); ?></label>
357
+									for="wpfas-js-pseudo"><?php _e('Enable JS pseudo elements (not recommended)'); ?></label>
358 358
 							</th>
359 359
 							<td>
360 360
 								<input type="hidden" name="wp-font-awesome-settings[js-pseudo]" value="0"/>
361 361
 								<input type="checkbox" name="wp-font-awesome-settings[js-pseudo]"
362
-								       value="1" <?php checked( $this->settings['js-pseudo'], '1' ); ?>
362
+								       value="1" <?php checked($this->settings['js-pseudo'], '1'); ?>
363 363
 								       id="wpfas-js-pseudo"/>
364
-								<span><?php _e( 'Used only with the JS version, this will make pseudo-elements work but can be CPU intensive on some sites.' ); ?></span>
364
+								<span><?php _e('Used only with the JS version, this will make pseudo-elements work but can be CPU intensive on some sites.'); ?></span>
365 365
 							</td>
366 366
 						</tr>
367 367
 
368 368
 						<tr valign="top">
369
-							<th scope="row"><label for="wpfas-dequeue"><?php _e( 'Dequeue' ); ?></label></th>
369
+							<th scope="row"><label for="wpfas-dequeue"><?php _e('Dequeue'); ?></label></th>
370 370
 							<td>
371 371
 								<input type="hidden" name="wp-font-awesome-settings[dequeue]" value="0"/>
372 372
 								<input type="checkbox" name="wp-font-awesome-settings[dequeue]"
373
-								       value="1" <?php checked( $this->settings['dequeue'], '1' ); ?>
373
+								       value="1" <?php checked($this->settings['dequeue'], '1'); ?>
374 374
 								       id="wpfas-dequeue"/>
375
-								<span><?php _e( 'This will try to dequeue any other Font Awesome versions loaded by other sources if they are added with `font-awesome` or `fontawesome` in the name.' ); ?></span>
375
+								<span><?php _e('This will try to dequeue any other Font Awesome versions loaded by other sources if they are added with `font-awesome` or `fontawesome` in the name.'); ?></span>
376 376
 							</td>
377 377
 						</tr>
378 378
 
@@ -397,12 +397,12 @@  discard block
 block discarded – undo
397 397
 		 *
398 398
 		 * @return string Either a valid version number or an empty string.
399 399
 		 */
400
-		public function validate_version_number( $version ) {
400
+		public function validate_version_number($version) {
401 401
 
402
-			if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) {
402
+			if (version_compare($version, '0.0.1', '>=') >= 0) {
403 403
 				// valid
404 404
 			} else {
405
-				$version = '';// not validated
405
+				$version = ''; // not validated
406 406
 			}
407 407
 
408 408
 			return $version;
@@ -420,16 +420,16 @@  discard block
 block discarded – undo
420 420
 		public function get_latest_version($force_api = false) {
421 421
 			$latest_version = $this->latest;
422 422
 
423
-			$cache = get_transient( 'wp-font-awesome-settings-version' );
423
+			$cache = get_transient('wp-font-awesome-settings-version');
424 424
 
425
-			if ( $cache === false || $force_api) { // its not set
425
+			if ($cache === false || $force_api) { // its not set
426 426
 				$api_ver = $this->get_latest_version_from_api();
427
-				if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) {
427
+				if (version_compare($api_ver, $this->latest, '>=') >= 0) {
428 428
 					$latest_version = $api_ver;
429
-					set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS );
429
+					set_transient('wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS);
430 430
 				}
431
-			} elseif ( $this->validate_version_number( $cache ) ) {
432
-				if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) {
431
+			} elseif ($this->validate_version_number($cache)) {
432
+				if (version_compare($cache, $this->latest, '>=') >= 0) {
433 433
 					$latest_version = $cache;
434 434
 				}
435 435
 			}
@@ -445,10 +445,10 @@  discard block
 block discarded – undo
445 445
 		 */
446 446
 		public function get_latest_version_from_api() {
447 447
 			$version  = "0";
448
-			$response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" );
449
-			if ( ! is_wp_error( $response ) && is_array( $response ) ) {
450
-				$api_response = json_decode( wp_remote_retrieve_body( $response ), true );
451
-				if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) {
448
+			$response = wp_remote_get("https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest");
449
+			if (!is_wp_error($response) && is_array($response)) {
450
+				$api_response = json_decode(wp_remote_retrieve_body($response), true);
451
+				if (isset($api_response['tag_name']) && version_compare($api_response['tag_name'], $this->latest, '>=') >= 0 && empty($api_response['prerelease'])) {
452 452
 					$version = $api_response['tag_name'];
453 453
 				}
454 454
 			}
Please login to merge, or discard this patch.