Plugin Directory

Changeset 3355671


Ignore:
Timestamp:
09/03/2025 09:12:18 PM (7 months ago)
Author:
goqsystem
Message:

format code

Location:
goqmieruca
Files:
12 edited
1 copied

Legend:

Unmodified
Added
Removed
  • goqmieruca/tags/1.0.2/admin/class-admin-page.php

    r1935300 r3355671  
    11<?php
    2 class GOQMIERUCA_Admin_Page {
     2class GOQMIERUCA_Admin_Page
     3{
    34    public $action_status, $action_message;
    45    public $error_message = array();
     
    910    protected $plugin_screen_hook_suffix = null;
    1011
    11     public function __construct() {
     12    public function __construct()
     13    {
    1214        $plugin = GOQMIERUCA::get_instance();
    1315        $this->plugin_slug = $plugin->get_plugin_slug();
     
    1517        $this->menu_slug = $admin->get_toplevel_menu_slug();
    1618        $this->submenu_slug = $admin->get_submenu_slug();
    17 //      $this->clear_action_status();
    1819        /*******************************************/
    1920
    20         add_action( 'admin_head', array( $this, 'add_admin_head' ) );
     21        add_action('admin_head', array($this, 'add_admin_head'));
    2122
    2223        // Load admin style sheet and JavaScript.
    23         add_action( 'admin_print_styles', array( $this, 'enqueue_admin_styles' ) );
    24         add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
     24        add_action('admin_print_styles', array($this, 'enqueue_admin_styles'));
     25        add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'));
    2526
    2627        // Add the options page and menu item.
    27         add_action( 'admin_menu', array( $this, 'add_admin_menu' ) );
     28        add_action('admin_menu', array($this, 'add_admin_menu'));
    2829
    2930        //スクリーン自体の表示・非表示
    30         add_filter( 'screen_options_show_screen', array( $this, 'admin_show_screen' ), 10, 2 );
     31        add_filter('screen_options_show_screen', array($this, 'admin_show_screen'), 10, 2);
    3132
    3233        //スクリーンの表示件数取得
    33         add_filter( 'set-screen-option', array( $this, 'admin_set_screen_options' ), 10, 3 );
     34        add_filter('set-screen-option', array($this, 'admin_set_screen_options'), 10, 3);
    3435
    35         add_filter( 'contextual_help', array( $this, 'admin_help_setting' ), 900, 3 );
    36         add_action( 'admin_print_footer_scripts', array( $this, 'admin_scripts' ) );
    37         add_action( 'admin_print_footer_scripts', array( $this, 'admin_page_scripts' ) );
    38         add_action( 'admin_footer', array( $this, 'clear_action_status' ) );
     36        add_filter('contextual_help', array($this, 'admin_help_setting'), 900, 3);
     37        add_action('admin_print_footer_scripts', array($this, 'admin_scripts'));
     38        add_action('admin_print_footer_scripts', array($this, 'admin_page_scripts'));
     39        add_action('admin_footer', array($this, 'clear_action_status'));
    3940    }
    4041
     
    5152     * @since     1.0.0
    5253     ***********************************/
    53     public function admin_help_setting( $help, $screen_id, $screen ) {
    54 
    55     }
     54    public function admin_help_setting($help, $screen_id, $screen) {}
    5655
    5756    /***********************************
     
    6059     * @since     1.0.0
    6160     ***********************************/
    62     public function add_admin_head() {
    63         //if( $this->action_status == 'edit' || $this->action_status == 'editpost' ) {
    64     //      add_thickbox();
    65         //}
     61    public function add_admin_head()
     62    {
    6663    }
    6764
     
    7168     * @since     1.0.0
    7269     ***********************************/
    73     public function enqueue_admin_styles() {
    74         if( !isset( $this->plugin_screen_hook_suffix ) )
     70    public function enqueue_admin_styles()
     71    {
     72        if (!isset($this->plugin_screen_hook_suffix))
    7573            return;
    7674
     
    7876        $screen = get_current_screen();
    7977
    80         if( $this->plugin_screen_hook_suffix == $screen->id ) {
    81             wp_enqueue_style( $this->plugin_slug .'-admin-styles', GOQMIERUCA_PLUGIN_URL.'/admin/assets/css/admin.css', array(), GOQMIERUCA_VERSION );
     78        if ($this->plugin_screen_hook_suffix == $screen->id) {
     79            wp_enqueue_style($this->plugin_slug . '-admin-styles', GOQMIERUCA_PLUGIN_URL . '/admin/assets/css/admin.css', array(), GOQMIERUCA_VERSION);
    8280
    83             $ui = $wp_scripts->query( 'jquery-ui-core' );
    84             $url = "//ajax.googleapis.com/ajax/libs/jqueryui/{$ui->ver}/themes/redmond/jquery-ui.min.css";
    85             wp_enqueue_style( 'jquery-ui-redmond', $url, false, null );
     81            $ui = $wp_scripts->query('jquery-ui-core');
     82            $url = "//ajax.googleapis.com/ajax/libs/jqueryui/{$ui->ver}/themes/redmond/jquery-ui.min.css";
     83            wp_enqueue_style('jquery-ui-redmond', $url, false, null);
    8684
    87             $url = "//fonts.googleapis.com/earlyaccess/notosansjapanese.css";
    88             wp_enqueue_style( 'notosansjapanese', $url, false, null );
     85            $url = "//fonts.googleapis.com/earlyaccess/notosansjapanese.css";
     86            wp_enqueue_style('notosansjapanese', $url, false, null);
    8987        }
    9088    }
     
    9593     * @since     1.0.0
    9694     ***********************************/
    97     public function enqueue_admin_scripts() {
    98         if( !isset( $this->plugin_screen_hook_suffix ) )
     95    public function enqueue_admin_scripts()
     96    {
     97        if (!isset($this->plugin_screen_hook_suffix))
    9998            return;
    10099
    101100        $screen = get_current_screen();
    102101
    103         if( $this->plugin_screen_hook_suffix == $screen->id ) {
    104             wp_enqueue_script( 'jquery-color' );
    105             wp_enqueue_script( 'jquery-ui-tabs' );
    106             wp_enqueue_script( 'jquery-ui-dialog' );
     102        if ($this->plugin_screen_hook_suffix == $screen->id) {
     103            wp_enqueue_script('jquery-color');
     104            wp_enqueue_script('jquery-ui-tabs');
     105            wp_enqueue_script('jquery-ui-dialog');
    107106        }
    108107    }
     
    114113     * NOTE:  $show_screen = 1は表示オプションを表示、0は非表示
    115114     ***********************************/
    116     public function admin_show_screen( $show_screen, $screen ) {
     115    public function admin_show_screen($show_screen, $screen)
     116    {
    117117        return $show_screen;
    118118    }
     
    124124     * NOTE:  screen_options_show_screen にフックして、保存されたリストの表示件数を適用
    125125     ***********************************/
    126     public function admin_set_screen_options( $result, $option, $value ) {
    127 //      $screens = array( self::$per_page_slug );
    128 //      if( in_array( $option, $screens ) )
    129 //          $result = $value;
    130 //
     126    public function admin_set_screen_options($result, $option, $value)
     127    {
    131128        return $result;
    132129    }
     
    137134     * @since    1.0.0
    138135     ***********************************/
    139     public function add_admin_menu() {
    140 
    141     }
     136    public function add_admin_menu() {}
    142137
    143138    /***********************************
     
    146141     * @since    1.0.0
    147142     ***********************************/
    148     public function set_action_status( $status, $message ) {
     143    public function set_action_status($status, $message)
     144    {
    149145        $this->action_status = $status;
    150146        $this->action_message = $message;
     
    158154     * @since    1.0.0
    159155     ***********************************/
    160     public function clear_action_status() {
     156    public function clear_action_status()
     157    {
    161158        $this->action_status = 'none';
    162159        $this->action_message = '';
     
    170167     * @since    1.0.0
    171168     *******************************/
    172     public function admin_scripts() {
    173         if( !isset( $this->plugin_screen_hook_suffix ) )
     169    public function admin_scripts()
     170    {
     171        if (!isset($this->plugin_screen_hook_suffix))
    174172            return;
    175173
    176174        $screen = get_current_screen();
    177         if( $this->plugin_screen_hook_suffix != $screen->id )
     175        if ($this->plugin_screen_hook_suffix != $screen->id)
    178176            return;
    179177?>
    180 <script type="text/javascript">
     178        <script type="text/javascript">
    181179
    182 </script>
     180        </script>
    183181<?php
    184182    }
     
    189187     * @since    1.0.0
    190188     *******************************/
    191     public function admin_page_scripts() {
    192 
    193     }
     189    public function admin_page_scripts() {}
    194190}
  • goqmieruca/tags/1.0.2/admin/class-admin-setting.php

    r1935300 r3355671  
    11<?php
    2 class GOQMIERUCA_Setting extends GOQMIERUCA_Admin_Page {
     2class GOQMIERUCA_Setting extends GOQMIERUCA_Admin_Page
     3{
    34
    45    protected static $instance = null;
     
    2627     * @since     1.0.0
    2728     ***********************************/
    28     public function __construct() {
     29    public function __construct()
     30    {
    2931        parent::__construct();
    3032    }
     
    3739     * @return    object    A single instance of this class.
    3840     ***********************************/
    39     public static function get_instance() {
    40         if ( null == self::$instance ) {
     41    public static function get_instance()
     42    {
     43        if (null == self::$instance) {
    4144            self::$instance = new self;
    4245        }
     
    5053     * @since     1.0.0
    5154     ***********************************/
    52     protected function init() {
     55    protected function init()
     56    {
    5357        $this->title = '';
    5458    }
     
    5963     * @since     1.0.0
    6064     ***********************************/
    61     public function admin_help_setting( $help, $screen_id, $screen ) {
    62     }
     65    public function admin_help_setting($help, $screen_id, $screen) {}
    6366
    6467    /***********************************
     
    6770     * @since     1.0.0
    6871     ***********************************/
    69     public function enqueue_admin_styles() {
    70         if( !isset( $this->plugin_screen_hook_suffix ) )
     72    public function enqueue_admin_styles()
     73    {
     74        if (!isset($this->plugin_screen_hook_suffix))
    7175            return;
    7276
    7377        parent::enqueue_admin_styles();
    7478        $screen = get_current_screen();
    75         if ( $this->plugin_screen_hook_suffix == $screen->id ) {
    76             //wp_enqueue_style( $this->plugin_slug .'_admin_coupon_styles', plugins_url( 'assets/css/admin-setting.css', __FILE__ ), array(), GOQMIERUCA_VERSION );
     79        if ($this->plugin_screen_hook_suffix == $screen->id) {
    7780        }
    7881    }
     
    8386     * @since     1.0.0
    8487     ***********************************/
    85     public function enqueue_admin_scripts() {
    86         if( !isset( $this->plugin_screen_hook_suffix ) )
     88    public function enqueue_admin_scripts()
     89    {
     90        if (!isset($this->plugin_screen_hook_suffix))
    8791            return;
    8892
     
    9397
    9498    /***********************************
    95      * 表示オプションの表示制御
    96      * @since    1.0.0
    97      *
    98      * NOTE:  $show_screen = 1は表示オプションを表示、0は非表示
    99      ***********************************/
    100 /*
    101     public function admin_show_screen( $show_screen, $screen ){
    102         if( !isset( $screen->id ) || false === strpos( $screen->id,  $this->plugin_slug .'_management' ) )
    103             return $show_screen;
    104 
    105         if( isset($_REQUEST['action']) && '-1' != $_REQUEST['action'] ){
    106             $action = $_REQUEST['action'];
    107         }elseif( isset($_REQUEST['action2']) && '-1' != $_REQUEST['action2'] ){
    108             $action = $_REQUEST['action2'];
    109         }else{
    110             $action = 'list';
    111         }
    112 
    113         switch( $action ){
    114             case 'new' :
    115             case 'edit':
    116                 $show_screen = 0;
    117                 break;
    118             case '-1':
    119             case 'list':
    120             case 'delete':
    121             case 'delete_batch':
    122             default :
    123                 $show_screen = 1;
    124                 break;
    125         }
    126         return $show_screen;
    127     }
    128 */
    129 
    130     /***********************************
    13199     * リストの表示件数取得
    132100     * @since    1.0.0
     
    134102     * NOTE:  screen_options_show_screen にフックして、保存されたリストの表示件数を適用
    135103     ***********************************/
    136     public function admin_set_screen_options( $result, $option, $value ){
    137         $list_screens = array( self::$per_page_slug );
    138 
    139         if( in_array( $option, $list_screens ) )
     104    public function admin_set_screen_options($result, $option, $value)
     105    {
     106        $list_screens = array(self::$per_page_slug);
     107
     108        if (in_array($option, $list_screens))
    140109            $result = $value;
    141110
     
    148117     * @since    1.0.0
    149118     ***********************************/
    150     public function add_admin_menu() {
     119    public function add_admin_menu()
     120    {
    151121        $menu1_slug = $this->menu_slug['menu1'];
    152         $this->plugin_screen_hook_suffix = add_menu_page(__( 'GoQMieruca', 'gqm' ), __( 'GoQMieruca', 'gqm' ), 'activate_plugins', $menu1_slug, array( $this, 'read_plugin_page'), GOQMIERUCA_PLUGIN_URL.'/admin/assets/images/icon-goqmieruca.png', '3.5' );
    153         add_action( 'load-' . $this->plugin_screen_hook_suffix, array( $this, 'load_plugin_action' ) );
     122        $this->plugin_screen_hook_suffix = add_menu_page(__('GoQMieruca', 'gqm'), __('GoQMieruca', 'gqm'), 'activate_plugins', $menu1_slug, array($this, 'read_plugin_page'), GOQMIERUCA_PLUGIN_URL . '/admin/assets/images/icon-goqmieruca.png', '3.5');
     123        add_action('load-' . $this->plugin_screen_hook_suffix, array($this, 'load_plugin_action'));
    154124    }
    155125
     
    159129     * @since    1.0.0
    160130     ***********************************/
    161     public function load_plugin_action() {
    162         if( !isset( $this->plugin_screen_hook_suffix ) )
     131    public function load_plugin_action()
     132    {
     133        if (!isset($this->plugin_screen_hook_suffix))
    163134            return;
    164135
    165136        $current_screen = get_current_screen();
    166         if( $this->plugin_screen_hook_suffix != $current_screen->id )
    167             return;
    168 
    169         if( isset($_REQUEST['action']) && '-1' != $_REQUEST['action'] ) {
     137        if ($this->plugin_screen_hook_suffix != $current_screen->id)
     138            return;
     139
     140        if (isset($_REQUEST['action']) && '-1' != $_REQUEST['action']) {
    170141            $this->mode = $_REQUEST['action'];
    171         } elseif( isset($_REQUEST['action2']) && '-1' != $_REQUEST['action2'] ) {
     142        } elseif (isset($_REQUEST['action2']) && '-1' != $_REQUEST['action2']) {
    172143            $this->mode = $_REQUEST['action2'];
    173144        } else {
     
    176147
    177148        //set_action
    178         if( isset($_SESSION[$this->plugin_slug]['action_status']) && isset($_SESSION[$this->plugin_slug]['action_message']) ){
     149        if (isset($_SESSION[$this->plugin_slug]['action_status']) && isset($_SESSION[$this->plugin_slug]['action_message'])) {
    179150            $action_status = $_SESSION[$this->plugin_slug]['action_status'];
    180151            $action_message = $_SESSION[$this->plugin_slug]['action_message'];
    181152
    182             $this->set_action_status($action_status, $action_message );
    183         }
    184 
    185         switch( $this->mode ) {
    186         case 'up':
    187             if( isset($_POST['gqm_save']) ){
    188                 check_admin_referer( 'gqm_setting', 'gqm_nonce' );
    189 
    190                 $this->error_message = array();
    191 
    192                 $sitecode = isset($_POST['sitecode']) ? $_POST['sitecode']: '';
    193 
    194 /*
    195                 if( strlen($ref_url) == 0 ){
    196                     $this->error_message[] = __('Javascriptが未入力です。', 'gqm');
     153            $this->set_action_status($action_status, $action_message);
     154        }
     155
     156        switch ($this->mode) {
     157            case 'up':
     158                if (isset($_POST['gqm_save'])) {
     159                    check_admin_referer('gqm_setting', 'gqm_nonce');
     160
     161                    $this->error_message = array();
     162
     163                    $sitecode = isset($_POST['sitecode']) ? $_POST['sitecode'] : '';
     164
     165                    if (array() == $this->error_message) {
     166                        $gqm_system_setting = array(
     167                            'sitecode' => $sitecode
     168                        );
     169
     170                        $res = update_option('gqm_system_setting', $gqm_system_setting);
     171
     172                        if ($res) {
     173                            $this->set_action_status('success', __('保存が完了しました。', 'gqm'));
     174                        } else {
     175                            $this->set_action_status('error', __('保存に失敗しました。', 'gqm'));
     176                        }
     177                    } else {
     178                        $this->set_action_status('error', __('保存に失敗しました。', 'gqm'));
     179                    }
    197180                }
    198 */
    199 
    200                 if( array() == $this->error_message ){
    201                     $gqm_system_setting = array(
    202                                                 'sitecode' => $sitecode
    203                                             );
    204 
    205                     $res = update_option('gqm_system_setting', $gqm_system_setting);
    206 
    207                     if ( $res ) {
    208                         $this->set_action_status('success', __('保存が完了しました。','gqm'));
    209 
    210                     }else{
    211                         $this->set_action_status('error', __('保存に失敗しました。','gqm'));
    212                     }
    213                 }else{
    214                     $this->set_action_status('error', __('保存に失敗しました。','gqm'));
    215                 }
    216             }
    217             $this->page = 'system-setting';
    218             break;
    219         case 'view':
    220         default:
    221             $this->page = 'system-setting';
    222             break;
     181                $this->page = 'system-setting';
     182                break;
     183            case 'view':
     184            default:
     185                $this->page = 'system-setting';
     186                break;
    223187        }
    224188    }
     
    229193     * @since    1.0.0
    230194     ***********************************/
    231     public function read_plugin_page() {
    232         if( !isset( $this->plugin_screen_hook_suffix ) )
     195    public function read_plugin_page()
     196    {
     197        if (!isset($this->plugin_screen_hook_suffix))
    233198            return;
    234199
    235200        $screen = get_current_screen();
    236         if( $this->plugin_screen_hook_suffix != $screen->id )
    237             return;
    238 
    239         if( !empty($this->page) ) {
    240             if( $this->page == 'system-setting' ) {
     201        if ($this->plugin_screen_hook_suffix != $screen->id)
     202            return;
     203
     204        if (!empty($this->page)) {
     205            if ($this->page == 'system-setting') {
    241206                $status = $this->action_status;
    242207                $message = $this->action_message;
     
    246211
    247212                $gqm_system_setting = get_option('gqm_system_setting');
    248             }else{
     213            } else {
    249214                $status = $this->action_status;
    250215                $message = $this->action_message;
     
    253218                $this->error_message = array();
    254219            }
    255             require_once( GOQMIERUCA_PLUGIN_DIR.'/admin/views/'.$this->page.'.php' );
    256         }
    257     }
    258 
    259     public function error_message_e($error_message){
    260         $res ='';
    261         if(!empty($error_message)){
     220            require_once(GOQMIERUCA_PLUGIN_DIR . '/admin/views/' . $this->page . '.php');
     221        }
     222    }
     223
     224    public function error_message_e($error_message)
     225    {
     226        $res = '';
     227        if (!empty($error_message)) {
    262228            $res = '<ul class="error_message_list">';
    263             foreach($error_message as $mes){
    264                 $res .= '<li>'.esc_html($mes).'</li>';
     229            foreach ($error_message as $mes) {
     230                $res .= '<li>' . esc_html($mes) . '</li>';
    265231            }
    266232            $res .= '</ul>';
     
    268234        echo $res;
    269235    }
    270    
    271     public function admin_page_scripts() {
    272         if( !isset( $this->plugin_screen_hook_suffix ) )
     236
     237    public function admin_page_scripts()
     238    {
     239        if (!isset($this->plugin_screen_hook_suffix))
    273240            return;
    274241
    275242        $screen = get_current_screen();
    276         if( $this->plugin_screen_hook_suffix != $screen->id )
     243        if ($this->plugin_screen_hook_suffix != $screen->id)
    277244            return;
    278245
    279246        ob_start();
    280247?>
    281 <script type="text/javascript">
    282 jQuery(function($){
    283 <?php if('system-setting' === $this->page) : ?>
    284 
    285 
    286 
    287 <?php endif; ?>
    288 });
    289 </script>
     248        <script type="text/javascript">
     249            jQuery(function($) {
     250                <?php if ('system-setting' === $this->page) : ?>
     251
     252
     253
     254                <?php endif; ?>
     255            });
     256        </script>
    290257<?php
    291258        $html = ob_get_contents();
     
    293260        echo $html;
    294261    }
    295 
    296262}
  • goqmieruca/tags/1.0.2/admin/class-goqmieruca-admin.php

    r1935300 r3355671  
    11<?php
    2 class GOQMIERUCA_Admin {
     2class GOQMIERUCA_Admin
     3{
    34    protected static $instance = null;
    45
     
    67    protected $submenu_slug = array();
    78
    8     private function __construct() {
     9    private function __construct()
     10    {
    911        $plugin = GOQMIERUCA::get_instance();
    1012        $this->plugin_slug = $plugin->get_plugin_slug();
     
    1315        $this->menu_slug['menu1'] = $this->plugin_slug . '_management';
    1416        $this->submenu_slug['menu1']['sub1'] = $this->plugin_slug . '_setting';
    15         //$this->submenu_slug['menu1']['sub2'] = $this->plugin_slug . '_list';
    1617    }
    1718
    18     public static function get_instance() {
     19    public static function get_instance()
     20    {
    1921
    20         if ( null == self::$instance ) {
     22        if (null == self::$instance) {
    2123            self::$instance = new self;
    2224        }
     
    2527    }
    2628
    27     public function get_toplevel_menu_slug() {
     29    public function get_toplevel_menu_slug()
     30    {
    2831        return $this->menu_slug;
    2932    }
    3033
    31     public function get_submenu_slug(){
     34    public function get_submenu_slug()
     35    {
    3236        return $this->submenu_slug;
    3337    }
  • goqmieruca/tags/1.0.2/class-goqmieruca.php

    r1935300 r3355671  
    11<?php
    2 class GOQMIERUCA {
     2class GOQMIERUCA
     3{
    34    protected $plugin_slug = 'goqmieruca';
    45
    56    protected static $instance = null;
    67
    7     private function __construct() {
    8         add_action('wp_print_styles', array($this, 'wp_print_styles') );
    9         add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts') );
    10         add_action('wp_print_scripts', array($this, 'wp_print_scripts') );
    11     //  add_action('wp_print_footer_scripts', array($this, 'print_footer_scripts') );
     8    private function __construct()
     9    {
     10        add_action('wp_print_styles', array($this, 'wp_print_styles'));
     11        add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'));
     12        add_action('wp_print_scripts', array($this, 'wp_print_scripts'));
    1213    }
    13  
    14     public static function get_instance() {
    15         if ( null == self::$instance ) {
     14
     15    public static function get_instance()
     16    {
     17        if (null == self::$instance) {
    1618            self::$instance = new self;
    1719        }
     
    1921    }
    2022
    21     public function get_plugin_slug() {
     23    public function get_plugin_slug()
     24    {
    2225        return $this->plugin_slug;
    2326    }
    2427
    25     public static function load_textdomain(){
     28    public static function load_textdomain() {}
    2629
    27     }
     30    public static function activate($network_wide)
     31    {
     32        if (function_exists('is_multisite') && is_multisite()) {
     33            if ($network_wide) {
     34                $blog_ids = self::get_blog_ids();
     35                foreach ($blog_ids as $blog_id) {
    2836
    29     public static function activate( $network_wide ) {
    30         if ( function_exists( 'is_multisite' ) && is_multisite() ) {
    31             if ( $network_wide  ) {
    32                 $blog_ids = self::get_blog_ids();
    33                 foreach ( $blog_ids as $blog_id ) {
    34 
    35                     switch_to_blog( $blog_id );
     37                    switch_to_blog($blog_id);
    3638                    self::single_activate();
    3739
     
    4648    }
    4749
    48     public static function deactivate( $network_wide ) {
    49         if ( function_exists( 'is_multisite' ) && is_multisite() ) {
    50             if ( $network_wide ) {
     50    public static function deactivate($network_wide)
     51    {
     52        if (function_exists('is_multisite') && is_multisite()) {
     53            if ($network_wide) {
    5154                $blog_ids = self::get_blog_ids();
    52                 foreach ( $blog_ids as $blog_id ) {
    53                     switch_to_blog( $blog_id );
     55                foreach ($blog_ids as $blog_id) {
     56                    switch_to_blog($blog_id);
    5457                    self::single_deactivate();
    5558                    restore_current_blog();
     
    6366    }
    6467
    65     public function activate_new_site( $blog_id ) {
    66         if ( 1 !== did_action( 'wpmu_new_blog' ) ) {
     68    public function activate_new_site($blog_id)
     69    {
     70        if (1 !== did_action('wpmu_new_blog')) {
    6771            return;
    6872        }
    69         switch_to_blog( $blog_id );
     73        switch_to_blog($blog_id);
    7074        self::single_activate();
    7175        restore_current_blog();
    7276    }
    7377
    74     private static function get_blog_ids() {
     78    private static function get_blog_ids()
     79    {
    7580        global $wpdb;
    7681
     
    7984            AND deleted = '0'";
    8085
    81         return $wpdb->get_col( $sql );
     86        return $wpdb->get_col($sql);
    8287    }
    8388
    8489
    85     private static function single_activate() {
     90    private static function single_activate()
     91    {
    8692        $old = get_option('gqm_system_setting');
    87         $new['sitecode'] = isset($old['sitecode']) ? $old['sitecode']: '';
    88        
     93        $new['sitecode'] = isset($old['sitecode']) ? $old['sitecode'] : '';
     94
    8995        $res = update_option('gqm_system_setting', $new);
    9096    }
    9197
    92     private static function single_deactivate() {
    93     }
     98    private static function single_deactivate() {}
    9499
    95     function wp_print_styles(){
     100    function wp_print_styles() {}
    96101
    97     }
    98 
    99     function enqueue_scripts(){
     102    function enqueue_scripts()
     103    {
    100104        //wp_enqueue_style( 'cs-css', GOQMIERUCA_PLUGIN_URL.'/common/css/custom.css' );
    101105    }
    102106
    103     function wp_print_scripts(){
    104        
    105     }
     107    function wp_print_scripts() {}
    106108}
  • goqmieruca/tags/1.0.2/front/class-goqmieruca-front.php

    r2369125 r3355671  
    11<?php
    2 class GOQMIERUCA_Front {
     2class GOQMIERUCA_Front
     3{
    34    protected static $instance = null;
    45
    5     private function __construct() {
     6    private function __construct()
     7    {
    68        $plugin = GOQMIERUCA::get_instance();
    79        $this->plugin_slug = $plugin->get_plugin_slug();
    810        $this->gqm_system_setting = get_option('gqm_system_setting');
    911
    10         add_action('wp_print_styles', array($this, 'wp_print_styles') );
    11         add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts') );
    12         add_action('wp_print_scripts', array($this, 'wp_print_scripts') );
    13         add_action('wp_print_footer_scripts', array($this, 'print_footer_scripts'), 99 );
     12        add_action('wp_print_styles', array($this, 'wp_print_styles'));
     13        add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'));
     14        add_action('wp_print_scripts', array($this, 'wp_print_scripts'));
     15        add_action('wp_print_footer_scripts', array($this, 'print_footer_scripts'), 99);
    1416    }
    15  
    16     public static function get_instance() {
    17         if ( null == self::$instance ) {
     17
     18    public static function get_instance()
     19    {
     20        if (null == self::$instance) {
    1821            self::$instance = new self;
    1922        }
     
    2225
    2326
    24     function wp_print_styles(){
     27    function wp_print_styles() {}
    2528
    26     }
    27 
    28     function enqueue_scripts(){
     29    function enqueue_scripts()
     30    {
    2931        //wp_enqueue_style( 'front-css', GOQMIERUCA_PLUGIN_URL.'/front/assets/css/front.css' );
    3032    }
    3133
    32     function wp_print_scripts(){
     34    function wp_print_scripts() {}
    3335
    34     }
    35 
    36     function print_footer_scripts(){
     36    function print_footer_scripts()
     37    {
    3738        if ($this->gqm_system_setting['sitecode']) {
    3839?>
    39         <script>
    40         (function(){
    41             var w=window,d=document;
    42             var s="https://log.goq.jp/?ma=<?php echo esc_html($this->gqm_system_setting['sitecode']); ?>";
    43             var a =d.createElement("script"), m=d.getElementsByTagName("script")[0];
    44             a.async=true,a.src=s,m.parentNode.insertBefore(a,m);
    45         })();
    46         </script>
     40            <script>
     41                (function() {
     42                    var w = window,
     43                        d = document;
     44                    var s = "https://log.goq.jp/?ma=<?php echo esc_html($this->gqm_system_setting['sitecode']); ?>";
     45                    var a = d.createElement("script"),
     46                        m = d.getElementsByTagName("script")[0];
     47                    a.async = true, a.src = s, m.parentNode.insertBefore(a, m);
     48                })();
     49            </script>
    4750<?php
    4851        }
    4952    }
    50 
    51    
    5253}
  • goqmieruca/tags/1.0.2/goqmieruca.php

    r2369126 r3355671  
    1010*/
    1111
    12 define( 'GOQMIERUCA_VERSION', "1.0.1");
    13 define( 'GOQMIERUCA_SLUG', 'goqmieruca' );
    14 define( 'GOQMIERUCA_PLUGIN_DIR', WP_PLUGIN_DIR . '/' . plugin_basename(dirname(__FILE__)) );
    15 define( 'GOQMIERUCA_PLUGIN_URL', WP_PLUGIN_URL . '/' . plugin_basename(dirname(__FILE__)) );
    16 define( 'GOQMIERUCA_PLUGIN_FOLDER', dirname(plugin_basename(__FILE__)) );
    17 define( 'GOQMIERUCA_PLUGIN_BASENAME', plugin_basename(__FILE__) );
     12define('GOQMIERUCA_VERSION', "1.0.1");
     13define('GOQMIERUCA_SLUG', 'goqmieruca');
     14define('GOQMIERUCA_PLUGIN_DIR', WP_PLUGIN_DIR . '/' . plugin_basename(dirname(__FILE__)));
     15define('GOQMIERUCA_PLUGIN_URL', WP_PLUGIN_URL . '/' . plugin_basename(dirname(__FILE__)));
     16define('GOQMIERUCA_PLUGIN_FOLDER', dirname(plugin_basename(__FILE__)));
     17define('GOQMIERUCA_PLUGIN_BASENAME', plugin_basename(__FILE__));
    1818
    19 require_once( GOQMIERUCA_PLUGIN_DIR . '/class-goqmieruca.php' );
    20 require_once( GOQMIERUCA_PLUGIN_DIR . '/common/function.php' );
     19require_once(GOQMIERUCA_PLUGIN_DIR . '/class-goqmieruca.php');
     20require_once(GOQMIERUCA_PLUGIN_DIR . '/common/function.php');
    2121
    2222GOQMIERUCA::load_textdomain();
    2323
    24 register_activation_hook( __FILE__, array( 'GOQMIERUCA', 'activate' ) );
    25 register_deactivation_hook( __FILE__, array( 'GOQMIERUCA', 'deactivate' ) );
     24register_activation_hook(__FILE__, array('GOQMIERUCA', 'activate'));
     25register_deactivation_hook(__FILE__, array('GOQMIERUCA', 'deactivate'));
    2626
    27 add_action( 'plugins_loaded', array('GOQMIERUCA', 'get_instance') );
     27add_action('plugins_loaded', array('GOQMIERUCA', 'get_instance'));
    2828
    29 if( is_admin() ){
    30     require_once( GOQMIERUCA_PLUGIN_DIR . '/admin/class-goqmieruca-admin.php' );
     29if (is_admin()) {
     30    require_once(GOQMIERUCA_PLUGIN_DIR . '/admin/class-goqmieruca-admin.php');
    3131    add_action('plugins_loaded', array('GOQMIERUCA_Admin', 'get_instance'));
    3232
    33     require_once( GOQMIERUCA_PLUGIN_DIR . '/admin/class-admin-page.php' );
     33    require_once(GOQMIERUCA_PLUGIN_DIR . '/admin/class-admin-page.php');
    3434
    35     require_once( GOQMIERUCA_PLUGIN_DIR . '/admin/class-admin-setting.php' );
     35    require_once(GOQMIERUCA_PLUGIN_DIR . '/admin/class-admin-setting.php');
    3636    add_action('plugins_loaded', array('GOQMIERUCA_Setting', 'get_instance'));
    37 
    38 }else{
    39     require_once( GOQMIERUCA_PLUGIN_DIR . '/front/class-goqmieruca-front.php' );
     37} else {
     38    require_once(GOQMIERUCA_PLUGIN_DIR . '/front/class-goqmieruca-front.php');
    4039    add_action('plugins_loaded', array('GOQMIERUCA_Front', 'get_instance'));
    41 
    4240}
  • goqmieruca/trunk/admin/class-admin-page.php

    r1935300 r3355671  
    11<?php
    2 class GOQMIERUCA_Admin_Page {
     2class GOQMIERUCA_Admin_Page
     3{
    34    public $action_status, $action_message;
    45    public $error_message = array();
     
    910    protected $plugin_screen_hook_suffix = null;
    1011
    11     public function __construct() {
     12    public function __construct()
     13    {
    1214        $plugin = GOQMIERUCA::get_instance();
    1315        $this->plugin_slug = $plugin->get_plugin_slug();
     
    1517        $this->menu_slug = $admin->get_toplevel_menu_slug();
    1618        $this->submenu_slug = $admin->get_submenu_slug();
    17 //      $this->clear_action_status();
    1819        /*******************************************/
    1920
    20         add_action( 'admin_head', array( $this, 'add_admin_head' ) );
     21        add_action('admin_head', array($this, 'add_admin_head'));
    2122
    2223        // Load admin style sheet and JavaScript.
    23         add_action( 'admin_print_styles', array( $this, 'enqueue_admin_styles' ) );
    24         add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
     24        add_action('admin_print_styles', array($this, 'enqueue_admin_styles'));
     25        add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'));
    2526
    2627        // Add the options page and menu item.
    27         add_action( 'admin_menu', array( $this, 'add_admin_menu' ) );
     28        add_action('admin_menu', array($this, 'add_admin_menu'));
    2829
    2930        //スクリーン自体の表示・非表示
    30         add_filter( 'screen_options_show_screen', array( $this, 'admin_show_screen' ), 10, 2 );
     31        add_filter('screen_options_show_screen', array($this, 'admin_show_screen'), 10, 2);
    3132
    3233        //スクリーンの表示件数取得
    33         add_filter( 'set-screen-option', array( $this, 'admin_set_screen_options' ), 10, 3 );
     34        add_filter('set-screen-option', array($this, 'admin_set_screen_options'), 10, 3);
    3435
    35         add_filter( 'contextual_help', array( $this, 'admin_help_setting' ), 900, 3 );
    36         add_action( 'admin_print_footer_scripts', array( $this, 'admin_scripts' ) );
    37         add_action( 'admin_print_footer_scripts', array( $this, 'admin_page_scripts' ) );
    38         add_action( 'admin_footer', array( $this, 'clear_action_status' ) );
     36        add_filter('contextual_help', array($this, 'admin_help_setting'), 900, 3);
     37        add_action('admin_print_footer_scripts', array($this, 'admin_scripts'));
     38        add_action('admin_print_footer_scripts', array($this, 'admin_page_scripts'));
     39        add_action('admin_footer', array($this, 'clear_action_status'));
    3940    }
    4041
     
    5152     * @since     1.0.0
    5253     ***********************************/
    53     public function admin_help_setting( $help, $screen_id, $screen ) {
    54 
    55     }
     54    public function admin_help_setting($help, $screen_id, $screen) {}
    5655
    5756    /***********************************
     
    6059     * @since     1.0.0
    6160     ***********************************/
    62     public function add_admin_head() {
    63         //if( $this->action_status == 'edit' || $this->action_status == 'editpost' ) {
    64     //      add_thickbox();
    65         //}
     61    public function add_admin_head()
     62    {
    6663    }
    6764
     
    7168     * @since     1.0.0
    7269     ***********************************/
    73     public function enqueue_admin_styles() {
    74         if( !isset( $this->plugin_screen_hook_suffix ) )
     70    public function enqueue_admin_styles()
     71    {
     72        if (!isset($this->plugin_screen_hook_suffix))
    7573            return;
    7674
     
    7876        $screen = get_current_screen();
    7977
    80         if( $this->plugin_screen_hook_suffix == $screen->id ) {
    81             wp_enqueue_style( $this->plugin_slug .'-admin-styles', GOQMIERUCA_PLUGIN_URL.'/admin/assets/css/admin.css', array(), GOQMIERUCA_VERSION );
     78        if ($this->plugin_screen_hook_suffix == $screen->id) {
     79            wp_enqueue_style($this->plugin_slug . '-admin-styles', GOQMIERUCA_PLUGIN_URL . '/admin/assets/css/admin.css', array(), GOQMIERUCA_VERSION);
    8280
    83             $ui = $wp_scripts->query( 'jquery-ui-core' );
    84             $url = "//ajax.googleapis.com/ajax/libs/jqueryui/{$ui->ver}/themes/redmond/jquery-ui.min.css";
    85             wp_enqueue_style( 'jquery-ui-redmond', $url, false, null );
     81            $ui = $wp_scripts->query('jquery-ui-core');
     82            $url = "//ajax.googleapis.com/ajax/libs/jqueryui/{$ui->ver}/themes/redmond/jquery-ui.min.css";
     83            wp_enqueue_style('jquery-ui-redmond', $url, false, null);
    8684
    87             $url = "//fonts.googleapis.com/earlyaccess/notosansjapanese.css";
    88             wp_enqueue_style( 'notosansjapanese', $url, false, null );
     85            $url = "//fonts.googleapis.com/earlyaccess/notosansjapanese.css";
     86            wp_enqueue_style('notosansjapanese', $url, false, null);
    8987        }
    9088    }
     
    9593     * @since     1.0.0
    9694     ***********************************/
    97     public function enqueue_admin_scripts() {
    98         if( !isset( $this->plugin_screen_hook_suffix ) )
     95    public function enqueue_admin_scripts()
     96    {
     97        if (!isset($this->plugin_screen_hook_suffix))
    9998            return;
    10099
    101100        $screen = get_current_screen();
    102101
    103         if( $this->plugin_screen_hook_suffix == $screen->id ) {
    104             wp_enqueue_script( 'jquery-color' );
    105             wp_enqueue_script( 'jquery-ui-tabs' );
    106             wp_enqueue_script( 'jquery-ui-dialog' );
     102        if ($this->plugin_screen_hook_suffix == $screen->id) {
     103            wp_enqueue_script('jquery-color');
     104            wp_enqueue_script('jquery-ui-tabs');
     105            wp_enqueue_script('jquery-ui-dialog');
    107106        }
    108107    }
     
    114113     * NOTE:  $show_screen = 1は表示オプションを表示、0は非表示
    115114     ***********************************/
    116     public function admin_show_screen( $show_screen, $screen ) {
     115    public function admin_show_screen($show_screen, $screen)
     116    {
    117117        return $show_screen;
    118118    }
     
    124124     * NOTE:  screen_options_show_screen にフックして、保存されたリストの表示件数を適用
    125125     ***********************************/
    126     public function admin_set_screen_options( $result, $option, $value ) {
    127 //      $screens = array( self::$per_page_slug );
    128 //      if( in_array( $option, $screens ) )
    129 //          $result = $value;
    130 //
     126    public function admin_set_screen_options($result, $option, $value)
     127    {
    131128        return $result;
    132129    }
     
    137134     * @since    1.0.0
    138135     ***********************************/
    139     public function add_admin_menu() {
    140 
    141     }
     136    public function add_admin_menu() {}
    142137
    143138    /***********************************
     
    146141     * @since    1.0.0
    147142     ***********************************/
    148     public function set_action_status( $status, $message ) {
     143    public function set_action_status($status, $message)
     144    {
    149145        $this->action_status = $status;
    150146        $this->action_message = $message;
     
    158154     * @since    1.0.0
    159155     ***********************************/
    160     public function clear_action_status() {
     156    public function clear_action_status()
     157    {
    161158        $this->action_status = 'none';
    162159        $this->action_message = '';
     
    170167     * @since    1.0.0
    171168     *******************************/
    172     public function admin_scripts() {
    173         if( !isset( $this->plugin_screen_hook_suffix ) )
     169    public function admin_scripts()
     170    {
     171        if (!isset($this->plugin_screen_hook_suffix))
    174172            return;
    175173
    176174        $screen = get_current_screen();
    177         if( $this->plugin_screen_hook_suffix != $screen->id )
     175        if ($this->plugin_screen_hook_suffix != $screen->id)
    178176            return;
    179177?>
    180 <script type="text/javascript">
     178        <script type="text/javascript">
    181179
    182 </script>
     180        </script>
    183181<?php
    184182    }
     
    189187     * @since    1.0.0
    190188     *******************************/
    191     public function admin_page_scripts() {
    192 
    193     }
     189    public function admin_page_scripts() {}
    194190}
  • goqmieruca/trunk/admin/class-admin-setting.php

    r1935300 r3355671  
    11<?php
    2 class GOQMIERUCA_Setting extends GOQMIERUCA_Admin_Page {
     2class GOQMIERUCA_Setting extends GOQMIERUCA_Admin_Page
     3{
    34
    45    protected static $instance = null;
     
    2627     * @since     1.0.0
    2728     ***********************************/
    28     public function __construct() {
     29    public function __construct()
     30    {
    2931        parent::__construct();
    3032    }
     
    3739     * @return    object    A single instance of this class.
    3840     ***********************************/
    39     public static function get_instance() {
    40         if ( null == self::$instance ) {
     41    public static function get_instance()
     42    {
     43        if (null == self::$instance) {
    4144            self::$instance = new self;
    4245        }
     
    5053     * @since     1.0.0
    5154     ***********************************/
    52     protected function init() {
     55    protected function init()
     56    {
    5357        $this->title = '';
    5458    }
     
    5963     * @since     1.0.0
    6064     ***********************************/
    61     public function admin_help_setting( $help, $screen_id, $screen ) {
    62     }
     65    public function admin_help_setting($help, $screen_id, $screen) {}
    6366
    6467    /***********************************
     
    6770     * @since     1.0.0
    6871     ***********************************/
    69     public function enqueue_admin_styles() {
    70         if( !isset( $this->plugin_screen_hook_suffix ) )
     72    public function enqueue_admin_styles()
     73    {
     74        if (!isset($this->plugin_screen_hook_suffix))
    7175            return;
    7276
    7377        parent::enqueue_admin_styles();
    7478        $screen = get_current_screen();
    75         if ( $this->plugin_screen_hook_suffix == $screen->id ) {
    76             //wp_enqueue_style( $this->plugin_slug .'_admin_coupon_styles', plugins_url( 'assets/css/admin-setting.css', __FILE__ ), array(), GOQMIERUCA_VERSION );
     79        if ($this->plugin_screen_hook_suffix == $screen->id) {
    7780        }
    7881    }
     
    8386     * @since     1.0.0
    8487     ***********************************/
    85     public function enqueue_admin_scripts() {
    86         if( !isset( $this->plugin_screen_hook_suffix ) )
     88    public function enqueue_admin_scripts()
     89    {
     90        if (!isset($this->plugin_screen_hook_suffix))
    8791            return;
    8892
     
    9397
    9498    /***********************************
    95      * 表示オプションの表示制御
    96      * @since    1.0.0
    97      *
    98      * NOTE:  $show_screen = 1は表示オプションを表示、0は非表示
    99      ***********************************/
    100 /*
    101     public function admin_show_screen( $show_screen, $screen ){
    102         if( !isset( $screen->id ) || false === strpos( $screen->id,  $this->plugin_slug .'_management' ) )
    103             return $show_screen;
    104 
    105         if( isset($_REQUEST['action']) && '-1' != $_REQUEST['action'] ){
    106             $action = $_REQUEST['action'];
    107         }elseif( isset($_REQUEST['action2']) && '-1' != $_REQUEST['action2'] ){
    108             $action = $_REQUEST['action2'];
    109         }else{
    110             $action = 'list';
    111         }
    112 
    113         switch( $action ){
    114             case 'new' :
    115             case 'edit':
    116                 $show_screen = 0;
    117                 break;
    118             case '-1':
    119             case 'list':
    120             case 'delete':
    121             case 'delete_batch':
    122             default :
    123                 $show_screen = 1;
    124                 break;
    125         }
    126         return $show_screen;
    127     }
    128 */
    129 
    130     /***********************************
    13199     * リストの表示件数取得
    132100     * @since    1.0.0
     
    134102     * NOTE:  screen_options_show_screen にフックして、保存されたリストの表示件数を適用
    135103     ***********************************/
    136     public function admin_set_screen_options( $result, $option, $value ){
    137         $list_screens = array( self::$per_page_slug );
    138 
    139         if( in_array( $option, $list_screens ) )
     104    public function admin_set_screen_options($result, $option, $value)
     105    {
     106        $list_screens = array(self::$per_page_slug);
     107
     108        if (in_array($option, $list_screens))
    140109            $result = $value;
    141110
     
    148117     * @since    1.0.0
    149118     ***********************************/
    150     public function add_admin_menu() {
     119    public function add_admin_menu()
     120    {
    151121        $menu1_slug = $this->menu_slug['menu1'];
    152         $this->plugin_screen_hook_suffix = add_menu_page(__( 'GoQMieruca', 'gqm' ), __( 'GoQMieruca', 'gqm' ), 'activate_plugins', $menu1_slug, array( $this, 'read_plugin_page'), GOQMIERUCA_PLUGIN_URL.'/admin/assets/images/icon-goqmieruca.png', '3.5' );
    153         add_action( 'load-' . $this->plugin_screen_hook_suffix, array( $this, 'load_plugin_action' ) );
     122        $this->plugin_screen_hook_suffix = add_menu_page(__('GoQMieruca', 'gqm'), __('GoQMieruca', 'gqm'), 'activate_plugins', $menu1_slug, array($this, 'read_plugin_page'), GOQMIERUCA_PLUGIN_URL . '/admin/assets/images/icon-goqmieruca.png', '3.5');
     123        add_action('load-' . $this->plugin_screen_hook_suffix, array($this, 'load_plugin_action'));
    154124    }
    155125
     
    159129     * @since    1.0.0
    160130     ***********************************/
    161     public function load_plugin_action() {
    162         if( !isset( $this->plugin_screen_hook_suffix ) )
     131    public function load_plugin_action()
     132    {
     133        if (!isset($this->plugin_screen_hook_suffix))
    163134            return;
    164135
    165136        $current_screen = get_current_screen();
    166         if( $this->plugin_screen_hook_suffix != $current_screen->id )
    167             return;
    168 
    169         if( isset($_REQUEST['action']) && '-1' != $_REQUEST['action'] ) {
     137        if ($this->plugin_screen_hook_suffix != $current_screen->id)
     138            return;
     139
     140        if (isset($_REQUEST['action']) && '-1' != $_REQUEST['action']) {
    170141            $this->mode = $_REQUEST['action'];
    171         } elseif( isset($_REQUEST['action2']) && '-1' != $_REQUEST['action2'] ) {
     142        } elseif (isset($_REQUEST['action2']) && '-1' != $_REQUEST['action2']) {
    172143            $this->mode = $_REQUEST['action2'];
    173144        } else {
     
    176147
    177148        //set_action
    178         if( isset($_SESSION[$this->plugin_slug]['action_status']) && isset($_SESSION[$this->plugin_slug]['action_message']) ){
     149        if (isset($_SESSION[$this->plugin_slug]['action_status']) && isset($_SESSION[$this->plugin_slug]['action_message'])) {
    179150            $action_status = $_SESSION[$this->plugin_slug]['action_status'];
    180151            $action_message = $_SESSION[$this->plugin_slug]['action_message'];
    181152
    182             $this->set_action_status($action_status, $action_message );
    183         }
    184 
    185         switch( $this->mode ) {
    186         case 'up':
    187             if( isset($_POST['gqm_save']) ){
    188                 check_admin_referer( 'gqm_setting', 'gqm_nonce' );
    189 
    190                 $this->error_message = array();
    191 
    192                 $sitecode = isset($_POST['sitecode']) ? $_POST['sitecode']: '';
    193 
    194 /*
    195                 if( strlen($ref_url) == 0 ){
    196                     $this->error_message[] = __('Javascriptが未入力です。', 'gqm');
     153            $this->set_action_status($action_status, $action_message);
     154        }
     155
     156        switch ($this->mode) {
     157            case 'up':
     158                if (isset($_POST['gqm_save'])) {
     159                    check_admin_referer('gqm_setting', 'gqm_nonce');
     160
     161                    $this->error_message = array();
     162
     163                    $sitecode = isset($_POST['sitecode']) ? $_POST['sitecode'] : '';
     164
     165                    if (array() == $this->error_message) {
     166                        $gqm_system_setting = array(
     167                            'sitecode' => $sitecode
     168                        );
     169
     170                        $res = update_option('gqm_system_setting', $gqm_system_setting);
     171
     172                        if ($res) {
     173                            $this->set_action_status('success', __('保存が完了しました。', 'gqm'));
     174                        } else {
     175                            $this->set_action_status('error', __('保存に失敗しました。', 'gqm'));
     176                        }
     177                    } else {
     178                        $this->set_action_status('error', __('保存に失敗しました。', 'gqm'));
     179                    }
    197180                }
    198 */
    199 
    200                 if( array() == $this->error_message ){
    201                     $gqm_system_setting = array(
    202                                                 'sitecode' => $sitecode
    203                                             );
    204 
    205                     $res = update_option('gqm_system_setting', $gqm_system_setting);
    206 
    207                     if ( $res ) {
    208                         $this->set_action_status('success', __('保存が完了しました。','gqm'));
    209 
    210                     }else{
    211                         $this->set_action_status('error', __('保存に失敗しました。','gqm'));
    212                     }
    213                 }else{
    214                     $this->set_action_status('error', __('保存に失敗しました。','gqm'));
    215                 }
    216             }
    217             $this->page = 'system-setting';
    218             break;
    219         case 'view':
    220         default:
    221             $this->page = 'system-setting';
    222             break;
     181                $this->page = 'system-setting';
     182                break;
     183            case 'view':
     184            default:
     185                $this->page = 'system-setting';
     186                break;
    223187        }
    224188    }
     
    229193     * @since    1.0.0
    230194     ***********************************/
    231     public function read_plugin_page() {
    232         if( !isset( $this->plugin_screen_hook_suffix ) )
     195    public function read_plugin_page()
     196    {
     197        if (!isset($this->plugin_screen_hook_suffix))
    233198            return;
    234199
    235200        $screen = get_current_screen();
    236         if( $this->plugin_screen_hook_suffix != $screen->id )
    237             return;
    238 
    239         if( !empty($this->page) ) {
    240             if( $this->page == 'system-setting' ) {
     201        if ($this->plugin_screen_hook_suffix != $screen->id)
     202            return;
     203
     204        if (!empty($this->page)) {
     205            if ($this->page == 'system-setting') {
    241206                $status = $this->action_status;
    242207                $message = $this->action_message;
     
    246211
    247212                $gqm_system_setting = get_option('gqm_system_setting');
    248             }else{
     213            } else {
    249214                $status = $this->action_status;
    250215                $message = $this->action_message;
     
    253218                $this->error_message = array();
    254219            }
    255             require_once( GOQMIERUCA_PLUGIN_DIR.'/admin/views/'.$this->page.'.php' );
    256         }
    257     }
    258 
    259     public function error_message_e($error_message){
    260         $res ='';
    261         if(!empty($error_message)){
     220            require_once(GOQMIERUCA_PLUGIN_DIR . '/admin/views/' . $this->page . '.php');
     221        }
     222    }
     223
     224    public function error_message_e($error_message)
     225    {
     226        $res = '';
     227        if (!empty($error_message)) {
    262228            $res = '<ul class="error_message_list">';
    263             foreach($error_message as $mes){
    264                 $res .= '<li>'.esc_html($mes).'</li>';
     229            foreach ($error_message as $mes) {
     230                $res .= '<li>' . esc_html($mes) . '</li>';
    265231            }
    266232            $res .= '</ul>';
     
    268234        echo $res;
    269235    }
    270    
    271     public function admin_page_scripts() {
    272         if( !isset( $this->plugin_screen_hook_suffix ) )
     236
     237    public function admin_page_scripts()
     238    {
     239        if (!isset($this->plugin_screen_hook_suffix))
    273240            return;
    274241
    275242        $screen = get_current_screen();
    276         if( $this->plugin_screen_hook_suffix != $screen->id )
     243        if ($this->plugin_screen_hook_suffix != $screen->id)
    277244            return;
    278245
    279246        ob_start();
    280247?>
    281 <script type="text/javascript">
    282 jQuery(function($){
    283 <?php if('system-setting' === $this->page) : ?>
    284 
    285 
    286 
    287 <?php endif; ?>
    288 });
    289 </script>
     248        <script type="text/javascript">
     249            jQuery(function($) {
     250                <?php if ('system-setting' === $this->page) : ?>
     251
     252
     253
     254                <?php endif; ?>
     255            });
     256        </script>
    290257<?php
    291258        $html = ob_get_contents();
     
    293260        echo $html;
    294261    }
    295 
    296262}
  • goqmieruca/trunk/admin/class-goqmieruca-admin.php

    r1935300 r3355671  
    11<?php
    2 class GOQMIERUCA_Admin {
     2class GOQMIERUCA_Admin
     3{
    34    protected static $instance = null;
    45
     
    67    protected $submenu_slug = array();
    78
    8     private function __construct() {
     9    private function __construct()
     10    {
    911        $plugin = GOQMIERUCA::get_instance();
    1012        $this->plugin_slug = $plugin->get_plugin_slug();
     
    1315        $this->menu_slug['menu1'] = $this->plugin_slug . '_management';
    1416        $this->submenu_slug['menu1']['sub1'] = $this->plugin_slug . '_setting';
    15         //$this->submenu_slug['menu1']['sub2'] = $this->plugin_slug . '_list';
    1617    }
    1718
    18     public static function get_instance() {
     19    public static function get_instance()
     20    {
    1921
    20         if ( null == self::$instance ) {
     22        if (null == self::$instance) {
    2123            self::$instance = new self;
    2224        }
     
    2527    }
    2628
    27     public function get_toplevel_menu_slug() {
     29    public function get_toplevel_menu_slug()
     30    {
    2831        return $this->menu_slug;
    2932    }
    3033
    31     public function get_submenu_slug(){
     34    public function get_submenu_slug()
     35    {
    3236        return $this->submenu_slug;
    3337    }
  • goqmieruca/trunk/class-goqmieruca.php

    r1935300 r3355671  
    11<?php
    2 class GOQMIERUCA {
     2class GOQMIERUCA
     3{
    34    protected $plugin_slug = 'goqmieruca';
    45
    56    protected static $instance = null;
    67
    7     private function __construct() {
    8         add_action('wp_print_styles', array($this, 'wp_print_styles') );
    9         add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts') );
    10         add_action('wp_print_scripts', array($this, 'wp_print_scripts') );
    11     //  add_action('wp_print_footer_scripts', array($this, 'print_footer_scripts') );
     8    private function __construct()
     9    {
     10        add_action('wp_print_styles', array($this, 'wp_print_styles'));
     11        add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'));
     12        add_action('wp_print_scripts', array($this, 'wp_print_scripts'));
    1213    }
    13  
    14     public static function get_instance() {
    15         if ( null == self::$instance ) {
     14
     15    public static function get_instance()
     16    {
     17        if (null == self::$instance) {
    1618            self::$instance = new self;
    1719        }
     
    1921    }
    2022
    21     public function get_plugin_slug() {
     23    public function get_plugin_slug()
     24    {
    2225        return $this->plugin_slug;
    2326    }
    2427
    25     public static function load_textdomain(){
     28    public static function load_textdomain() {}
    2629
    27     }
     30    public static function activate($network_wide)
     31    {
     32        if (function_exists('is_multisite') && is_multisite()) {
     33            if ($network_wide) {
     34                $blog_ids = self::get_blog_ids();
     35                foreach ($blog_ids as $blog_id) {
    2836
    29     public static function activate( $network_wide ) {
    30         if ( function_exists( 'is_multisite' ) && is_multisite() ) {
    31             if ( $network_wide  ) {
    32                 $blog_ids = self::get_blog_ids();
    33                 foreach ( $blog_ids as $blog_id ) {
    34 
    35                     switch_to_blog( $blog_id );
     37                    switch_to_blog($blog_id);
    3638                    self::single_activate();
    3739
     
    4648    }
    4749
    48     public static function deactivate( $network_wide ) {
    49         if ( function_exists( 'is_multisite' ) && is_multisite() ) {
    50             if ( $network_wide ) {
     50    public static function deactivate($network_wide)
     51    {
     52        if (function_exists('is_multisite') && is_multisite()) {
     53            if ($network_wide) {
    5154                $blog_ids = self::get_blog_ids();
    52                 foreach ( $blog_ids as $blog_id ) {
    53                     switch_to_blog( $blog_id );
     55                foreach ($blog_ids as $blog_id) {
     56                    switch_to_blog($blog_id);
    5457                    self::single_deactivate();
    5558                    restore_current_blog();
     
    6366    }
    6467
    65     public function activate_new_site( $blog_id ) {
    66         if ( 1 !== did_action( 'wpmu_new_blog' ) ) {
     68    public function activate_new_site($blog_id)
     69    {
     70        if (1 !== did_action('wpmu_new_blog')) {
    6771            return;
    6872        }
    69         switch_to_blog( $blog_id );
     73        switch_to_blog($blog_id);
    7074        self::single_activate();
    7175        restore_current_blog();
    7276    }
    7377
    74     private static function get_blog_ids() {
     78    private static function get_blog_ids()
     79    {
    7580        global $wpdb;
    7681
     
    7984            AND deleted = '0'";
    8085
    81         return $wpdb->get_col( $sql );
     86        return $wpdb->get_col($sql);
    8287    }
    8388
    8489
    85     private static function single_activate() {
     90    private static function single_activate()
     91    {
    8692        $old = get_option('gqm_system_setting');
    87         $new['sitecode'] = isset($old['sitecode']) ? $old['sitecode']: '';
    88        
     93        $new['sitecode'] = isset($old['sitecode']) ? $old['sitecode'] : '';
     94
    8995        $res = update_option('gqm_system_setting', $new);
    9096    }
    9197
    92     private static function single_deactivate() {
    93     }
     98    private static function single_deactivate() {}
    9499
    95     function wp_print_styles(){
     100    function wp_print_styles() {}
    96101
    97     }
    98 
    99     function enqueue_scripts(){
     102    function enqueue_scripts()
     103    {
    100104        //wp_enqueue_style( 'cs-css', GOQMIERUCA_PLUGIN_URL.'/common/css/custom.css' );
    101105    }
    102106
    103     function wp_print_scripts(){
    104        
    105     }
     107    function wp_print_scripts() {}
    106108}
  • goqmieruca/trunk/front/class-goqmieruca-front.php

    r2369125 r3355671  
    11<?php
    2 class GOQMIERUCA_Front {
     2class GOQMIERUCA_Front
     3{
    34    protected static $instance = null;
    45
    5     private function __construct() {
     6    private function __construct()
     7    {
    68        $plugin = GOQMIERUCA::get_instance();
    79        $this->plugin_slug = $plugin->get_plugin_slug();
    810        $this->gqm_system_setting = get_option('gqm_system_setting');
    911
    10         add_action('wp_print_styles', array($this, 'wp_print_styles') );
    11         add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts') );
    12         add_action('wp_print_scripts', array($this, 'wp_print_scripts') );
    13         add_action('wp_print_footer_scripts', array($this, 'print_footer_scripts'), 99 );
     12        add_action('wp_print_styles', array($this, 'wp_print_styles'));
     13        add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'));
     14        add_action('wp_print_scripts', array($this, 'wp_print_scripts'));
     15        add_action('wp_print_footer_scripts', array($this, 'print_footer_scripts'), 99);
    1416    }
    15  
    16     public static function get_instance() {
    17         if ( null == self::$instance ) {
     17
     18    public static function get_instance()
     19    {
     20        if (null == self::$instance) {
    1821            self::$instance = new self;
    1922        }
     
    2225
    2326
    24     function wp_print_styles(){
     27    function wp_print_styles() {}
    2528
    26     }
    27 
    28     function enqueue_scripts(){
     29    function enqueue_scripts()
     30    {
    2931        //wp_enqueue_style( 'front-css', GOQMIERUCA_PLUGIN_URL.'/front/assets/css/front.css' );
    3032    }
    3133
    32     function wp_print_scripts(){
     34    function wp_print_scripts() {}
    3335
    34     }
    35 
    36     function print_footer_scripts(){
     36    function print_footer_scripts()
     37    {
    3738        if ($this->gqm_system_setting['sitecode']) {
    3839?>
    39         <script>
    40         (function(){
    41             var w=window,d=document;
    42             var s="https://log.goq.jp/?ma=<?php echo esc_html($this->gqm_system_setting['sitecode']); ?>";
    43             var a =d.createElement("script"), m=d.getElementsByTagName("script")[0];
    44             a.async=true,a.src=s,m.parentNode.insertBefore(a,m);
    45         })();
    46         </script>
     40            <script>
     41                (function() {
     42                    var w = window,
     43                        d = document;
     44                    var s = "https://log.goq.jp/?ma=<?php echo esc_html($this->gqm_system_setting['sitecode']); ?>";
     45                    var a = d.createElement("script"),
     46                        m = d.getElementsByTagName("script")[0];
     47                    a.async = true, a.src = s, m.parentNode.insertBefore(a, m);
     48                })();
     49            </script>
    4750<?php
    4851        }
    4952    }
    50 
    51    
    5253}
  • goqmieruca/trunk/goqmieruca.php

    r2369126 r3355671  
    1010*/
    1111
    12 define( 'GOQMIERUCA_VERSION', "1.0.1");
    13 define( 'GOQMIERUCA_SLUG', 'goqmieruca' );
    14 define( 'GOQMIERUCA_PLUGIN_DIR', WP_PLUGIN_DIR . '/' . plugin_basename(dirname(__FILE__)) );
    15 define( 'GOQMIERUCA_PLUGIN_URL', WP_PLUGIN_URL . '/' . plugin_basename(dirname(__FILE__)) );
    16 define( 'GOQMIERUCA_PLUGIN_FOLDER', dirname(plugin_basename(__FILE__)) );
    17 define( 'GOQMIERUCA_PLUGIN_BASENAME', plugin_basename(__FILE__) );
     12define('GOQMIERUCA_VERSION', "1.0.1");
     13define('GOQMIERUCA_SLUG', 'goqmieruca');
     14define('GOQMIERUCA_PLUGIN_DIR', WP_PLUGIN_DIR . '/' . plugin_basename(dirname(__FILE__)));
     15define('GOQMIERUCA_PLUGIN_URL', WP_PLUGIN_URL . '/' . plugin_basename(dirname(__FILE__)));
     16define('GOQMIERUCA_PLUGIN_FOLDER', dirname(plugin_basename(__FILE__)));
     17define('GOQMIERUCA_PLUGIN_BASENAME', plugin_basename(__FILE__));
    1818
    19 require_once( GOQMIERUCA_PLUGIN_DIR . '/class-goqmieruca.php' );
    20 require_once( GOQMIERUCA_PLUGIN_DIR . '/common/function.php' );
     19require_once(GOQMIERUCA_PLUGIN_DIR . '/class-goqmieruca.php');
     20require_once(GOQMIERUCA_PLUGIN_DIR . '/common/function.php');
    2121
    2222GOQMIERUCA::load_textdomain();
    2323
    24 register_activation_hook( __FILE__, array( 'GOQMIERUCA', 'activate' ) );
    25 register_deactivation_hook( __FILE__, array( 'GOQMIERUCA', 'deactivate' ) );
     24register_activation_hook(__FILE__, array('GOQMIERUCA', 'activate'));
     25register_deactivation_hook(__FILE__, array('GOQMIERUCA', 'deactivate'));
    2626
    27 add_action( 'plugins_loaded', array('GOQMIERUCA', 'get_instance') );
     27add_action('plugins_loaded', array('GOQMIERUCA', 'get_instance'));
    2828
    29 if( is_admin() ){
    30     require_once( GOQMIERUCA_PLUGIN_DIR . '/admin/class-goqmieruca-admin.php' );
     29if (is_admin()) {
     30    require_once(GOQMIERUCA_PLUGIN_DIR . '/admin/class-goqmieruca-admin.php');
    3131    add_action('plugins_loaded', array('GOQMIERUCA_Admin', 'get_instance'));
    3232
    33     require_once( GOQMIERUCA_PLUGIN_DIR . '/admin/class-admin-page.php' );
     33    require_once(GOQMIERUCA_PLUGIN_DIR . '/admin/class-admin-page.php');
    3434
    35     require_once( GOQMIERUCA_PLUGIN_DIR . '/admin/class-admin-setting.php' );
     35    require_once(GOQMIERUCA_PLUGIN_DIR . '/admin/class-admin-setting.php');
    3636    add_action('plugins_loaded', array('GOQMIERUCA_Setting', 'get_instance'));
    37 
    38 }else{
    39     require_once( GOQMIERUCA_PLUGIN_DIR . '/front/class-goqmieruca-front.php' );
     37} else {
     38    require_once(GOQMIERUCA_PLUGIN_DIR . '/front/class-goqmieruca-front.php');
    4039    add_action('plugins_loaded', array('GOQMIERUCA_Front', 'get_instance'));
    41 
    4240}
Note: See TracChangeset for help on using the changeset viewer.