| @@ -3,14 +3,25 @@ | ||
| 3 | 3 | die( 'You are not allowed to call this page directly.' ); |
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | class FrmStyle { |
| 7 | - public $number = false; // Unique ID number of the current instance. | |
| 8 | - public $id = 0; // the id of the post | |
| 7 | + /** | |
| 8 | + * Unique ID number of the current instance. | |
| 9 | + * | |
| 10 | + * @var int | |
| 11 | + */ | |
| 12 | + public $number = false; | |
| 9 | 13 | |
| 10 | 14 | /** |
| 11 | - * @param int|string $id The id of the stylsheet or 'default' | |
| 15 | + * The id of the post. | |
| 16 | + * | |
| 17 | + * @var int|string | |
| 12 | 18 | */ |
| 19 | + public $id = 0; | |
| 20 | + | |
| 21 | + /** | |
| 22 | + * @param int|string $id The id of the stylsheet or 'default'. | |
| 23 | + */ | |
| 13 | 24 | public function __construct( $id = 0 ) { |
| 14 | 25 | $this->id = $id; |
| 15 | 26 | } |
| 16 | 27 | |
| @@ -20,9 +31,10 @@ | ||
| 20 | 31 | public function get_new() { |
| 21 | 32 | $this->id = 0; |
| 22 | 33 | |
| 23 | 34 | $max_slug_value = 2147483647; |
| 24 | - $min_slug_value = 37; // we want to have at least 2 characters in the slug | |
| 35 | + // We want to have at least 2 characters in the slug. | |
| 36 | + $min_slug_value = 37; | |
| 25 | 37 | $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 ); |
| 26 | 38 | |
| 27 | 39 | $style = array( |
| 28 | 40 | 'post_type' => FrmStylesController::$post_type, |
| @@ -120,9 +132,9 @@ | ||
| 120 | 132 | } |
| 121 | 133 | } |
| 122 | 134 | |
| 123 | 135 | $action_ids[] = $this->save( $new_instance ); |
| 124 | - } | |
| 136 | + }//end foreach | |
| 125 | 137 | |
| 126 | 138 | $this->save_settings(); |
| 127 | 139 | |
| 128 | 140 | return $action_ids; |
| @@ -132,9 +144,9 @@ | ||
| 132 | 144 | * Sanitize custom color values and convert it to valid one filling missing values. |
| 133 | 145 | * |
| 134 | 146 | * @since 5.3.2 |
| 135 | 147 | * |
| 136 | - * @param string $color_val, The color value, by reference. | |
| 148 | + * @param string $color_val The color value, by reference. | |
| 137 | 149 | * @return void |
| 138 | 150 | */ |
| 139 | 151 | private function maybe_sanitize_rgba_value( &$color_val ) { |
| 140 | 152 | if ( preg_match( '/(rgb|rgba)\(/', $color_val ) !== 1 ) { |
| @@ -141,9 +153,10 @@ | ||
| 141 | 153 | return; |
| 142 | 154 | } |
| 143 | 155 | |
| 144 | 156 | $color_val = trim( $color_val ); |
| 145 | - $color_val = ltrim( $color_val, '(' ); // Remove leading braces so (rgba(1,1,1,1) doesn't cause inconsistent braces. | |
| 157 | + // Remove leading braces so (rgba(1,1,1,1) doesn't cause inconsistent braces. | |
| 158 | + $color_val = ltrim( $color_val, '(' ); | |
| 146 | 159 | $patterns = array( '/rgba\((\s*\d+\s*,){3}[[0-1]\.]+\)/', '/rgb\((\s*\d+\s*,){2}\s*[\d]+\)/' ); |
| 147 | 160 | foreach ( $patterns as $pattern ) { |
| 148 | 161 | if ( preg_match( $pattern, $color_val ) === 1 ) { |
| 149 | 162 | return; |
| @@ -153,10 +166,11 @@ | ||
| 153 | 166 | // Remove all leading ')' braces, then add one back. This way there's always a single brace. |
| 154 | 167 | $color_val = rtrim( $color_val, ')' ); |
| 155 | 168 | $color_val .= ')'; |
| 156 | 169 | |
| 157 | - $color_rgba = substr( $color_val, strpos( $color_val, '(' ) + 1, strlen( $color_val ) - strpos( $color_val, '(' ) - 2 ); | |
| 158 | - $color_rgba = trim( $color_rgba, '()' ); // Remove any excessive braces from the rgba like rgba((. | |
| 170 | + $color_rgba = substr( $color_val, strpos( $color_val, '(' ) + 1, strlen( $color_val ) - strpos( $color_val, '(' ) - 2 ); | |
| 171 | + // Remove any excessive braces from the rgba like rgba((. | |
| 172 | + $color_rgba = trim( $color_rgba, '()' ); | |
| 159 | 173 | $length_of_color_codes = strpos( $color_val, '(' ); |
| 160 | 174 | $new_color_values = array(); |
| 161 | 175 | |
| 162 | 176 | // replace empty values by 0 or 1 (if alpha position). |
| @@ -183,12 +197,12 @@ | ||
| 183 | 197 | $new_value = 1; |
| 184 | 198 | } else { |
| 185 | 199 | $new_value = floatval( $value ); |
| 186 | 200 | } |
| 187 | - } | |
| 201 | + }//end if | |
| 188 | 202 | |
| 189 | 203 | $new_color_values[] = null === $new_value ? $value : $new_value; |
| 190 | - } | |
| 204 | + }//end foreach | |
| 191 | 205 | |
| 192 | 206 | // add more 0s and 1 (if alpha position) if needed. |
| 193 | 207 | $missing_values = $length_of_color_codes - count( $new_color_values ); |
| 194 | 208 | if ( $missing_values > 1 ) { |
| @@ -203,9 +217,10 @@ | ||
| 203 | 217 | } |
| 204 | 218 | |
| 205 | 219 | $new_color = implode( ',', $new_color_values ); |
| 206 | 220 | $prefix = substr( $color_val, 0, strpos( $color_val, '(' ) + 1 ); |
| 207 | - $prefix = rtrim( $prefix, '(' ) . '('; // Limit the number of opening braces after rgb/rgba. There should only be one. | |
| 221 | + // Limit the number of opening braces after rgb/rgba. There should only be one. | |
| 222 | + $prefix = rtrim( $prefix, '(' ) . '('; | |
| 208 | 223 | $new_color = $prefix . $new_color . ')'; |
| 209 | 224 | |
| 210 | 225 | $color_val = $new_color; |
| 211 | 226 | } |
| @@ -650,15 +665,15 @@ | ||
| 650 | 665 | 'field_pad' => '6px 10px', |
| 651 | 666 | 'field_margin' => '20px', |
| 652 | 667 | 'field_weight' => 'normal', |
| 653 | 668 | 'text_color' => '555555', |
| 654 | - //'border_color_hv' => 'cccccc', | |
| 669 | + // 'border_color_hv' => 'cccccc', | |
| 655 | 670 | 'border_color' => 'BFC3C8', |
| 656 | 671 | 'field_border_width' => '1px', |
| 657 | 672 | 'field_border_style' => 'solid', |
| 658 | 673 | |
| 659 | 674 | 'bg_color' => 'ffffff', |
| 660 | - //'bg_color_hv' => 'ffffff', | |
| 675 | + // 'bg_color_hv' => 'ffffff', | |
| 661 | 676 | 'remove_box_shadow' => '', |
| 662 | 677 | 'bg_color_active' => 'ffffff', |
| 663 | 678 | 'border_color_active' => '66afe9', |
| 664 | 679 | 'remove_box_shadow_active' => '', |