Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: AB Test
- Description: Display different theme
- Author: RSmol
- */
- add_filter('template', 'change_theme');
- add_filter('option_template', 'change_theme');
- add_filter('option_stylesheet', 'change_theme');
- function change_theme($theme) {
- if ($_GET['ab_test'] == 'ab_test') {
- $theme = 'tolstovka_new';
- }
- if (!get_option( 'ab_test_name' )) {
- return $theme;
- }
- if (strpos($_SERVER['REQUEST_URI'], 'tekstil/futbolki/') !== false) {
- require_once __DIR__ . '/ABTest.php';
- if (ABTest::instance()->getTestValue('print_capital_new_template_t-shirt') === 'new') {
- $theme = 'tolstovka_new';
- }
- }
- return $theme;
- }
- add_action( 'admin_init', 'ab_tests_api_init' );
- function ab_tests_api_init() {
- add_settings_section(
- 'ab_test_section', // секция
- 'Настройки AB тестирования',
- 'ab_test_section_callback_function',
- 'reading' // страница
- );
- add_settings_field(
- 'ab_test_name',
- 'Включить AB тестирование',
- 'ab_test_callback_function', // можно указать ''
- 'reading', // страница
- 'ab_test_section' // секция
- );
- register_setting( 'reading', 'ab_test_name' );
- }
- function ab_test_section_callback_function() {
- }
- function ab_test_callback_function() {
- echo '<input
- name="ab_test_name"
- type="checkbox"
- ' . checked( 1, get_option( 'ab_test_name' ), false ) . '
- value="1"
- class="code"
- />';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement