Plugin Directory

Changeset 1305017


Ignore:
Timestamp:
12/10/2015 07:27:48 AM (10 years ago)
Author:
baseapp
Message:

Admin Button

Location:
wpbase-cache/trunk
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • wpbase-cache/trunk/wpbase-cache-admin.php

    r1220845 r1305017  
    4242        );
    4343
     44    add_settings_field(
     45                'wpbase_cache_options_admin_bar_button', 'Show dashboard button in admin bar', array($this, 'admin_bar_button_input'), 'wpbasecache', 'wpbase_cache_section'
     46        );
    4447
    45 
     48       
    4649        add_settings_field(
    4750                'wpbase_cache_options_varnish_cache', 'Enable Varnish Cache', array($this, 'varnish_cache_input'), 'wpbasecache', 'wpbase_cache_section'
     
    5760    }
    5861
     62    public function admin_bar_button_input(){
     63        $options = get_option('wpbase_cache_options');
     64        $checked = checked(1, $options['admin_bar_button'], FALSE);
     65        if (!(defined('WPBASE_CACHE_SANDBOX') && WPBASE_CACHE_SANDBOX)) {
     66            echo "<input id='wpbase_cache_admin_bar_button' name='wpbase_cache_options[admin_bar_button]' type='checkbox' value='1' $checked />";
     67        } else {
     68            echo "<input id='wpbase_cache_admin_bar_button' disabled='disabled' name='wpbase_cache_options[admin_bar_button]' type='checkbox' value='1' $checked />";
     69        }
     70    }
     71   
     72   
    5973    public function varnish_cache_input() {
    6074        $options = get_option('wpbase_cache_options');
  • wpbase-cache/trunk/wpbase-cache.php

    r1298973 r1305017  
    44Plugin URI: https://github.com/baseapp/wpbase-cache
    55Description: A wordpress plugin for using all caches on varnish, nginx, php-fpm stack with php-apc. This plugin includes db-cache-reloaded-fix for dbcache.
    6 Version: 2.1.5
     6Version: 2.1.6
    77Author: Vikrant Datta
    88Author URI: http://blog.wpoven.com
     
    2727define('WPBASE_CACHE_DIR', WP_PLUGIN_DIR . '/wpbase-cache');
    2828define('WPBASE_CACHE_INC_DIR', WP_PLUGIN_DIR . '/wpbase-cache/inc');
    29 
     29add_action( 'admin_enqueue_scripts', function()
     30{
     31    wp_register_style('style',  plugin_dir_url(__FILE__ ).'/style.css',false);
     32    wp_enqueue_style( 'style');
     33});
    3034//$path = dirname(dirname(dirname(__FILE__)));
    3135//if(is_file($path.'/db.php')){
     
    3842    }
    3943}
     44function check_wpoven_site() {
     45    $check_path = dirname(dirname(dirname(ABSPATH)));
     46    if (is_file($check_path . '/bamon/key')) {
     47       function custom_button_example($wp_admin_bar) {
     48            $file = ABSPATH . 'wp-config.php';
     49            $content = file_get_contents($file);
     50            $match = '';
     51            preg_match('/define.*DB_NAME.*\'(.*)\'/', $content, $match);
     52            $dbname = $match[1];
     53            $sitename = substr($dbname, 2);
     54            $ch = curl_init();
     55            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     56            curl_setopt($ch, CURLOPT_URL, "https://wpoven.com/sites/checksiteinfo/" . $sitename);
     57            $content = curl_exec($ch);
     58            curl_close($ch);
     59            //$return_array = explode(",", $content);
     60            $return_array = json_decode($content,true);
     61            //var_dump($return_array);
     62            if ($return_array['status'] == "true") {
     63                $args = array(
     64                    'id' => 'Dashboard-button',
     65                    'title' => $return_array['panel_title'].' Dashboard',
     66                    'href' => $return_array['hostname'] . '/sites/view/' . $return_array['siteuid'],
     67                    'meta' => array(
     68                        'class' => 'dashboard-button-class'
     69                    )
     70                );
     71                $wp_admin_bar->add_node($args);
     72            }
     73            else{
     74                $args = array(
     75                'id' => 'WPOven-button',
     76                'title' => 'WPOven Site Dashboard',
     77                'href' => 'https://wpoven.com/sites/edit/'.$sitename,
     78                'meta' => array(
     79                    'class' => 'dashboard-button-class'
     80                )
     81            );
     82            $wp_admin_bar->add_node($args);
     83            }
     84        }
     85
     86        add_action('admin_bar_menu', 'custom_button_example', 100);
     87    }
     88}
     89$options = get_option('wpbase_cache_options');
     90if(isset($options['admin_bar_button']))
     91    add_action('init', 'check_wpoven_site');
    4092
    4193register_activation_hook(__FILE__, 'upon_activation');
     
    64116            'db_cache' => '0',
    65117            'varnish_cache' => '1',
    66             'send_as' => 'noreply'
     118            'send_as' => 'noreply',
     119            'admin_bar_button' => '1'
    67120                //'reject_url' => '',
    68121                //'reject_cookie' => '',
     
    80133            'db_cache' => '0',
    81134            'varnish_cache' => '0',
    82             'send_as' => '0'
     135            'send_as' => '0',
     136             'admin_bar_button' => ''
    83137                //'reject_url' => '',
    84138                //'reject_cookie' => '',
     
    227281    }
    228282    }
     283 
Note: See TracChangeset for help on using the changeset viewer.