Plugin Directory

Changeset 1236313


Ignore:
Timestamp:
09/02/2015 12:30:06 PM (11 years ago)
Author:
Octavius.rocks
Message:

1.3.4 AB enable option

Location:
octavius-rocks/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • octavius-rocks/trunk/admin/class-octavius-client-admin.php

    r1220938 r1236313  
    9292            array($this, 'control_top_clicks')      // Controll Function
    9393        );
    94 
    95         wp_add_dashboard_widget(
    96             'octavius_ab_results',
    97             'A/B Results',
    98             array($this, 'render_ab_results'),
    99             array($this, 'control_ab_results')
    100         );
     94        if($this->variants->enabled()){
     95            wp_add_dashboard_widget(
     96                'octavius_ab_results',
     97                'A/B Results',
     98                array($this, 'render_ab_results'),
     99                array($this, 'control_ab_results')
     100            );
     101        }
    101102    }
    102103    private function dashboardOptions($options = null){
     
    151152        wp_enqueue_script( 'octavius-admin-dashboard', plugin_dir_url( __FILE__ ) . 'js/octavius-dashboard.js', array(), '1.0', true );
    152153
    153         // require_once dirname(__FILE__)."/../classes/Octavius_Top_Links_Table.php";
    154         // $wp_list_table = new Octavius_Top_Links_Table();
    155         // $wp_list_table->prepare_items($options["number"]);
    156         // $wp_list_table->display();
    157        
    158         // TODO: enqueue js
    159154        include dirname(__FILE__)."/partials/octavius-dashboard-top-clicks.php";
    160155
  • octavius-rocks/trunk/admin/class-octavius-client-settings.php

    r1183285 r1236313  
    8383         * save if needed
    8484         */
     85        if(isset($_POST['submit'])){
     86            /**
     87             * update ab settings
     88             */
     89            $enabled = 0;
     90            if(isset($_POST["octavius_rocks_ab_enabled"])){
     91                $enabled = intval($_POST["octavius_rocks_ab_enabled"]);
     92            }
     93            if($enabled < 1){
     94                $enabled = 0;
     95            } else {
     96                $enabled = 1;
     97            }
     98            $this->variants->enabled($enabled);
     99        }
    85100        if(isset($_POST) && isset($_POST["octavius_rocks"]) && is_array($_POST["octavius_rocks"])){
    86101            $oc = $_POST["octavius_rocks"];
     
    109124            }
    110125            $this->variants->save($values);
    111             /**
    112              * update ab settings
    113              */
    114             update_option('octavius_rocks_ab_min_hits', intval($_POST["octavius_rocks_ab_min_hits"]));
    115126        }
    116127        /**
    117128         * render settings page
    118129         */
    119         $min_hits = get_option('octavius_rocks_ab_min_hits', 10);
     130        $ab_enabled = $this->variants->enabled();
    120131        $all = $this->variants->get();
    121132        require dirname(__FILE__)."/partials/octavius-settings-ab.php";
  • octavius-rocks/trunk/admin/partials/octavius-settings-ab.php

    r1183285 r1236313  
    11<form method="post" action="<?php echo $_SERVER["PHP_SELF"]; ?>?page=octavius-rocks&amp;tab=ab">
    22   
     3    <h2>Settings</h2>
     4    <table class="form-table">
     5        <tbody>
     6            <tr>
     7                <tr>
     8                    <th scope="row"><?php echo __("Turn on A/B tests for posts"); ?></th>
     9                    <td><input type="checkbox" id="octavius_rocks_ab_enabled" value="1"
     10                    <?php if($ab_enabled) echo "checked='checked'"; ?>
     11                    name="octavius_rocks_ab_enabled"> <?php
     12                    if($ab_enabled) {
     13                        echo __("Enabled");
     14                    } else {
     15                        echo __("Disabled");
     16                    }
     17                    ?></td>
     18                </tr>
     19            </tr>
     20        </tbody>
     21    </table>
     22   
    323    <h2>Variants</h2>
     24    <?php
     25    if($ab_enabled):
     26    ?>
    427    <table>
    528        <tbody>
     
    3154        </tbody>
    3255    </table>
    33 
    34 
    35     <h2>Settings</h2>
    36     <table class="form-table">
    37         <tbody>
    38             <tr>
    39                 <th scope="row"><label for="octavius_rocks_ab_min_hits">Show on Dashboard after minimun of x Hits</label></th>
    40                 <td><input type="text" id="octavius_rocks_ab_min_hits" name="octavius_rocks_ab_min_hits" value="<?php echo $min_hits; ?>"
    41                 class="regular-text" placeholder="Number of Hits"></td>
    42             </tr>
    43         </tbody>
    44     </table>
     56    <?php
     57    else:
     58        ?>
     59    <p><?php echo __("Enable A/B Tests to see more options"); ?></p>
     60    <?php
     61    endif;
     62    ?>
     63   
    4564
    4665    <?php submit_button("Save"); ?>
  • octavius-rocks/trunk/includes/class-octavius-client.php

    r1230199 r1236313  
    3838
    3939        $this->plugin_name = 'octavius-client';
    40         $this->version = '1.3.3';
     40        $this->version = '1.3.4';
    4141
    4242        $this->load_dependencies();
     
    162162         * if there is an alternate teaser variante render meta box
    163163         */
    164         if(count($this->variants->get()) > 0){
     164        if( $this->variants->enabled() && count($this->variants->get()) > 0){
    165165            $this->loader->add_action('add_meta_boxes', $plugin_admin, 'add_meta_box_ab');
    166166            $this->loader->add_action('save_post', $plugin_admin, 'save_meta_box_ab');
  • octavius-rocks/trunk/includes/class-octavius-rocks-ab-variants-store.php

    r1220938 r1236313  
    4747        return get_post_meta($post_id,"_octavius_rocks_variant",true);
    4848    }
     49    /**
     50     * is octavius enabled?
     51     */
     52    public function enabled( $enabled = null ){
     53        if($enabled !== null){
     54            update_option("_octavius_rocks_ab_enabled", $enabled);
     55        }
     56        return get_option('_octavius_rocks_ab_enabled', false);
     57    }
    4958}
  • octavius-rocks/trunk/octavius-client.php

    r1230199 r1236313  
    88 * Plugin URI:        http://www.palasthotel.de
    99 * Description:       Tacking click paths
    10  * Version:           1.3.3
     10 * Version:           1.3.4
    1111 * Author:            PALASTHOTEL by Edward
    1212 * Author URI:        http://www.palasthotel.de
  • octavius-rocks/trunk/readme.txt

    r1230199 r1236313  
    55Requires at least: 4.0
    66Tested up to: 4.3
    7 Stable tag: 1.3.3
     7Stable tag: 1.3.4
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3333
    3434== Changelog ==
     35
     36= 1.3.4 =
     37 * Enable or disable A/B Tests for post option
    3538
    3639= 1.3.3 =
Note: See TracChangeset for help on using the changeset viewer.