| 1 |
<?php |
| 2 |
function wp_insert_form_accordion_tabs_rules( $control, $identifier, $location ) { |
| 3 |
$posts_per_page = get_option( 'posts_per_page' ); |
| 4 |
$instances = []; |
| 5 |
for ( $i = 1; $i <= $posts_per_page; $i++ ) { |
| 6 |
$instances[] = [ |
| 7 |
'text' => 'Hide on ' . wp_insert_add_ordinal_number_suffix( $i ) . ' Post', |
| 8 |
'value' => $i, |
| 9 |
]; |
| 10 |
} |
| 11 |
|
| 12 |
echo '<h3>Rules</h3>'; |
| 13 |
if ( $location == 'inpostads' ) { |
| 14 |
echo '<div>'; |
| 15 |
$control->add_control( |
| 16 |
[ |
| 17 |
'type' => 'checkbox-button', |
| 18 |
'label' => 'Status : Show Ads', |
| 19 |
'checkedLabel' => 'Status : Hide Ads', |
| 20 |
'uncheckedLabel' => 'Status : Show Ads', |
| 21 |
'optionName' => 'rules_exclude_loggedin', |
| 22 |
] |
| 23 |
); |
| 24 |
$control->create_section( 'Logged in Users' ); |
| 25 |
$control->set_HTML( '<div class="wp_insert_rule_block">' . $control->HTML . '</div>' ); |
| 26 |
wp_insert_echo_html( $control->HTML ); |
| 27 |
$control->clear_controls(); |
| 28 |
|
| 29 |
$control->add_control( |
| 30 |
[ |
| 31 |
'type' => 'checkbox-button', |
| 32 |
'label' => 'Status : Show Ads', |
| 33 |
'checkedLabel' => 'Status : Hide Ads', |
| 34 |
'uncheckedLabel' => 'Status : Show Ads', |
| 35 |
'optionName' => 'rules_exclude_mobile_devices', |
| 36 |
] |
| 37 |
); |
| 38 |
$control->create_section( 'Mobile Devices' ); |
| 39 |
$control->set_HTML( '<div class="wp_insert_rule_block">' . $control->HTML . '</div><div style="clear: both;"></div>' ); |
| 40 |
wp_insert_echo_html( $control->HTML ); |
| 41 |
$control->clear_controls(); |
| 42 |
|
| 43 |
$control->add_control( |
| 44 |
[ |
| 45 |
'type' => 'checkbox-button', |
| 46 |
'label' => 'Status : Show Ads', |
| 47 |
'checkedLabel' => 'Status : Hide Ads', |
| 48 |
'uncheckedLabel' => 'Status : Show Ads', |
| 49 |
'optionName' => 'rules_exclude_404', |
| 50 |
] |
| 51 |
); |
| 52 |
$control->create_section( '404 Pages' ); |
| 53 |
$control->set_HTML( '<div class="wp_insert_rule_block">' . $control->HTML . '</div><div style="clear: both;"></div>' ); |
| 54 |
wp_insert_echo_html( $control->HTML ); |
| 55 |
$control->clear_controls(); |
| 56 |
|
| 57 |
$control->add_control( |
| 58 |
[ |
| 59 |
'type' => 'checkbox-button', |
| 60 |
'label' => 'Status : Show Ads', |
| 61 |
'checkedLabel' => 'Status : Hide Ads', |
| 62 |
'uncheckedLabel' => 'Status : Show Ads', |
| 63 |
'optionName' => 'rules_exclude_home', |
| 64 |
] |
| 65 |
); |
| 66 |
$control->add_control( |
| 67 |
[ |
| 68 |
'type' => 'choosen-multiselect', |
| 69 |
'label' => 'Instances', |
| 70 |
'optionName' => 'rules_home_instances', |
| 71 |
'options' => $instances, |
| 72 |
] |
| 73 |
); |
| 74 |
$control->create_section( 'Home' ); |
| 75 |
$control->set_HTML( '<div class="wp_insert_rule_block">' . $control->HTML . '</div>' ); |
| 76 |
wp_insert_echo_html( $control->HTML ); |
| 77 |
$control->clear_controls(); |
| 78 |
|
| 79 |
$control->add_control( |
| 80 |
[ |
| 81 |
'type' => 'checkbox-button', |
| 82 |
'label' => 'Status : Show Ads', |
| 83 |
'checkedLabel' => 'Status : Hide Ads', |
| 84 |
'uncheckedLabel' => 'Status : Show Ads', |
| 85 |
'optionName' => 'rules_exclude_archives', |
| 86 |
] |
| 87 |
); |
| 88 |
$control->add_control( |
| 89 |
[ |
| 90 |
'type' => 'choosen-multiselect', |
| 91 |
'label' => 'Instances', |
| 92 |
'optionName' => 'rules_archives_instances', |
| 93 |
'options' => $instances, |
| 94 |
] |
| 95 |
); |
| 96 |
$control->create_section( 'Archives' ); |
| 97 |
$control->set_HTML( '<div class="wp_insert_rule_block">' . $control->HTML . '</div><div style="clear: both;"></div>' ); |
| 98 |
wp_insert_echo_html( $control->HTML ); |
| 99 |
$control->clear_controls(); |
| 100 |
|
| 101 |
$control->add_control( |
| 102 |
[ |
| 103 |
'type' => 'checkbox-button', |
| 104 |
'label' => 'Status : Show Ads', |
| 105 |
'checkedLabel' => 'Status : Hide Ads', |
| 106 |
'uncheckedLabel' => 'Status : Show Ads', |
| 107 |
'optionName' => 'rules_exclude_search', |
| 108 |
] |
| 109 |
); |
| 110 |
$control->add_control( |
| 111 |
[ |
| 112 |
'type' => 'choosen-multiselect', |
| 113 |
'label' => 'Instances', |
| 114 |
'optionName' => 'rules_search_instances', |
| 115 |
'options' => $instances, |
| 116 |
] |
| 117 |
); |
| 118 |
$control->create_section( 'Search Results' ); |
| 119 |
$control->set_HTML( '<div class="wp_insert_rule_block">' . $control->HTML . '</div>' ); |
| 120 |
wp_insert_echo_html( $control->HTML ); |
| 121 |
$control->clear_controls(); |
| 122 |
|
| 123 |
$control->add_control( |
| 124 |
[ |
| 125 |
'type' => 'checkbox-button', |
| 126 |
'label' => 'Status : Show Ads', |
| 127 |
'checkedLabel' => 'Status : Hide Ads', |
| 128 |
'uncheckedLabel' => 'Status : Show Ads', |
| 129 |
'optionName' => 'rules_exclude_page', |
| 130 |
] |
| 131 |
); |
| 132 |
$control->add_control( |
| 133 |
[ |
| 134 |
'type' => 'pages-chosen-multiselect', |
| 135 |
'label' => 'Exceptions', |
| 136 |
'optionName' => 'rules_page_exceptions', |
| 137 |
] |
| 138 |
); |
| 139 |
$control->create_section( 'Single Pages' ); |
| 140 |
$control->set_HTML( '<div class="wp_insert_rule_block">' . $control->HTML . '</div><div style="clear: both;"></div>' ); |
| 141 |
wp_insert_echo_html( $control->HTML ); |
| 142 |
$control->clear_controls(); |
| 143 |
|
| 144 |
$control->add_control( |
| 145 |
[ |
| 146 |
'type' => 'checkbox-button', |
| 147 |
'label' => 'Status : Show Ads', |
| 148 |
'checkedLabel' => 'Status : Hide Ads', |
| 149 |
'uncheckedLabel' => 'Status : Show Ads', |
| 150 |
'optionName' => 'rules_exclude_post', |
| 151 |
] |
| 152 |
); |
| 153 |
$control->add_control( |
| 154 |
[ |
| 155 |
'type' => 'posts-chosen-multiselect', |
| 156 |
'label' => 'Exceptions', |
| 157 |
'optionName' => 'rules_post_exceptions', |
| 158 |
] |
| 159 |
); |
| 160 |
$control->add_control( |
| 161 |
[ |
| 162 |
'type' => 'categories-chosen-multiselect', |
| 163 |
'label' => 'Category Exceptions', |
| 164 |
'optionName' => 'rules_post_categories_exceptions', |
| 165 |
] |
| 166 |
); |
| 167 |
$control->create_section( 'Single Posts' ); |
| 168 |
$control->set_HTML( '<div class="wp_insert_rule_block">' . $control->HTML . '</div>' ); |
| 169 |
wp_insert_echo_html( $control->HTML ); |
| 170 |
$control->clear_controls(); |
| 171 |
|
| 172 |
$control->add_control( |
| 173 |
[ |
| 174 |
'type' => 'checkbox-button', |
| 175 |
'label' => 'Status : Show Ads', |
| 176 |
'checkedLabel' => 'Status : Hide Ads', |
| 177 |
'uncheckedLabel' => 'Status : Show Ads', |
| 178 |
'optionName' => 'rules_exclude_categories', |
| 179 |
] |
| 180 |
); |
| 181 |
$control->add_control( |
| 182 |
[ |
| 183 |
'type' => 'choosen-multiselect', |
| 184 |
'label' => 'Instances', |
| 185 |
'optionName' => 'rules_categories_instances', |
| 186 |
'options' => $instances, |
| 187 |
] |
| 188 |
); |
| 189 |
$control->add_control( |
| 190 |
[ |
| 191 |
'type' => 'categories-chosen-multiselect', |
| 192 |
'label' => 'Exceptions', |
| 193 |
'optionName' => 'rules_categories_exceptions', |
| 194 |
] |
| 195 |
); |
| 196 |
$control->create_section( 'Category Archives' ); |
| 197 |
$control->set_HTML( '<div class="wp_insert_rule_block">' . $control->HTML . '</div><div style="clear: both;"></div>' ); |
| 198 |
wp_insert_echo_html( $control->HTML ); |
| 199 |
$control->clear_controls(); |
| 200 |
echo '</div>'; |
| 201 |
} else { |
| 202 |
echo '<div>'; |
| 203 |
$control->add_control( |
| 204 |
[ |
| 205 |
'type' => 'checkbox-button', |
| 206 |
'label' => 'Status : Show Ads', |
| 207 |
'checkedLabel' => 'Status : Hide Ads', |
| 208 |
'uncheckedLabel' => 'Status : Show Ads', |
| 209 |
'optionName' => 'rules_exclude_loggedin', |
| 210 |
] |
| 211 |
); |
| 212 |
$control->create_section( 'Logged in Users' ); |
| 213 |
$control->set_HTML( '<div class="wp_insert_rule_block">' . $control->HTML . '</div>' ); |
| 214 |
wp_insert_echo_html( $control->HTML ); |
| 215 |
$control->clear_controls(); |
| 216 |
|
| 217 |
$control->add_control( |
| 218 |
[ |
| 219 |
'type' => 'checkbox-button', |
| 220 |
'label' => 'Status : Show Ads', |
| 221 |
'checkedLabel' => 'Status : Hide Ads', |
| 222 |
'uncheckedLabel' => 'Status : Show Ads', |
| 223 |
'optionName' => 'rules_exclude_mobile_devices', |
| 224 |
] |
| 225 |
); |
| 226 |
$control->create_section( 'Mobile Devices' ); |
| 227 |
$control->set_HTML( '<div class="wp_insert_rule_block">' . $control->HTML . '</div><div style="clear: both;"></div>' ); |
| 228 |
wp_insert_echo_html( $control->HTML ); |
| 229 |
$control->clear_controls(); |
| 230 |
|
| 231 |
$control->add_control( |
| 232 |
[ |
| 233 |
'type' => 'checkbox-button', |
| 234 |
'label' => 'Status : Show Ads', |
| 235 |
'checkedLabel' => 'Status : Hide Ads', |
| 236 |
'uncheckedLabel' => 'Status : Show Ads', |
| 237 |
'optionName' => 'rules_exclude_404', |
| 238 |
] |
| 239 |
); |
| 240 |
$control->create_section( '404 Pages' ); |
| 241 |
$control->set_HTML( '<div class="wp_insert_rule_block">' . $control->HTML . '</div>' ); |
| 242 |
wp_insert_echo_html( $control->HTML ); |
| 243 |
$control->clear_controls(); |
| 244 |
|
| 245 |
$control->add_control( |
| 246 |
[ |
| 247 |
'type' => 'checkbox-button', |
| 248 |
'label' => 'Status : Show Ads', |
| 249 |
'checkedLabel' => 'Status : Hide Ads', |
| 250 |
'uncheckedLabel' => 'Status : Show Ads', |
| 251 |
'optionName' => 'rules_exclude_home', |
| 252 |
] |
| 253 |
); |
| 254 |
$control->create_section( 'Home' ); |
| 255 |
$control->set_HTML( '<div class="wp_insert_rule_block">' . $control->HTML . '</div><div style="clear: both;"></div>' ); |
| 256 |
wp_insert_echo_html( $control->HTML ); |
| 257 |
$control->clear_controls(); |
| 258 |
|
| 259 |
$control->add_control( |
| 260 |
[ |
| 261 |
'type' => 'checkbox-button', |
| 262 |
'label' => 'Status : Show Ads', |
| 263 |
'checkedLabel' => 'Status : Hide Ads', |
| 264 |
'uncheckedLabel' => 'Status : Show Ads', |
| 265 |
'optionName' => 'rules_exclude_archives', |
| 266 |
] |
| 267 |
); |
| 268 |
$control->create_section( 'Archives' ); |
| 269 |
$control->set_HTML( '<div class="wp_insert_rule_block">' . $control->HTML . '</div>' ); |
| 270 |
wp_insert_echo_html( $control->HTML ); |
| 271 |
$control->clear_controls(); |
| 272 |
|
| 273 |
$control->add_control( |
| 274 |
[ |
| 275 |
'type' => 'checkbox-button', |
| 276 |
'label' => 'Status : Show Ads', |
| 277 |
'checkedLabel' => 'Status : Hide Ads', |
| 278 |
'uncheckedLabel' => 'Status : Show Ads', |
| 279 |
'optionName' => 'rules_exclude_search', |
| 280 |
] |
| 281 |
); |
| 282 |
$control->create_section( 'Search Results' ); |
| 283 |
$control->set_HTML( '<div class="wp_insert_rule_block">' . $control->HTML . '</div><div style="clear: both;"></div>' ); |
| 284 |
wp_insert_echo_html( $control->HTML ); |
| 285 |
$control->clear_controls(); |
| 286 |
|
| 287 |
$control->add_control( |
| 288 |
[ |
| 289 |
'type' => 'checkbox-button', |
| 290 |
'label' => 'Status : Show Ads', |
| 291 |
'checkedLabel' => 'Status : Hide Ads', |
| 292 |
'uncheckedLabel' => 'Status : Show Ads', |
| 293 |
'optionName' => 'rules_exclude_page', |
| 294 |
] |
| 295 |
); |
| 296 |
$control->add_control( |
| 297 |
[ |
| 298 |
'type' => 'pages-chosen-multiselect', |
| 299 |
'label' => 'Exceptions', |
| 300 |
'optionName' => 'rules_page_exceptions', |
| 301 |
] |
| 302 |
); |
| 303 |
$control->create_section( 'Single Pages' ); |
| 304 |
$control->set_HTML( '<div class="wp_insert_rule_block">' . $control->HTML . '</div>' ); |
| 305 |
wp_insert_echo_html( $control->HTML ); |
| 306 |
$control->clear_controls(); |
| 307 |
|
| 308 |
$control->add_control( |
| 309 |
[ |
| 310 |
'type' => 'checkbox-button', |
| 311 |
'label' => 'Status : Show Ads', |
| 312 |
'checkedLabel' => 'Status : Hide Ads', |
| 313 |
'uncheckedLabel' => 'Status : Show Ads', |
| 314 |
'optionName' => 'rules_exclude_categories', |
| 315 |
] |
| 316 |
); |
| 317 |
$control->add_control( |
| 318 |
[ |
| 319 |
'type' => 'categories-chosen-multiselect', |
| 320 |
'label' => 'Exceptions', |
| 321 |
'optionName' => 'rules_categories_exceptions', |
| 322 |
] |
| 323 |
); |
| 324 |
$control->create_section( 'Category Archives' ); |
| 325 |
$control->set_HTML( '<div class="wp_insert_rule_block">' . $control->HTML . '</div><div style="clear: both;"></div>' ); |
| 326 |
wp_insert_echo_html( $control->HTML ); |
| 327 |
$control->clear_controls(); |
| 328 |
|
| 329 |
$control->add_control( |
| 330 |
[ |
| 331 |
'type' => 'checkbox-button', |
| 332 |
'label' => 'Status : Show Ads', |
| 333 |
'checkedLabel' => 'Status : Hide Ads', |
| 334 |
'uncheckedLabel' => 'Status : Show Ads', |
| 335 |
'optionName' => 'rules_exclude_post', |
| 336 |
] |
| 337 |
); |
| 338 |
$control->add_control( |
| 339 |
[ |
| 340 |
'type' => 'posts-chosen-multiselect', |
| 341 |
'label' => 'Exceptions', |
| 342 |
'optionName' => 'rules_post_exceptions', |
| 343 |
] |
| 344 |
); |
| 345 |
$control->add_control( |
| 346 |
[ |
| 347 |
'type' => 'categories-chosen-multiselect', |
| 348 |
'label' => 'Category Exceptions', |
| 349 |
'optionName' => 'rules_post_categories_exceptions', |
| 350 |
] |
| 351 |
); |
| 352 |
$control->create_section( 'Single Posts' ); |
| 353 |
$control->set_HTML( '<div class="wp_insert_rule_block">' . $control->HTML . '</div><div style="clear: both;"></div>' ); |
| 354 |
wp_insert_echo_html( $control->HTML ); |
| 355 |
$control->clear_controls(); |
| 356 |
echo '</div>'; |
| 357 |
} |
| 358 |
return $control; |
| 359 |
} |
| 360 |
|