Changeset 2171771
- Timestamp:
- 10/11/2019 01:01:03 PM (6 years ago)
- Location:
- styles-selector
- Files:
-
- 1 deleted
- 12 edited
-
assets/screenshot-3.jpg (modified) (previous)
-
trunk/README.txt (modified) (8 diffs)
-
trunk/admin/class-styleselector-admin.php (modified) (2 diffs)
-
trunk/admin/css/styleselector-admin.css (modified) (1 diff)
-
trunk/admin/js/styleselector-admin.js (modified) (5 diffs)
-
trunk/admin/partials/styleselector-admin-display.php (modified) (5 diffs)
-
trunk/assets (modified) (1 prop)
-
trunk/assets/restored.jpg (deleted)
-
trunk/includes/class-styleselector-activator.php (modified) (2 diffs)
-
trunk/includes/class-styleselector.php (modified) (1 diff)
-
trunk/public/js/styleselector-public.js (modified) (7 diffs)
-
trunk/public/partials/widget-styleselector.php (modified) (4 diffs)
-
trunk/styleselector.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
styles-selector/trunk/README.txt
r2165362 r2171771 8 8 Tested up to: 5.2.3 9 9 License: GPLv2 or later 10 Version: 1. 0.010 Version: 1.1.0 11 11 Requires at least: 5.2 12 12 Requires PHP: 7.1.32 … … 22 22 https://stackoverflow.com/questions/21646738/convert-hex-to-rgba 23 23 https://www.w3schools.com/ 24 https://www.wordpress.org/ 24 25 25 26 == Description == … … 27 28 Plugin for altering several items in a theme in order to change the visualization. You can choose which kind of item will be, 28 29 an individual CSS element or an entire class by specifing the type of element. 29 If you have a theme switcher, you can also alter several themes (up to five).30 If you have a theme switcher, like "multidevice switcher", you can also alter several themes (up to five). 30 31 Once you have saved the themes, their elements and the name of the option, a widget will be created with a menu list of the options you did, 31 32 so the users can set the display options they want. 33 34 35 The main idea of this plugin came when reading some webnovel in my cellphone and couldn't change the color of the text when the light changed. 36 It provides the user an instant change of the colors of the screen, colors preselected by the administrator in order to not change very much the design of the page, 37 also it has the advantage of not reloading the content, since there is no change of the theme, just an alteration of the CSS properties. 38 39 32 40 33 41 Usage … … 37 45 ## Admin menu 38 46 39 * The admin can choose up to five different themes from the installed ones to be changed by selectint them in a drop down at the beginning of each tab of the configuration page. Note that you can select the same theme several times if you run out of mods. 47 * The admin can choose up to five different themes from the installed ones to be changed by selecting them in a drop down at the beginning of each tab of the configuration page. Note that you can select the same theme several times if you run out of mods. 48 * You can force the selector to be displayed at the top of the page instead of using a widget or a shortcode. 49 * You can configure the style of the selector for each theme. 40 50 * At each theme tab the admin can set up to ten color modifications to classes or individual elements. 41 51 ### Admin menuOptions fields … … 56 66 57 67 ## Frontend 58 * The user can choose between a default "Restore" option, and the ones defined by you. 68 * The user can choose between a default "Restore" option, and the ones defined by you. This option is persistent. 69 * The user can select the size of the text. This option is not persistent. 59 70 60 71 == Installation == … … 74 85 Tested in a multisite with * domain names and works fine. Can't say yet if in a MU with only one domain will work the same. 75 86 87 = Works with xxx theme? = 88 89 Can't say. CSS is sometimes tricky and is nor always clear which element to change. 90 Some themes may prevent tampering or have dynamic HTML5 and javascript updates of the styles. 91 92 = Why can't I add my own stylesheet? = 93 94 This plugin isn't a theme switcher, neither a customizer, it just changes colors and size of the fonts for better reading. 95 96 = I have updated the plugin and fonts doesn't change size. = 97 98 Try refreshing all caches, sometimes it takes time to reload styles and scripts. 99 76 100 77 101 == Screenshots == … … 83 107 == Changelog == 84 108 109 = 1.1.0 = 110 Added font size to frontend. 111 Configurable selector. 112 Optional force selector on head. 113 Added fields to options database. 114 Some spelling errors corrected. 115 Added "overflow:auto" to options boxes. 116 Added some nonsense to the FAQ. 117 85 118 = 1.0 = 86 119 First version 120 87 121 == Upgrade Notice == 122 = 1.1.0 = 123 124 Added some fronted and backend options. Corrected spelling and deleted some unneded code. 88 125 89 126 = 1.0 = … … 92 129 == TODO == 93 130 94 Add font size and face frontend customization.95 Add background image backend option.96 Option to selectively display the "head" menu instead of uncomenting it.97 131 Prepare code for translation. 98 132 Clean a bit the code. 133 Add background image backend option. 99 134 100 135 == Directories explanation == -
styles-selector/trunk/admin/class-styleselector-admin.php
r2165349 r2171771 5 5 * 6 6 * @link https://chafalladas.com 7 * @since 1. 0.07 * @since 1.1.0 8 8 * 9 9 * @package Styleselector … … 158 158 */ 159 159 160 public function validate($input) {161 160 public function validate($input) 161 { 162 162 $valid = array(); 163 $ss_fieldTypes = array("ss_ selected_theme", "ss_opt_name", "ss_theme_option_type","ss_element","ss_bg_colorPicker","ss_fn_colorPicker","ss_myRange","ss_myRangeFont","ss_option");163 $ss_fieldTypes = array("ss_disp_head", "ss_select_style", "ss_select_sheet_div", "ss_select_sheet_sel", "ss_selected_theme", "ss_opt_name", "ss_theme_option_type","ss_element","ss_bg_colorPicker","ss_fn_colorPicker","ss_myRange","ss_myRangeFont","ss_option"); 164 164 for ($ss_tab = 1; $ss_tab < 6; $ss_tab++) 165 165 { 166 166 $ss_fieldId = $ss_fieldTypes[0]."_".$ss_tab; 167 $valid[$ss_fieldId] = wp_filter_nohtml_kses($input[$ss_fieldId]); 168 for ($ss_count = 1; $ss_count < 11; $ss_count++) 169 { 170 for ($ss_fieldCount = 1; $ss_fieldCount < count($ss_fieldTypes); $ss_fieldCount++) 171 { 172 $ss_fieldId = $ss_fieldTypes[$ss_fieldCount]."_".$ss_tab."_".$ss_count; 173 $valid[$ss_fieldId] = wp_filter_nohtml_kses($input[$ss_fieldId]); 174 } 175 } 176 } 167 $valid[$ss_fieldId] = wp_filter_nohtml_kses($input[$ss_fieldId]); 168 $ss_fieldId = $ss_fieldTypes[1]."_".$ss_tab; 169 $valid[$ss_fieldId] = wp_filter_nohtml_kses($input[$ss_fieldId]); 170 $ss_fieldId = $ss_fieldTypes[2]."_".$ss_tab; 171 $valid[$ss_fieldId] = wp_filter_nohtml_kses($input[$ss_fieldId]); 172 $ss_fieldId = $ss_fieldTypes[3]."_".$ss_tab; 173 $valid[$ss_fieldId] = wp_filter_nohtml_kses($input[$ss_fieldId]); 174 $ss_fieldId = $ss_fieldTypes[4]."_".$ss_tab; 175 $valid[$ss_fieldId] = wp_filter_nohtml_kses($input[$ss_fieldId]); 176 for ($ss_count = 1; $ss_count < 11; $ss_count++) 177 { 178 for ($ss_fieldCount = 5; $ss_fieldCount < count($ss_fieldTypes); $ss_fieldCount++) 179 { 180 $ss_fieldId = $ss_fieldTypes[$ss_fieldCount]."_".$ss_tab."_".$ss_count; 181 $valid[$ss_fieldId] = wp_filter_nohtml_kses($input[$ss_fieldId]); 182 } 183 } 184 } 177 185 return $valid; 178 186 } -
styles-selector/trunk/admin/css/styleselector-admin.css
r2165349 r2171771 97 97 .vertical [type=radio]:checked ~ label ~ .content, .vertical [type=checkbox]:checked ~ label ~ .content { 98 98 height:110px; 99 overflow: auto; 99 100 border:1px solid #0073AA; 100 101 } -
styles-selector/trunk/admin/js/styleselector-admin.js
r2165349 r2171771 1 1 //https://stackoverflow.com/questions/21646738/convert-hex-to-rgba ****************** 2 // console.trace(this); 3 4 var eleArray = []; //Array of options 5 var changes = { 6 isTab:'', option:'', isClass:'', eleName:'', rgbColor:'', rgbFont:'', alfaBg:'', alfaFn:'', restore:false, 7 bgColor: function() 8 { 9 var tcolr = hexToRgbA(this.rgbColor); 10 return "rgba(" + tcolr.ssR + ", " + tcolr.ssG + ", " + tcolr.ssB + ", "+ this.alfaBg/100 + ")"; 11 }, 12 fnColor: function() 13 { 14 var tcolr = hexToRgbA(this.rgbFont); 15 return "rgba(" + tcolr.ssR + ", " + tcolr.ssG + ", " + tcolr.ssB + ", "+ this.alfaFn/100 + ")"; 16 } 17 } 18 2 19 function hexToRgbA(hex){ 3 20 var c; … … 45 62 else{document.getElementById("submit").style.display = "block";} 46 63 } 64 //Select selector option **************** 65 function styleSelect(ss_element) 66 { 67 document.getElementById("select_sheet_div_" + ss_element).disabled = true; 68 document.getElementById("select_sheet_sel_" + ss_element).disabled = true; 69 switch(parseInt(document.getElementById("select_style_" + ss_element).value)) 70 { 71 case 0: 72 document.getElementById("select_sheet_div_" + ss_element).value = ''; 73 document.getElementById("select_sheet_sel_" + ss_element).value = ''; 74 break; 75 case 1: 76 document.getElementById("select_sheet_div_" + ss_element).value = 'border-radius: 10px'; 77 document.getElementById("select_sheet_sel_" + ss_element).value = 'border-radius: 10px'; 78 break; 79 case 2: 80 document.getElementById("select_sheet_div_" + ss_element).disabled = false; 81 document.getElementById("select_sheet_sel_" + ss_element).disabled = false; 82 break; 83 } 84 document.getElementById("shortcode_sselector_" + ss_element).style = document.getElementById("select_sheet_div_" + ss_element).value; 85 document.getElementById("widget_sselector_" + ss_element).style = document.getElementById("select_sheet_sel_" + ss_element).value; 86 fillForm(ss_element); 87 } 47 88 //Color picker routine ****************** 48 89 function clickColor(ss_element,ss_which) … … 81 122 function fillForm(ss_option) 82 123 { 83 var ss_fieldTypes = ["ss_selected_theme", "ss_opt_name", "ss_theme_option_type","ss_element","ss_bg_colorPicker","ss_fn_colorPicker","ss_myRange","ss_myRangeFont","ss_option"]; 84 var checkEl = document.getElementById(ss_fieldTypes[0] + "_" + ss_option); 85 if (checkEl !== null) 86 { 87 document.getElementById(ss_fieldTypes[0] + "_" + ss_option).value = document.getElementById(ss_fieldTypes[0].replace("ss_", "") + "_" + ss_option).value; 124 var i = 0; 125 var ss_fieldTypes = ["ss_disp_head", "ss_select_style", "ss_select_sheet_div", "ss_select_sheet_sel", "ss_selected_theme", "ss_opt_name", "ss_theme_option_type","ss_element","ss_bg_colorPicker","ss_fn_colorPicker","ss_myRange","ss_myRangeFont","ss_option"]; 126 if (ss_option.lastIndexOf("_") === -1) 127 { 128 setChecked(document.getElementById(ss_fieldTypes[0].replace("ss_", "") + "_" + ss_option), document.getElementById(ss_fieldTypes[0] + "_" + ss_option)); 129 for (i=1; i < 5; i++) 130 { 131 document.getElementById(ss_fieldTypes[i] + '_' + ss_option).value = document.getElementById(ss_fieldTypes[i].replace("ss_", "") + "_" + ss_option).value; 132 if (document.getElementById(ss_fieldTypes[i].replace("ss_", "") + "_" + ss_option).value == "2") 133 { 134 document.getElementById(ss_fieldTypes[2].replace("ss_", "") + "_" + ss_option).disabled = false; 135 document.getElementById(ss_fieldTypes[3].replace("ss_", "") + "_" + ss_option).disabled = false; 136 } 137 } 88 138 } 89 139 else 90 140 { 91 for ( var i=1; i < ss_fieldTypes.length -1; i++)141 for (i=5; i < ss_fieldTypes.length -1; i++) 92 142 { 93 143 document.getElementById(ss_fieldTypes[i] + '_' + ss_option).value = document.getElementById(ss_fieldTypes[i].replace("ss_", "") + "_" + ss_option).value; 94 144 } 95 if(document.getElementById(ss_fieldTypes[i].replace("ss_", "") + "_" + ss_option).checked == 1) 96 {document.getElementById(ss_fieldTypes[i] + '_' + ss_option).value = 1;} 97 else 98 {document.getElementById(ss_fieldTypes[i] + '_' + ss_option).value = 0;} 145 setChecked(document.getElementById(ss_fieldTypes[i].replace("ss_", "") + "_" + ss_option),document.getElementById(ss_fieldTypes[i] + '_' + ss_option)); 99 146 } 100 147 } … … 102 149 function ss_pass_stored() 103 150 { 104 var ss_fieldTypes = ["ss_ selected_theme", "ss_opt_name", "ss_theme_option_type","ss_element","ss_bg_colorPicker","ss_fn_colorPicker","ss_myRange","ss_myRangeFont","ss_option"];151 var ss_fieldTypes = ["ss_disp_head", "ss_select_style", "ss_select_sheet_div", "ss_select_sheet_sel", "ss_selected_theme", "ss_opt_name", "ss_theme_option_type","ss_element","ss_bg_colorPicker","ss_fn_colorPicker","ss_myRange","ss_myRangeFont","ss_option"]; 105 152 var ss_option, i, j, k = 0; 106 153 var ss_colors = ""; 107 154 for(i=1;i < 6;i++) 108 155 { 156 checkedVal(document.getElementById(ss_fieldTypes[k].replace("ss_", "") + "_" + i),document.getElementById(ss_fieldTypes[k] + "_" + i).value); 157 k++; 158 if (document.getElementById(ss_fieldTypes[k] + "_" + i).value == "2") 159 { 160 document.getElementById(ss_fieldTypes[2].replace("ss_", "") + "_" + i).disabled = false; 161 document.getElementById(ss_fieldTypes[3].replace("ss_", "") + "_" + i).disabled = false; 162 } 163 document.getElementById(ss_fieldTypes[k].replace("ss_", "") + "_" + i).value = document.getElementById(ss_fieldTypes[k] + "_" + i).value; 164 k++; 165 document.getElementById(ss_fieldTypes[k].replace("ss_", "") + "_" + i).value = document.getElementById(ss_fieldTypes[k] + "_" + i).value; 166 k++; 167 document.getElementById(ss_fieldTypes[k].replace("ss_", "") + "_" + i).value = document.getElementById(ss_fieldTypes[k] + "_" + i).value; 168 k++; 109 169 document.getElementById(ss_fieldTypes[k].replace("ss_", "") + "_" + i).value = document.getElementById(ss_fieldTypes[k] + "_" + i).value; 110 170 for (j=1; j < 11; j++) 111 171 { 112 for (k= 1; k < ss_fieldTypes.length - 5; k++)172 for (k=5; k < ss_fieldTypes.length - 5; k++) 113 173 { 114 ss_option = i + "_" + j;174 ss_option = i + "_" + j; 115 175 document.getElementById(ss_fieldTypes[k].replace("ss_", "") + "_" + ss_option).value = document.getElementById(ss_fieldTypes[k] + '_' + ss_option).value; 116 176 } 117 177 //Some really simple yet hard to read code that renders the style colors we saved 118 178 // Need to read more about wrappers to make a nice method for the test_color element here. Next version maybe. 119 // console.log("Test Color filling: " + ss_option + " Element: " + ss_fieldTypes[k].replace("ss_", "") + "_" + ss_option);120 179 document.getElementById(ss_fieldTypes[k].replace("ss_", "") + "_" + ss_option).value = document.getElementById(ss_fieldTypes[k] + '_' + ss_option).value; 121 180 ss_colors = hexToRgbA(document.getElementById(ss_fieldTypes[k].replace("ss_", "") + "_" + ss_option).value); … … 139 198 document.getElementById(ss_fieldTypes[k].replace("ss_", "") + "_" + ss_option).style.backgroundColor = ss_bgcolor.replace(/[^,]+(?=\))/, ss_alfa); 140 199 document.getElementById('test_color_' + ss_option).innerHTML = "Font color: " + document.getElementById('test_color_' + ss_option).style.color + " BG Color: " + document.getElementById('test_color_' + ss_option).style.backgroundColor; 141 k++; 142 if(document.getElementById(ss_fieldTypes[k] + '_' + ss_option).value == 1) 143 {document.getElementById(ss_fieldTypes[k].replace("ss_", "") + "_" + ss_option).checked = 1;} 144 else 145 {document.getElementById(ss_fieldTypes[k].replace("ss_", "") + "_" + ss_option).checked = 0;} 200 k++; 201 checkedVal(document.getElementById(ss_fieldTypes[k].replace("ss_", "") + "_" + ss_option), document.getElementById(ss_fieldTypes[k] + '_' + ss_option).value); 146 202 //Seriously, this is unreadable, it's a Must TODO. 147 203 } 148 204 k = 0; 149 } 150 } 205 styleSelect("" + i); 206 } 207 } 208 //Set checked according stored vals 209 function checkedVal(which, val) 210 { 211 if(val == 1) 212 {which.checked = 1;} 213 else 214 {which.checked = 0;} 215 } 216 //Set val according checked status 217 function setChecked(checkedOne, valOne) 218 { 219 if(checkedOne.checked == 1) 220 {valOne.value = 1;} 221 else 222 {valOne.value = 0;} 223 } 224 225 //Selector demo options. 226 227 //Styles options 228 229 //Add new values 230 function addOption(a_tab, a_option,a_class,a_name,a_color,a_font,a_alfab,a_alfaf,dontcare) 231 { 232 var exists = false; 233 var j,k=0; 234 for (k=0;k < eleArray.length;k++)//Check if entry already exists 235 { 236 if(eleArray[k].eleName == a_name && eleArray[k].option == a_option) 237 { 238 exists = true; 239 } 240 } 241 if(!exists && (a_name == "shortcode_sselector" || a_name == "widget_sselector")) 242 { 243 eleArray.push(Object.create(changes,{isTab:{value:a_tab}, option:{value:a_option}, isClass:{value:a_class}, eleName:{value:a_name}, 244 rgbColor:{value:a_color}, rgbFont:{value:a_font}, alfaBg:{value:a_alfab}, alfaFn:{value:a_alfaf}})); 245 } 246 } 247 //Change colors 248 // shortcode_sselector".$ss_tab."' 249 //sample_sselector".$ss_tab." 250 function changeProps(ss_element,tab) 251 { 252 var i,j=0; 253 var wichOption = ss_element.value; 254 if (wichOption == "Restore") 255 { 256 ss_element.style.backgroundColor = "#ffffff"; 257 ss_element.style.color = "#000"; 258 document.getElementById("shortcode_sselector_" +tab).style.backgroundColor = "#ffffff"; 259 document.getElementById("shortcode_sselector_" +tab).style.color = "#000"; 260 } 261 262 for(i=0;i<eleArray.length;i++) 263 { 264 if(wichOption == eleArray[i].option) 265 { 266 ss_element.style.backgroundColor = eleArray[i].bgColor(); 267 ss_element.style.color = eleArray[i].fnColor(); 268 document.getElementById("shortcode_sselector_" +tab).style.backgroundColor = eleArray[i].bgColor(); 269 document.getElementById("shortcode_sselector_" +tab).style.color = eleArray[i].fnColor(); 270 } 271 } 272 } 273 274 //Function to extract a style property 275 var getStyle = function(element, property) { 276 return window.getComputedStyle ? window.getComputedStyle(element, null).getPropertyValue(property) : element.style[property.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); })]; 277 }; -
styles-selector/trunk/admin/partials/styleselector-admin-display.php
r2165349 r2171771 24 24 } 25 25 echo "</select>"; 26 // echo "<fieldset>".get_stylesheet(). " ____ " .get_bloginfo('stylesheet_directory'); 26 echo "<h3>Should the selector be displayed at the head of the page?</h3>"; 27 echo "<input type='checkbox' id='disp_head_".$ss_tab."' name='disp_head_".$ss_tab."' oninput=\"fillForm('".$ss_tab."')\" />"; 28 echo "<h3>Choose a style for the selectors. You can also alter them changing the \"shortcode_sselector\" for the div and \"widget_sselector\" for the selector classes.</h3>"; 29 echo "<table align='center'>"; 30 echo " <tr align='center'>"; 31 echo " <td width='50'>Choose a style for the selectors.</td>"; 32 echo " <td width='50'>Custom CCS for \"shortcode_sselector\".</td>"; 33 echo " <td width='50'>Custom CCS for \"widget_sselector\".</td>"; 34 echo " <td width='50'>"; 35 echo " <div class='shortcode_sselector_".$ss_tab."'>Select a style: "; 36 echo " </div>"; 37 echo "</td>"; 38 echo " </tr>"; 39 echo " <tr align='center'>"; 40 echo " <td><select name='select_style_".$ss_tab."' id='select_style_".$ss_tab."' oninput=\"styleSelect('".$ss_tab."')\">"; 41 echo " <option value='0'>Squared</option>"; 42 echo " <option value='1'>Rounded</option>"; 43 echo " <option value='2'>Custom</option>"; 44 echo " </select></td>"; 45 echo " <td><textarea id='select_sheet_div_".$ss_tab."' name='select_sheet_div_".$ss_tab."' cols='80' rows='4' class='all-options' disabled oninput=\"styleSelect('".$ss_tab."')\">Select 'Custom' to edit.</textarea></td>"; 46 echo " <td><textarea id='select_sheet_sel_".$ss_tab."' name='select_sheet_sel_".$ss_tab."' cols='80' rows='4' class='all-options' disabled oninput=\"styleSelect('".$ss_tab."')\">Select 'Custom' to edit.</textarea></td>"; 47 echo " <td style='width:150px'><div id='shortcode_sselector_".$ss_tab."'>"; 48 prepareAdmOutput($ss_tab); 49 echo " </div></td>"; 50 echo " </tr>"; 51 echo "</table>"; 27 52 echo "<!-- Same as the themes options the list of configurable styles and classes is fixed, in this case to ten different styles and classes. -->"; 28 53 echo "<h4>Options for this theme.</h4>"; … … 37 62 echo " <div class='content'>"; 38 63 echo " <fieldset class='stylesel-admin-colors'>"; 39 echo " <table align='center' >";64 echo " <table align='center' width='100%'>"; 40 65 echo " <tr align='center'>"; 41 echo " <td width='50'>Type a name for the option: </td>";42 echo " <td width='50'>Class or element? </td>";43 echo " <td width='50'>Name of the element to manipulate: </td>";44 echo " <td width='150'>Pick the color of the background: </td>";45 echo " <td width='150'>Pick the color of the font: </td>";46 echo " <td width='150'>Background transparency: </td>";47 echo " <td width='150'>Font transparency: </td>";66 echo " <td>Type a name for the option: </td>"; 67 echo " <td>Class or element? </td>"; 68 echo " <td>Name of the element to manipulate: </td>"; 69 echo " <td>Pick the color of the background: </td>"; 70 echo " <td>Pick the color of the font: </td>"; 71 echo " <td>Background transparency: </td>"; 72 echo " <td>Font transparency: </td>"; 48 73 echo " <td>Active?</td>"; 49 74 echo " </tr>"; … … 115 140 * 116 141 */ 117 $ss_fieldTypes = array("ss_ selected_theme", "ss_opt_name", "ss_theme_option_type","ss_element","ss_bg_colorPicker","ss_fn_colorPicker","ss_myRange","ss_myRangeFont","ss_option");142 $ss_fieldTypes = array("ss_disp_head", "ss_select_style", "ss_select_sheet_div", "ss_select_sheet_sel", "ss_selected_theme", "ss_opt_name", "ss_theme_option_type","ss_element","ss_bg_colorPicker","ss_fn_colorPicker","ss_myRange","ss_myRangeFont","ss_option"); 118 143 for ($ss_tab = 1; $ss_tab < 6; $ss_tab++) 119 144 { 120 145 $ss_fieldId = $ss_fieldTypes[0]."_".$ss_tab; 121 146 echo $ss_fieldId."<input type='text' name='".$this->plugin_name."[".$ss_fieldId."]' id='".$ss_fieldId."' value=\"".$options[$ss_fieldId]."\"class='all-options' />"; 147 148 $ss_fieldId = $ss_fieldTypes[1]."_".$ss_tab; 149 echo $ss_fieldId."<input type='text' name='".$this->plugin_name."[".$ss_fieldId."]' id='".$ss_fieldId."' value=\"".$options[$ss_fieldId]."\"class='all-options' />"; 150 151 $ss_fieldId = $ss_fieldTypes[2]."_".$ss_tab; 152 echo $ss_fieldId."<input type='text' name='".$this->plugin_name."[".$ss_fieldId."]' id='".$ss_fieldId."' value=\"".$options[$ss_fieldId]."\"class='all-options' />"; 153 154 $ss_fieldId = $ss_fieldTypes[3]."_".$ss_tab; 155 echo $ss_fieldId."<input type='text' name='".$this->plugin_name."[".$ss_fieldId."]' id='".$ss_fieldId."' value=\"".$options[$ss_fieldId]."\"class='all-options' />"; 156 157 $ss_fieldId = $ss_fieldTypes[4]."_".$ss_tab; 158 echo $ss_fieldId."<input type='text' name='".$this->plugin_name."[".$ss_fieldId."]' id='".$ss_fieldId."' value=\"".$options[$ss_fieldId]."\"class='all-options' />"; 159 122 160 echo "<fieldset class='stylesel-admin-colors'>"; 123 161 for ($ss_count = 1; $ss_count < 11; $ss_count++) 124 162 { 125 for ($ss_fieldCount = 1; $ss_fieldCount < count($ss_fieldTypes); $ss_fieldCount++)163 for ($ss_fieldCount = 5; $ss_fieldCount < count($ss_fieldTypes); $ss_fieldCount++) 126 164 { 127 165 $ss_fieldId = $ss_fieldTypes[$ss_fieldCount]."_".$ss_tab."_".$ss_count; … … 142 180 <p>This plugin creates a select menu that lets a user change the color style of a page or post to be changed acording the settings 143 181 that the blog administrator sets. </p> 144 <p>The admin can choose up to five different themes from the installed ones to be changed by selectin tthem in a drop down at the182 <p>The admin can choose up to five different themes from the installed ones to be changed by selecting them in a drop down at the 145 183 beginning of each tab of the configuration page. Note that you can select the same theme several times if you run out of mods.</p> 146 <p>At each theme tab the admin can set up to ten color modifications to classes or individual elements.</p> 147 <br> 184 <p>At each theme tab the admin can set up to ten color modifications to classes or individual elements.</p> 185 <p>You can configure the style of the selector for each theme. Also you can force the selector to be displayed at the top of the page instead of using a widget or a shortcode.</p> 186 <h4 align="center">Example</h4> 187 <p>Copy this in the "shortcode_sselector" box.<br> <code>font-size: 1.25em; font-weight: bolder; width: 100%; text-align:center; box-sizing: border-box; box-sizing: border-box; border: 2px solid #ccc; border-radius: 7px; padding: 9px 15px 9px 20px;</code></p> 188 <p> And this in the "widget_sselector".<br> <code>font-size: 1.25em; font-weight: bolder; width: 100%; text-align:center; box-sizing: border-box; box-sizing: border-box; border: 2px solid #ccc; border-radius: 7px; padding: 9px 15px 9px 20px;</code></p> 189 148 190 <h3 align="center">Options fields</h3> 149 191 <p>Name an option to be displayed to the user. This option will be added in the select input field.</p> … … 159 201 <p>Save yor changes clicking the blue button at the end of the page</p> 160 202 <h3 align="center">Displaying the select drop down</h3> 161 <p>There are currently two options, fi stis to add the "Style selector widget" that this plugin creates to any sidebar.203 <p>There are currently two options, first one is to add the "Style selector widget" that this plugin creates to any sidebar. 162 204 You can also configure a title for the widget.</p> 163 <p>The second is via a shortcode. Place the shortcode "[s_selector]" anywherw to display the drop down menu</p> 164 <p>Additionally is a last minute adittion, you can uncoment the las line of the widget-selector.php file in the /public/partials dir of the pulugin directory 165 using the wordpress plugin editor to show the drop down at the start of each page.</p> 205 <p>The second is via a shortcode. Place the shortcode <b>"[s_selector]"</b> anywhere to display the drop down menu</p> 166 206 </div> 167 207 <script> 168 208 ss_pass_stored(); 169 209 </script> 170 171 210 </div> 211 <?php 212 //This function doesn't affect the display, is just for testing settings. 213 function prepareAdmOutput($ss_tab) 214 { 215 $options = get_option('styleselector'); 216 $ss_fieldTypes = array("ss_disp_head", "ss_select_style", "ss_select_sheet_div", "ss_select_sheet_sel","ss_selected_theme", "ss_opt_name", "ss_theme_option_type","ss_element","ss_bg_colorPicker","ss_fn_colorPicker","ss_myRange","ss_myRangeFont" ,"ss_option"); 217 $ss_option_value = array("<select onchange='changeProps(this,".$ss_tab.")' id='widget_sselector_".$ss_tab."'><option value='Restore'>Restore</option>"); 218 $ss_option_values = array("Restore"); 219 for ($ss_tab = 1; $ss_tab < 6; $ss_tab++) 220 { 221 $ss_fieldId = $ss_fieldTypes[4]."_".$ss_tab; 222 if (get_stylesheet() == $options[$ss_fieldId]) 223 { 224 for ($ss_count = 1; $ss_count < 11; $ss_count++) 225 { 226 $tem_str = $options["ss_option"."_".$ss_tab."_".$ss_count]; 227 if ($options["ss_option"."_".$ss_tab."_".$ss_count] == 1) 228 { 229 $str = "'".$ss_tab."',"; 230 if (!in_array($options["ss_opt_name"."_".$ss_tab."_".$ss_count], $ss_option_values)) 231 { 232 233 array_push($ss_option_value,"<option value='".$options["ss_opt_name"."_".$ss_tab."_".$ss_count]."'>".$options["ss_opt_name"."_".$ss_tab."_".$ss_count]."</option>"); 234 array_push($ss_option_values,$options["ss_opt_name"."_".$ss_tab."_".$ss_count]); 235 } 236 for ($ss_fieldCount = 5; $ss_fieldCount < count($ss_fieldTypes); $ss_fieldCount++) 237 { 238 $ss_fieldId = $ss_fieldTypes[$ss_fieldCount]."_".$ss_tab."_".$ss_count; 239 if ($ss_fieldCount == 5) 240 {$str = $str."'".$options[$ss_fieldId]."'";} 241 else{$str = $str.",'".$options[$ss_fieldId]."'";} 242 } 243 echo "<script>addOption(".$str.");</script>"; 244 } 245 } 246 } 247 } 248 foreach ($ss_option_value as $key=>$item){echo "$item\n";} 249 echo "</select> 250 <div><span style='font-size:15px;vertical-align:50%;cursor: pointer' title='Click to make the text smaller'>A</span> 251 <span style='font-size:15px;vertical-align:50%;'>➚</span> 252 <span style='font-size:30px; vertical-align:25%;cursor:pointer' title='Click to make the text bigger'>A</span></div>"; 253 254 } 255 ?> -
styles-selector/trunk/assets
-
Property
svn:ignore
set to
screenshot-1.jpg
screenshot-2.jpg
screenshot-3 .jpg
-
Property
svn:ignore
set to
-
styles-selector/trunk/includes/class-styleselector-activator.php
r2165349 r2171771 1 1 <?php 2 3 /**4 * Fired during plugin activation5 *6 * @link https://chafalladas.com7 * @since 1.0.08 *9 * @package Styleselector10 * @subpackage Styleselector/includes11 */12 2 13 3 /** … … 24 14 25 15 /** 26 * Short Description. (use period)16 * Checks version, if needed then remake the database options fields. 27 17 * 28 18 * Long Description. 29 19 * 30 * @since 1. 0.020 * @since 1.1.0 31 21 */ 32 22 public static function activate() { 23 //Check if database is already updated. 24 $options = get_option('styleselector'); 25 if(!isset($options["ss_disp_head_1"])) 26 { 27 options_updatever(); 28 } 29 } 30 } 33 31 34 } 32 // my $sanitize_callback function 35 33 36 } 34 function options_updatever() { 35 $valid = array(); 36 $options = get_option('styleselector'); 37 $ss_fieldTypes = array("ss_disp_head", "ss_select_style", "ss_select_sheet_div", "ss_select_sheet_sel", "ss_selected_theme", "ss_opt_name", "ss_theme_option_type","ss_element","ss_bg_colorPicker","ss_fn_colorPicker","ss_myRange","ss_myRangeFont","ss_option"); 38 for ($ss_tab = 1; $ss_tab < 6; $ss_tab++) 39 { 40 $ss_fieldId = $ss_fieldTypes[0]."_".$ss_tab; 41 $valid[$ss_fieldId] = "1"; 42 $ss_fieldId = $ss_fieldTypes[1]."_".$ss_tab; 43 $valid[$ss_fieldId] = "Custom"; 44 $ss_fieldId = $ss_fieldTypes[2]."_".$ss_tab; 45 $valid[$ss_fieldId] = "font-family: 'IBM Plex Mono', monospace; font-size: 1.15em; width: 100%; box-sizing: border-box; padding: 10px 20px; border: none; border-radius: 10px; background-color: #00f1f1; -webkit-transition: width 0.4s ease-in-out; transition: width 0.4s ease-in-out"; 46 $ss_fieldId = $ss_fieldTypes[3]."_".$ss_tab; 47 $valid[$ss_fieldId] = "width: 100px; margin: auto; box-sizing: border-box; box-sizing: border-box; border: 2px solid #ccc; border-radius: 10px; padding: 12px 20px 12px 40px; background-color: #00f100; -webkit-transition: width 0.4s ease-in-out; transition: width 0.4s ease-in-out"; 48 $ss_fieldId = $ss_fieldTypes[4]."_".$ss_tab; 49 $valid[$ss_fieldId] = $options[$ss_fieldId]; 50 $valid = array_merge($valid,$options); 51 for ($ss_count = 1; $ss_count < 11; $ss_count++) 52 { 53 for ($ss_fieldCount = 5; $ss_fieldCount < count($ss_fieldTypes); $ss_fieldCount++) 54 { 55 $ss_fieldId = $ss_fieldTypes[$ss_fieldCount]."_".$ss_tab."_".$ss_count; 56 $valid[$ss_fieldId] = $options[$ss_fieldId]; 57 } 58 } 59 } 60 update_option('styleselector', $valid ); 61 $message = __('Options updated!.'); 62 $type = 'updated'; 63 // add_settings_error( $setting, $code, $message, $type ) 64 add_settings_error('styleselector', esc_attr( 'settings_updated' ), $message, $type); 65 } 66 -
styles-selector/trunk/includes/class-styleselector.php
r2165349 r2171771 20 20 * Plugin URI: https://chafalladas.com/styles-selector-plugin/ 21 21 * Description: A plugin that changes on the fly the styles of a page. 22 * Version: 1. 0.022 * Version: 1.1.0 23 23 * Requires at least: 5.2 24 * Requires PHP: 7. 224 * Requires PHP: 7.1.3.2 25 25 * Author: Alfonso Abelenda Escudero 26 26 * Author URI: https://chafalladas.com -
styles-selector/trunk/public/js/styleselector-public.js
r2165349 r2171771 35 35 } 36 36 } 37 37 38 //Add new values 38 39 function addOption(a_option,a_class,a_name,a_color,a_font,a_alfab,a_alfaf,dontcare) … … 53 54 } 54 55 } 55 //Change colors 56 function changeProps(wichOption) 57 { 58 var i,j=0; 56 function setSize(size) 57 { 58 var option=getCookie("ss_Option"); 59 if (option == ""){option = "Restore"} 60 changeProps(option,size); 61 } 62 //Clean colors 63 function Restore(typeOfElement, element) 64 { 59 65 for(i=0;i<eleArray.length;i++) 60 66 { 61 if (wichOption == eleArray[i].option)62 { 63 if (eleArray[i].isClass == 0)67 if (eleArray[i].option == "Restore") 68 { 69 if (eleArray[i].isClass == 0) 64 70 { 65 71 var x = document.getElementsByClassName(eleArray[i].eleName); 66 72 for (j = 0; j < x.length; j++) 67 73 { 74 x[j].style.backgroundColor = eleArray[i].rgbColor; 75 x[j].style.color = eleArray[i].rgbFont; 76 } 77 } 78 else 79 { 80 document.getElementById(eleArray[i].eleName).style.backgroundColor = eleArray[i].rgbColor; 81 document.getElementById(eleArray[i].eleName).style.color = eleArray[i].rgbFont; 82 } 83 } 84 } 85 } 86 //Change colors 87 function changeProps(wichOption,size) 88 { 89 Restore(); 90 var i,j,newSize=0; 91 for(i=0;i<eleArray.length;i++) 92 { 93 if(wichOption == eleArray[i].option) 94 { 95 if(eleArray[i].isClass == 0) 96 { 97 var x = document.getElementsByClassName(eleArray[i].eleName); 98 for (j = 0; j < x.length; j++) 99 { 68 100 if (eleArray[i].option == "Restore") 69 101 { 70 x[j].style.backgroundColor = eleArray[i].rgbColor; 71 x[j].style.color = eleArray[i].rgbFont; 102 Restore(); 72 103 } 73 104 else … … 76 107 x[j].style.color = eleArray[i].fnColor(); 77 108 } 109 if(size != null) 110 { 111 newSize = size + parseFloat(x[j].style.fontSize.replace("em", "")); 112 if (isNaN(newSize)){newSize = parseFloat(size) + parseFloat(1.25);} 113 x[j].style.fontSize = newSize + "em"; 114 } 78 115 } 79 116 } … … 82 119 if (eleArray[i].option == "Restore") 83 120 { 84 document.getElementById(eleArray[i].eleName).style.backgroundColor = eleArray[i].rgbColor; 85 document.getElementById(eleArray[i].eleName).style.color = eleArray[i].rgbFont; 121 Restore(); 86 122 } 87 123 else 88 124 { 89 var pp = eleArray[i].fnColor();90 125 document.getElementById(eleArray[i].eleName).style.backgroundColor = eleArray[i].bgColor(); 91 126 document.getElementById(eleArray[i].eleName).style.color = eleArray[i].fnColor(); 92 127 } 128 if(size != null) 129 { 130 newSize = size + parseFloat(document.getElementById(eleArray[i].eleName).style.fontSize.replace("em", "")); 131 if (isNaN(newSize)){newSize = parseFloat(size) + parseFloat(1.25);} 132 document.getElementById(eleArray[i].eleName).style.fontSize = newSize + "em"; 133 } 93 134 } 94 135 } 95 136 } 96 137 setCookie("ss_Option",wichOption,365); 138 if (newSize !== 0){setCookie("ss_Size",newSize,365);} 97 139 } 98 140 //Save previous values … … 109 151 } 110 152 } 111 112 153 if(!exists) 113 154 { … … 148 189 var expires = "expires=" + d.toGMTString(); 149 190 document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; 191 return; 150 192 } 151 193 … … 168 210 function checkCookie() { 169 211 var option=getCookie("ss_Option"); 212 var size=getCookie("ss_Size") - 1.25; 170 213 //console.log("Cookie?"); 214 size = size.toFixed(2) 171 215 if (option != "") 172 216 { 173 217 //console.log("Cookie!"); 174 changeProps(option );218 changeProps(option,size); 175 219 return option; 176 220 } -
styles-selector/trunk/public/partials/widget-styleselector.php
r2165349 r2171771 72 72 { 73 73 $options = get_option('styleselector'); 74 $ss_fieldTypes = array("ss_ selected_theme", "ss_opt_name", "ss_theme_option_type","ss_element","ss_bg_colorPicker","ss_fn_colorPicker","ss_myRange","ss_myRangeFont","ss_option");75 $ss_option_value = array("<form ><select onchange='changeProps(this.value)' class='widget_sselector' disabled><option value='Restore'>Restore</option>");74 $ss_fieldTypes = array("ss_disp_head", "ss_select_style", "ss_select_sheet_div", "ss_select_sheet_sel","ss_selected_theme", "ss_opt_name", "ss_theme_option_type","ss_element","ss_bg_colorPicker","ss_fn_colorPicker","ss_myRange","ss_myRangeFont" ,"ss_option"); 75 $ss_option_value = array("<form title='Select the color of the text'><select onchange='changeProps(this.value)' class='widget_sselector' disabled><option value='Restore'>Restore</option>"); 76 76 $ss_option_values = array("Restore"); 77 77 for ($ss_tab = 1; $ss_tab < 6; $ss_tab++) 78 78 { 79 $ss_fieldId = $ss_fieldTypes[ 0]."_".$ss_tab;79 $ss_fieldId = $ss_fieldTypes[4]."_".$ss_tab; 80 80 if (get_stylesheet() == $options[$ss_fieldId]) 81 81 { 82 82 for ($ss_count = 1; $ss_count < 11; $ss_count++) 83 83 { 84 $tem_str = $options["ss_option"."_".$ss_tab."_".$ss_count]; 84 85 if ($options["ss_option"."_".$ss_tab."_".$ss_count] == 1) 85 86 { … … 91 92 array_push($ss_option_values,$options["ss_opt_name"."_".$ss_tab."_".$ss_count]); 92 93 } 93 for ($ss_fieldCount = 1; $ss_fieldCount < count($ss_fieldTypes); $ss_fieldCount++)94 for ($ss_fieldCount = 5; $ss_fieldCount < count($ss_fieldTypes); $ss_fieldCount++) 94 95 { 95 96 $ss_fieldId = $ss_fieldTypes[$ss_fieldCount]."_".$ss_tab."_".$ss_count; 96 if ($ss_fieldCount == 1)97 if ($ss_fieldCount == 5) 97 98 {$str = "'".$options[$ss_fieldId]."'";} 98 99 else{$str = $str.",'".$options[$ss_fieldId]."'";} … … 104 105 } 105 106 foreach ($ss_option_value as $key=>$item){echo "$item\n";} 106 echo "<form></select>"; 107 echo "</select></form> 108 <div><span style='font-size:15px;vertical-align:50%;cursor: pointer' onclick='setSize(-0.1)' title='Click to make the text smaller'>A</span> 109 <span style='font-size:15px;vertical-align:50%;'>➚</span> 110 <span style='font-size:30px; vertical-align:25%;cursor:pointer' onclick='setSize(0.1)' title='Click to make the text bigger'>A</span></div> 111 "; 107 112 } 108 113 109 114 function short_func() { 110 echo '<div align="center" class="shortcode_sselector"> Select a style:';115 echo '<div align="center" class="shortcode_sselector">'; 111 116 prepareOutput(); 112 //echo 'Style: '.get_stylesheet();113 117 echo '</div>'; 114 118 } 119 120 function add_header() 121 { 122 $options = get_option('styleselector'); 123 for ($ss_tab = 1; $ss_tab < 6; $ss_tab++) 124 { 125 if ($options["ss_disp_head_".$ss_tab] == 1 && get_stylesheet() == $options["ss_selected_theme_".$ss_tab]) 126 { 127 short_func(); 128 } 129 } 130 } 131 115 132 function wpshout_action_example() { 116 133 //Add restore values and enable the select input at the end of the page to prevent errors loading objects 117 134 //Also check a cookie and if exists, sets the option stored. 135 $options = get_option('styleselector'); 118 136 echo '<div style="background: green; color: white; text-align: right;" id="ss_selector_wait"><script> 119 137 var k=0;for (k;k < eleArray.length;k++){saveValues(k);};document.getElementById("ss_selector_wait").style.display = "none"; 120 138 var x = document.getElementsByClassName("widget_sselector"); 121 for (i = 0; i < x.length; i++){x[i].disabled = false;}; 139 for (i = 0; i < x.length; i++){x[i].disabled = false;};'; 140 for ($ss_tab = 1; $ss_tab < 6; $ss_tab++) 141 { 142 if (get_stylesheet() == $options["ss_selected_theme_".$ss_tab]) 143 { 144 $str = $options["ss_select_sheet_div_".$ss_tab]; 145 echo "x = document.getElementsByClassName('widget_sselector'); 146 for (j = 0; j < x.length; j++) 147 { 148 x[j].style = '".$str."'; 149 } 150 "; 151 echo "x = document.getElementsByClassName('shortcode_sselector'); 152 for (j = 0; j < x.length; j++) 153 { 154 x[j].style = '".$str."'; 155 } 156 "; 157 } 158 } 159 echo ' 122 160 var an_option = checkCookie(); 123 for (i = 0; i < x.length; i++){x[i].value = an_option;}; 161 x = document.getElementsByClassName("widget_sselector"); 162 for (i = 0; i < x.length; i++){x[i].value = an_option;}; 124 163 </script>Wait a sec, saving restore vars.</div>'; 125 164 } … … 127 166 add_shortcode( 's_selector','short_func'); 128 167 add_action('wp_footer', 'wpshout_action_example'); 129 //Uncomment to add styles selectore form at the head section 130 //add_action('wp_head', 'short_func'); 168 //Uncomment to add styles selector form at the head section 169 add_action('wp_head', 'add_header'); 170 //add_action('wp_page_menu', 'add_header'); //Some themes could have this option, can crash 171 //add_action('wp_nav_menu', 'add_header'); //Some themes could have this option, can crash 172 //add_action('wp_headers', 'short_func'); //Some themes could have this option, can crash -
styles-selector/trunk/styleselector.php
r2165349 r2171771 17 17 * Plugin URI: https://github.com/Chafalleiro/Styles-selector 18 18 * Description: Changes the styles by classes dinamically. Needs some knowledge about the css styles of the templates to alter. 19 * Version: 1. 0.019 * Version: 1.1.0 20 20 * Author: Alfonso 21 21 * Author URI: https://chafalladas.com
Note: See TracChangeset
for help on using the changeset viewer.