Changeset 2446754
- Timestamp:
- 12/28/2020 11:53:33 AM (5 years ago)
- Location:
- text-filtering/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (1 diff)
-
textfiltering.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
text-filtering/trunk/readme.txt
r2446703 r2446754 17 17 2. You can add as many filters as you want and then remove when you no longer need them to be applied to your posts. 18 18 3. The filters will replace the content accordingly as specified in the settings during page rendering and do not change the content you have saved in the posts. The Plugin does not alter any of your saved contents, but filters the text during the page load. 19 20 == Changelog == 21 22 = 1.0.0 = 23 * First Release 24 25 = 2.1.0 = 26 * Included option to enable or disable a filter, rather than delete a filter permanentaly and add later. -
text-filtering/trunk/textfiltering.php
r2446167 r2446754 3 3 * Plugin Name: Text Filtering 4 4 * Description: Filter out the text in your posts, replace them with your preferred phrase across all your posts or for the specified category posts. 5 * Version: 1.0.05 * Version: 2.1.0 6 6 * Author: Arun Thomas 7 7 * Text Domain: text-filtering … … 36 36 37 37 for($i=0;$i<$filters_count;$i++){ 38 if( ( in_array(get_option('textfiltering_option_3_name')[$i], $category_array))||(get_option('textfiltering_option_3_name')[$i] == 'All') ){38 if( ((in_array(get_option('textfiltering_option_3_name')[$i], $category_array))||(get_option('textfiltering_option_3_name')[$i] == 'All')) & (get_option('textfiltering_option_enable')[$i] == 1) ){ 39 39 $content = str_ireplace(get_option('textfiltering_option_name')[$i], get_option('textfiltering_option_2_name')[$i], $content); 40 40 } … … 49 49 add_option( 'textfiltering_option_2_name', ['*text muted*']); 50 50 add_option( 'textfiltering_option_3_name', ['All']); 51 add_option( 'textfiltering_option_enable', [1]); 51 52 52 53 register_setting( 'textfiltering_options_group', 'textfiltering_option_name', 'textfiltering_callback' ); 53 54 register_setting( 'textfiltering_options_group', 'textfiltering_option_2_name', 'textfiltering_callback' ); 54 55 register_setting( 'textfiltering_options_group', 'textfiltering_option_3_name', 'textfiltering_callback' ); 56 register_setting( 'textfiltering_options_group', 'textfiltering_option_enable', 'textfiltering_callback' ); 55 57 } 56 58 add_action( 'admin_init', 'textfiltering_register_settings' ); … … 109 111 110 112 <h1>Text Filtering</h1> 111 <form method="post" action="options.php" >113 <form method="post" action="options.php" onsubmit="validate_textfiltering_settings()"> 112 114 <?php settings_fields( 'textfiltering_options_group' ); ?> 113 115 <p>Specify your text filtering <a class="button button-primary" onclick="textfiltering_addfilter()"><span class="dashicons dashicons-plus" style="vertical-align: middle"></span> Add Filter</a></p> … … 124 126 <th scope="row"> 125 127 <label for="textfiltering_option_3_name">Category</label> 128 </th> 129 <th scope="row"> 130 <label for="textfiltering_option_enable">Enable</label> 126 131 </th> 127 132 <th> … … 151 156 <?php } ?> 152 157 </select> 158 </td> 159 <td style="text-align: center"> 160 <input class="enable-checkbox" type="checkbox" name="textfiltering_option_enable[]" value="1" width="100%" <?php if(get_option('textfiltering_option_enable')[$i] == 1){ echo "checked"; } ?> /> 161 <input class="enable-checkbox-hidden" type="hidden" name="textfiltering_option_enable[]" value="0" /> 153 162 </td> 154 163 <td> … … 170 179 } 171 180 181 function validate_textfiltering_settings(){ 182 var checkboxes = document.getElementsByClassName("enable-checkbox"); 183 var checkboxes_hidden = document.getElementsByClassName("enable-checkbox-hidden"); 184 for (var i = 0; i < checkboxes.length; i++) { 185 if( (checkboxes.item(i)).checked ) { 186 (checkboxes_hidden.item(i)).disabled = true; 187 } 188 } 189 } 190 172 191 function textfiltering_addfilter(){ 173 192 var element = document.getElementById('textfiltering-filter-block'); … … 191 210 new_filter_html+='</select>' 192 211 +'</td>' 212 +'<td style="text-align: center"><input class="enable-checkbox" type="checkbox" name="textfiltering_option_enable[]" value="1" width="100%" checked /><input class="enable-checkbox-hidden" type="hidden" name="textfiltering_option_enable[]" value="0" checked /></td>' 193 213 +'<td>' 194 214 +'<a class="button" style="width: 100%; text-align: center" onclick="textfiltering_removefilter('+filters_count+')"><span class="dashicons dashicons-trash" style="vertical-align: middle"></span> Remove</a>'
Note: See TracChangeset
for help on using the changeset viewer.