Changeset 3355671
- Timestamp:
- 09/03/2025 09:12:18 PM (7 months ago)
- Location:
- goqmieruca
- Files:
-
- 12 edited
- 1 copied
-
tags/1.0.2 (copied) (copied from goqmieruca/trunk)
-
tags/1.0.2/admin/class-admin-page.php (modified) (15 diffs)
-
tags/1.0.2/admin/class-admin-setting.php (modified) (17 diffs)
-
tags/1.0.2/admin/class-goqmieruca-admin.php (modified) (4 diffs)
-
tags/1.0.2/class-goqmieruca.php (modified) (5 diffs)
-
tags/1.0.2/front/class-goqmieruca-front.php (modified) (2 diffs)
-
tags/1.0.2/goqmieruca.php (modified) (1 diff)
-
trunk/admin/class-admin-page.php (modified) (15 diffs)
-
trunk/admin/class-admin-setting.php (modified) (17 diffs)
-
trunk/admin/class-goqmieruca-admin.php (modified) (4 diffs)
-
trunk/class-goqmieruca.php (modified) (5 diffs)
-
trunk/front/class-goqmieruca-front.php (modified) (2 diffs)
-
trunk/goqmieruca.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
goqmieruca/tags/1.0.2/admin/class-admin-page.php
r1935300 r3355671 1 1 <?php 2 class GOQMIERUCA_Admin_Page { 2 class GOQMIERUCA_Admin_Page 3 { 3 4 public $action_status, $action_message; 4 5 public $error_message = array(); … … 9 10 protected $plugin_screen_hook_suffix = null; 10 11 11 public function __construct() { 12 public function __construct() 13 { 12 14 $plugin = GOQMIERUCA::get_instance(); 13 15 $this->plugin_slug = $plugin->get_plugin_slug(); … … 15 17 $this->menu_slug = $admin->get_toplevel_menu_slug(); 16 18 $this->submenu_slug = $admin->get_submenu_slug(); 17 // $this->clear_action_status();18 19 /*******************************************/ 19 20 20 add_action( 'admin_head', array( $this, 'add_admin_head' ));21 add_action('admin_head', array($this, 'add_admin_head')); 21 22 22 23 // 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')); 25 26 26 27 // 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')); 28 29 29 30 //スクリーン自体の表示・非表示 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); 31 32 32 33 //スクリーンの表示件数取得 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); 34 35 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')); 39 40 } 40 41 … … 51 52 * @since 1.0.0 52 53 ***********************************/ 53 public function admin_help_setting( $help, $screen_id, $screen ) { 54 55 } 54 public function admin_help_setting($help, $screen_id, $screen) {} 56 55 57 56 /*********************************** … … 60 59 * @since 1.0.0 61 60 ***********************************/ 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 { 66 63 } 67 64 … … 71 68 * @since 1.0.0 72 69 ***********************************/ 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)) 75 73 return; 76 74 … … 78 76 $screen = get_current_screen(); 79 77 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); 82 80 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); 86 84 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); 89 87 } 90 88 } … … 95 93 * @since 1.0.0 96 94 ***********************************/ 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)) 99 98 return; 100 99 101 100 $screen = get_current_screen(); 102 101 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'); 107 106 } 108 107 } … … 114 113 * NOTE: $show_screen = 1は表示オプションを表示、0は非表示 115 114 ***********************************/ 116 public function admin_show_screen( $show_screen, $screen ) { 115 public function admin_show_screen($show_screen, $screen) 116 { 117 117 return $show_screen; 118 118 } … … 124 124 * NOTE: screen_options_show_screen にフックして、保存されたリストの表示件数を適用 125 125 ***********************************/ 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 { 131 128 return $result; 132 129 } … … 137 134 * @since 1.0.0 138 135 ***********************************/ 139 public function add_admin_menu() { 140 141 } 136 public function add_admin_menu() {} 142 137 143 138 /*********************************** … … 146 141 * @since 1.0.0 147 142 ***********************************/ 148 public function set_action_status( $status, $message ) { 143 public function set_action_status($status, $message) 144 { 149 145 $this->action_status = $status; 150 146 $this->action_message = $message; … … 158 154 * @since 1.0.0 159 155 ***********************************/ 160 public function clear_action_status() { 156 public function clear_action_status() 157 { 161 158 $this->action_status = 'none'; 162 159 $this->action_message = ''; … … 170 167 * @since 1.0.0 171 168 *******************************/ 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)) 174 172 return; 175 173 176 174 $screen = get_current_screen(); 177 if ( $this->plugin_screen_hook_suffix != $screen->id)175 if ($this->plugin_screen_hook_suffix != $screen->id) 178 176 return; 179 177 ?> 180 <script type="text/javascript">178 <script type="text/javascript"> 181 179 182 </script>180 </script> 183 181 <?php 184 182 } … … 189 187 * @since 1.0.0 190 188 *******************************/ 191 public function admin_page_scripts() { 192 193 } 189 public function admin_page_scripts() {} 194 190 } -
goqmieruca/tags/1.0.2/admin/class-admin-setting.php
r1935300 r3355671 1 1 <?php 2 class GOQMIERUCA_Setting extends GOQMIERUCA_Admin_Page { 2 class GOQMIERUCA_Setting extends GOQMIERUCA_Admin_Page 3 { 3 4 4 5 protected static $instance = null; … … 26 27 * @since 1.0.0 27 28 ***********************************/ 28 public function __construct() { 29 public function __construct() 30 { 29 31 parent::__construct(); 30 32 } … … 37 39 * @return object A single instance of this class. 38 40 ***********************************/ 39 public static function get_instance() { 40 if ( null == self::$instance ) { 41 public static function get_instance() 42 { 43 if (null == self::$instance) { 41 44 self::$instance = new self; 42 45 } … … 50 53 * @since 1.0.0 51 54 ***********************************/ 52 protected function init() { 55 protected function init() 56 { 53 57 $this->title = ''; 54 58 } … … 59 63 * @since 1.0.0 60 64 ***********************************/ 61 public function admin_help_setting( $help, $screen_id, $screen ) { 62 } 65 public function admin_help_setting($help, $screen_id, $screen) {} 63 66 64 67 /*********************************** … … 67 70 * @since 1.0.0 68 71 ***********************************/ 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)) 71 75 return; 72 76 73 77 parent::enqueue_admin_styles(); 74 78 $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) { 77 80 } 78 81 } … … 83 86 * @since 1.0.0 84 87 ***********************************/ 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)) 87 91 return; 88 92 … … 93 97 94 98 /*********************************** 95 * 表示オプションの表示制御96 * @since 1.0.097 *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 /***********************************131 99 * リストの表示件数取得 132 100 * @since 1.0.0 … … 134 102 * NOTE: screen_options_show_screen にフックして、保存されたリストの表示件数を適用 135 103 ***********************************/ 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)) 140 109 $result = $value; 141 110 … … 148 117 * @since 1.0.0 149 118 ***********************************/ 150 public function add_admin_menu() { 119 public function add_admin_menu() 120 { 151 121 $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')); 154 124 } 155 125 … … 159 129 * @since 1.0.0 160 130 ***********************************/ 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)) 163 134 return; 164 135 165 136 $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']) { 170 141 $this->mode = $_REQUEST['action']; 171 } elseif ( isset($_REQUEST['action2']) && '-1' != $_REQUEST['action2']) {142 } elseif (isset($_REQUEST['action2']) && '-1' != $_REQUEST['action2']) { 172 143 $this->mode = $_REQUEST['action2']; 173 144 } else { … … 176 147 177 148 //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'])) { 179 150 $action_status = $_SESSION[$this->plugin_slug]['action_status']; 180 151 $action_message = $_SESSION[$this->plugin_slug]['action_message']; 181 152 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 } 197 180 } 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; 223 187 } 224 188 } … … 229 193 * @since 1.0.0 230 194 ***********************************/ 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)) 233 198 return; 234 199 235 200 $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') { 241 206 $status = $this->action_status; 242 207 $message = $this->action_message; … … 246 211 247 212 $gqm_system_setting = get_option('gqm_system_setting'); 248 } else{213 } else { 249 214 $status = $this->action_status; 250 215 $message = $this->action_message; … … 253 218 $this->error_message = array(); 254 219 } 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)) { 262 228 $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>'; 265 231 } 266 232 $res .= '</ul>'; … … 268 234 echo $res; 269 235 } 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)) 273 240 return; 274 241 275 242 $screen = get_current_screen(); 276 if ( $this->plugin_screen_hook_suffix != $screen->id)243 if ($this->plugin_screen_hook_suffix != $screen->id) 277 244 return; 278 245 279 246 ob_start(); 280 247 ?> 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> 290 257 <?php 291 258 $html = ob_get_contents(); … … 293 260 echo $html; 294 261 } 295 296 262 } -
goqmieruca/tags/1.0.2/admin/class-goqmieruca-admin.php
r1935300 r3355671 1 1 <?php 2 class GOQMIERUCA_Admin { 2 class GOQMIERUCA_Admin 3 { 3 4 protected static $instance = null; 4 5 … … 6 7 protected $submenu_slug = array(); 7 8 8 private function __construct() { 9 private function __construct() 10 { 9 11 $plugin = GOQMIERUCA::get_instance(); 10 12 $this->plugin_slug = $plugin->get_plugin_slug(); … … 13 15 $this->menu_slug['menu1'] = $this->plugin_slug . '_management'; 14 16 $this->submenu_slug['menu1']['sub1'] = $this->plugin_slug . '_setting'; 15 //$this->submenu_slug['menu1']['sub2'] = $this->plugin_slug . '_list';16 17 } 17 18 18 public static function get_instance() { 19 public static function get_instance() 20 { 19 21 20 if ( null == self::$instance) {22 if (null == self::$instance) { 21 23 self::$instance = new self; 22 24 } … … 25 27 } 26 28 27 public function get_toplevel_menu_slug() { 29 public function get_toplevel_menu_slug() 30 { 28 31 return $this->menu_slug; 29 32 } 30 33 31 public function get_submenu_slug(){ 34 public function get_submenu_slug() 35 { 32 36 return $this->submenu_slug; 33 37 } -
goqmieruca/tags/1.0.2/class-goqmieruca.php
r1935300 r3355671 1 1 <?php 2 class GOQMIERUCA { 2 class GOQMIERUCA 3 { 3 4 protected $plugin_slug = 'goqmieruca'; 4 5 5 6 protected static $instance = null; 6 7 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')); 12 13 } 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) { 16 18 self::$instance = new self; 17 19 } … … 19 21 } 20 22 21 public function get_plugin_slug() { 23 public function get_plugin_slug() 24 { 22 25 return $this->plugin_slug; 23 26 } 24 27 25 public static function load_textdomain() {28 public static function load_textdomain() {} 26 29 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) { 28 36 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); 36 38 self::single_activate(); 37 39 … … 46 48 } 47 49 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) { 51 54 $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); 54 57 self::single_deactivate(); 55 58 restore_current_blog(); … … 63 66 } 64 67 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')) { 67 71 return; 68 72 } 69 switch_to_blog( $blog_id);73 switch_to_blog($blog_id); 70 74 self::single_activate(); 71 75 restore_current_blog(); 72 76 } 73 77 74 private static function get_blog_ids() { 78 private static function get_blog_ids() 79 { 75 80 global $wpdb; 76 81 … … 79 84 AND deleted = '0'"; 80 85 81 return $wpdb->get_col( $sql);86 return $wpdb->get_col($sql); 82 87 } 83 88 84 89 85 private static function single_activate() { 90 private static function single_activate() 91 { 86 92 $old = get_option('gqm_system_setting'); 87 $new['sitecode'] = isset($old['sitecode']) ? $old['sitecode'] : '';88 93 $new['sitecode'] = isset($old['sitecode']) ? $old['sitecode'] : ''; 94 89 95 $res = update_option('gqm_system_setting', $new); 90 96 } 91 97 92 private static function single_deactivate() { 93 } 98 private static function single_deactivate() {} 94 99 95 function wp_print_styles() {100 function wp_print_styles() {} 96 101 97 } 98 99 function enqueue_scripts(){ 102 function enqueue_scripts() 103 { 100 104 //wp_enqueue_style( 'cs-css', GOQMIERUCA_PLUGIN_URL.'/common/css/custom.css' ); 101 105 } 102 106 103 function wp_print_scripts(){ 104 105 } 107 function wp_print_scripts() {} 106 108 } -
goqmieruca/tags/1.0.2/front/class-goqmieruca-front.php
r2369125 r3355671 1 1 <?php 2 class GOQMIERUCA_Front { 2 class GOQMIERUCA_Front 3 { 3 4 protected static $instance = null; 4 5 5 private function __construct() { 6 private function __construct() 7 { 6 8 $plugin = GOQMIERUCA::get_instance(); 7 9 $this->plugin_slug = $plugin->get_plugin_slug(); 8 10 $this->gqm_system_setting = get_option('gqm_system_setting'); 9 11 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); 14 16 } 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) { 18 21 self::$instance = new self; 19 22 } … … 22 25 23 26 24 function wp_print_styles() {27 function wp_print_styles() {} 25 28 26 } 27 28 function enqueue_scripts(){ 29 function enqueue_scripts() 30 { 29 31 //wp_enqueue_style( 'front-css', GOQMIERUCA_PLUGIN_URL.'/front/assets/css/front.css' ); 30 32 } 31 33 32 function wp_print_scripts() {34 function wp_print_scripts() {} 33 35 34 } 35 36 function print_footer_scripts(){ 36 function print_footer_scripts() 37 { 37 38 if ($this->gqm_system_setting['sitecode']) { 38 39 ?> 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> 47 50 <?php 48 51 } 49 52 } 50 51 52 53 } -
goqmieruca/tags/1.0.2/goqmieruca.php
r2369126 r3355671 10 10 */ 11 11 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__));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__)); 18 18 19 require_once( GOQMIERUCA_PLUGIN_DIR . '/class-goqmieruca.php');20 require_once( GOQMIERUCA_PLUGIN_DIR . '/common/function.php');19 require_once(GOQMIERUCA_PLUGIN_DIR . '/class-goqmieruca.php'); 20 require_once(GOQMIERUCA_PLUGIN_DIR . '/common/function.php'); 21 21 22 22 GOQMIERUCA::load_textdomain(); 23 23 24 register_activation_hook( __FILE__, array( 'GOQMIERUCA', 'activate' ));25 register_deactivation_hook( __FILE__, array( 'GOQMIERUCA', 'deactivate' ));24 register_activation_hook(__FILE__, array('GOQMIERUCA', 'activate')); 25 register_deactivation_hook(__FILE__, array('GOQMIERUCA', 'deactivate')); 26 26 27 add_action( 'plugins_loaded', array('GOQMIERUCA', 'get_instance'));27 add_action('plugins_loaded', array('GOQMIERUCA', 'get_instance')); 28 28 29 if ( is_admin() ){30 require_once( GOQMIERUCA_PLUGIN_DIR . '/admin/class-goqmieruca-admin.php');29 if (is_admin()) { 30 require_once(GOQMIERUCA_PLUGIN_DIR . '/admin/class-goqmieruca-admin.php'); 31 31 add_action('plugins_loaded', array('GOQMIERUCA_Admin', 'get_instance')); 32 32 33 require_once( GOQMIERUCA_PLUGIN_DIR . '/admin/class-admin-page.php');33 require_once(GOQMIERUCA_PLUGIN_DIR . '/admin/class-admin-page.php'); 34 34 35 require_once( GOQMIERUCA_PLUGIN_DIR . '/admin/class-admin-setting.php');35 require_once(GOQMIERUCA_PLUGIN_DIR . '/admin/class-admin-setting.php'); 36 36 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'); 40 39 add_action('plugins_loaded', array('GOQMIERUCA_Front', 'get_instance')); 41 42 40 } -
goqmieruca/trunk/admin/class-admin-page.php
r1935300 r3355671 1 1 <?php 2 class GOQMIERUCA_Admin_Page { 2 class GOQMIERUCA_Admin_Page 3 { 3 4 public $action_status, $action_message; 4 5 public $error_message = array(); … … 9 10 protected $plugin_screen_hook_suffix = null; 10 11 11 public function __construct() { 12 public function __construct() 13 { 12 14 $plugin = GOQMIERUCA::get_instance(); 13 15 $this->plugin_slug = $plugin->get_plugin_slug(); … … 15 17 $this->menu_slug = $admin->get_toplevel_menu_slug(); 16 18 $this->submenu_slug = $admin->get_submenu_slug(); 17 // $this->clear_action_status();18 19 /*******************************************/ 19 20 20 add_action( 'admin_head', array( $this, 'add_admin_head' ));21 add_action('admin_head', array($this, 'add_admin_head')); 21 22 22 23 // 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')); 25 26 26 27 // 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')); 28 29 29 30 //スクリーン自体の表示・非表示 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); 31 32 32 33 //スクリーンの表示件数取得 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); 34 35 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')); 39 40 } 40 41 … … 51 52 * @since 1.0.0 52 53 ***********************************/ 53 public function admin_help_setting( $help, $screen_id, $screen ) { 54 55 } 54 public function admin_help_setting($help, $screen_id, $screen) {} 56 55 57 56 /*********************************** … … 60 59 * @since 1.0.0 61 60 ***********************************/ 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 { 66 63 } 67 64 … … 71 68 * @since 1.0.0 72 69 ***********************************/ 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)) 75 73 return; 76 74 … … 78 76 $screen = get_current_screen(); 79 77 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); 82 80 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); 86 84 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); 89 87 } 90 88 } … … 95 93 * @since 1.0.0 96 94 ***********************************/ 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)) 99 98 return; 100 99 101 100 $screen = get_current_screen(); 102 101 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'); 107 106 } 108 107 } … … 114 113 * NOTE: $show_screen = 1は表示オプションを表示、0は非表示 115 114 ***********************************/ 116 public function admin_show_screen( $show_screen, $screen ) { 115 public function admin_show_screen($show_screen, $screen) 116 { 117 117 return $show_screen; 118 118 } … … 124 124 * NOTE: screen_options_show_screen にフックして、保存されたリストの表示件数を適用 125 125 ***********************************/ 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 { 131 128 return $result; 132 129 } … … 137 134 * @since 1.0.0 138 135 ***********************************/ 139 public function add_admin_menu() { 140 141 } 136 public function add_admin_menu() {} 142 137 143 138 /*********************************** … … 146 141 * @since 1.0.0 147 142 ***********************************/ 148 public function set_action_status( $status, $message ) { 143 public function set_action_status($status, $message) 144 { 149 145 $this->action_status = $status; 150 146 $this->action_message = $message; … … 158 154 * @since 1.0.0 159 155 ***********************************/ 160 public function clear_action_status() { 156 public function clear_action_status() 157 { 161 158 $this->action_status = 'none'; 162 159 $this->action_message = ''; … … 170 167 * @since 1.0.0 171 168 *******************************/ 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)) 174 172 return; 175 173 176 174 $screen = get_current_screen(); 177 if ( $this->plugin_screen_hook_suffix != $screen->id)175 if ($this->plugin_screen_hook_suffix != $screen->id) 178 176 return; 179 177 ?> 180 <script type="text/javascript">178 <script type="text/javascript"> 181 179 182 </script>180 </script> 183 181 <?php 184 182 } … … 189 187 * @since 1.0.0 190 188 *******************************/ 191 public function admin_page_scripts() { 192 193 } 189 public function admin_page_scripts() {} 194 190 } -
goqmieruca/trunk/admin/class-admin-setting.php
r1935300 r3355671 1 1 <?php 2 class GOQMIERUCA_Setting extends GOQMIERUCA_Admin_Page { 2 class GOQMIERUCA_Setting extends GOQMIERUCA_Admin_Page 3 { 3 4 4 5 protected static $instance = null; … … 26 27 * @since 1.0.0 27 28 ***********************************/ 28 public function __construct() { 29 public function __construct() 30 { 29 31 parent::__construct(); 30 32 } … … 37 39 * @return object A single instance of this class. 38 40 ***********************************/ 39 public static function get_instance() { 40 if ( null == self::$instance ) { 41 public static function get_instance() 42 { 43 if (null == self::$instance) { 41 44 self::$instance = new self; 42 45 } … … 50 53 * @since 1.0.0 51 54 ***********************************/ 52 protected function init() { 55 protected function init() 56 { 53 57 $this->title = ''; 54 58 } … … 59 63 * @since 1.0.0 60 64 ***********************************/ 61 public function admin_help_setting( $help, $screen_id, $screen ) { 62 } 65 public function admin_help_setting($help, $screen_id, $screen) {} 63 66 64 67 /*********************************** … … 67 70 * @since 1.0.0 68 71 ***********************************/ 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)) 71 75 return; 72 76 73 77 parent::enqueue_admin_styles(); 74 78 $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) { 77 80 } 78 81 } … … 83 86 * @since 1.0.0 84 87 ***********************************/ 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)) 87 91 return; 88 92 … … 93 97 94 98 /*********************************** 95 * 表示オプションの表示制御96 * @since 1.0.097 *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 /***********************************131 99 * リストの表示件数取得 132 100 * @since 1.0.0 … … 134 102 * NOTE: screen_options_show_screen にフックして、保存されたリストの表示件数を適用 135 103 ***********************************/ 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)) 140 109 $result = $value; 141 110 … … 148 117 * @since 1.0.0 149 118 ***********************************/ 150 public function add_admin_menu() { 119 public function add_admin_menu() 120 { 151 121 $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')); 154 124 } 155 125 … … 159 129 * @since 1.0.0 160 130 ***********************************/ 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)) 163 134 return; 164 135 165 136 $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']) { 170 141 $this->mode = $_REQUEST['action']; 171 } elseif ( isset($_REQUEST['action2']) && '-1' != $_REQUEST['action2']) {142 } elseif (isset($_REQUEST['action2']) && '-1' != $_REQUEST['action2']) { 172 143 $this->mode = $_REQUEST['action2']; 173 144 } else { … … 176 147 177 148 //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'])) { 179 150 $action_status = $_SESSION[$this->plugin_slug]['action_status']; 180 151 $action_message = $_SESSION[$this->plugin_slug]['action_message']; 181 152 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 } 197 180 } 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; 223 187 } 224 188 } … … 229 193 * @since 1.0.0 230 194 ***********************************/ 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)) 233 198 return; 234 199 235 200 $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') { 241 206 $status = $this->action_status; 242 207 $message = $this->action_message; … … 246 211 247 212 $gqm_system_setting = get_option('gqm_system_setting'); 248 } else{213 } else { 249 214 $status = $this->action_status; 250 215 $message = $this->action_message; … … 253 218 $this->error_message = array(); 254 219 } 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)) { 262 228 $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>'; 265 231 } 266 232 $res .= '</ul>'; … … 268 234 echo $res; 269 235 } 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)) 273 240 return; 274 241 275 242 $screen = get_current_screen(); 276 if ( $this->plugin_screen_hook_suffix != $screen->id)243 if ($this->plugin_screen_hook_suffix != $screen->id) 277 244 return; 278 245 279 246 ob_start(); 280 247 ?> 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> 290 257 <?php 291 258 $html = ob_get_contents(); … … 293 260 echo $html; 294 261 } 295 296 262 } -
goqmieruca/trunk/admin/class-goqmieruca-admin.php
r1935300 r3355671 1 1 <?php 2 class GOQMIERUCA_Admin { 2 class GOQMIERUCA_Admin 3 { 3 4 protected static $instance = null; 4 5 … … 6 7 protected $submenu_slug = array(); 7 8 8 private function __construct() { 9 private function __construct() 10 { 9 11 $plugin = GOQMIERUCA::get_instance(); 10 12 $this->plugin_slug = $plugin->get_plugin_slug(); … … 13 15 $this->menu_slug['menu1'] = $this->plugin_slug . '_management'; 14 16 $this->submenu_slug['menu1']['sub1'] = $this->plugin_slug . '_setting'; 15 //$this->submenu_slug['menu1']['sub2'] = $this->plugin_slug . '_list';16 17 } 17 18 18 public static function get_instance() { 19 public static function get_instance() 20 { 19 21 20 if ( null == self::$instance) {22 if (null == self::$instance) { 21 23 self::$instance = new self; 22 24 } … … 25 27 } 26 28 27 public function get_toplevel_menu_slug() { 29 public function get_toplevel_menu_slug() 30 { 28 31 return $this->menu_slug; 29 32 } 30 33 31 public function get_submenu_slug(){ 34 public function get_submenu_slug() 35 { 32 36 return $this->submenu_slug; 33 37 } -
goqmieruca/trunk/class-goqmieruca.php
r1935300 r3355671 1 1 <?php 2 class GOQMIERUCA { 2 class GOQMIERUCA 3 { 3 4 protected $plugin_slug = 'goqmieruca'; 4 5 5 6 protected static $instance = null; 6 7 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')); 12 13 } 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) { 16 18 self::$instance = new self; 17 19 } … … 19 21 } 20 22 21 public function get_plugin_slug() { 23 public function get_plugin_slug() 24 { 22 25 return $this->plugin_slug; 23 26 } 24 27 25 public static function load_textdomain() {28 public static function load_textdomain() {} 26 29 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) { 28 36 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); 36 38 self::single_activate(); 37 39 … … 46 48 } 47 49 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) { 51 54 $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); 54 57 self::single_deactivate(); 55 58 restore_current_blog(); … … 63 66 } 64 67 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')) { 67 71 return; 68 72 } 69 switch_to_blog( $blog_id);73 switch_to_blog($blog_id); 70 74 self::single_activate(); 71 75 restore_current_blog(); 72 76 } 73 77 74 private static function get_blog_ids() { 78 private static function get_blog_ids() 79 { 75 80 global $wpdb; 76 81 … … 79 84 AND deleted = '0'"; 80 85 81 return $wpdb->get_col( $sql);86 return $wpdb->get_col($sql); 82 87 } 83 88 84 89 85 private static function single_activate() { 90 private static function single_activate() 91 { 86 92 $old = get_option('gqm_system_setting'); 87 $new['sitecode'] = isset($old['sitecode']) ? $old['sitecode'] : '';88 93 $new['sitecode'] = isset($old['sitecode']) ? $old['sitecode'] : ''; 94 89 95 $res = update_option('gqm_system_setting', $new); 90 96 } 91 97 92 private static function single_deactivate() { 93 } 98 private static function single_deactivate() {} 94 99 95 function wp_print_styles() {100 function wp_print_styles() {} 96 101 97 } 98 99 function enqueue_scripts(){ 102 function enqueue_scripts() 103 { 100 104 //wp_enqueue_style( 'cs-css', GOQMIERUCA_PLUGIN_URL.'/common/css/custom.css' ); 101 105 } 102 106 103 function wp_print_scripts(){ 104 105 } 107 function wp_print_scripts() {} 106 108 } -
goqmieruca/trunk/front/class-goqmieruca-front.php
r2369125 r3355671 1 1 <?php 2 class GOQMIERUCA_Front { 2 class GOQMIERUCA_Front 3 { 3 4 protected static $instance = null; 4 5 5 private function __construct() { 6 private function __construct() 7 { 6 8 $plugin = GOQMIERUCA::get_instance(); 7 9 $this->plugin_slug = $plugin->get_plugin_slug(); 8 10 $this->gqm_system_setting = get_option('gqm_system_setting'); 9 11 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); 14 16 } 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) { 18 21 self::$instance = new self; 19 22 } … … 22 25 23 26 24 function wp_print_styles() {27 function wp_print_styles() {} 25 28 26 } 27 28 function enqueue_scripts(){ 29 function enqueue_scripts() 30 { 29 31 //wp_enqueue_style( 'front-css', GOQMIERUCA_PLUGIN_URL.'/front/assets/css/front.css' ); 30 32 } 31 33 32 function wp_print_scripts() {34 function wp_print_scripts() {} 33 35 34 } 35 36 function print_footer_scripts(){ 36 function print_footer_scripts() 37 { 37 38 if ($this->gqm_system_setting['sitecode']) { 38 39 ?> 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> 47 50 <?php 48 51 } 49 52 } 50 51 52 53 } -
goqmieruca/trunk/goqmieruca.php
r2369126 r3355671 10 10 */ 11 11 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__));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__)); 18 18 19 require_once( GOQMIERUCA_PLUGIN_DIR . '/class-goqmieruca.php');20 require_once( GOQMIERUCA_PLUGIN_DIR . '/common/function.php');19 require_once(GOQMIERUCA_PLUGIN_DIR . '/class-goqmieruca.php'); 20 require_once(GOQMIERUCA_PLUGIN_DIR . '/common/function.php'); 21 21 22 22 GOQMIERUCA::load_textdomain(); 23 23 24 register_activation_hook( __FILE__, array( 'GOQMIERUCA', 'activate' ));25 register_deactivation_hook( __FILE__, array( 'GOQMIERUCA', 'deactivate' ));24 register_activation_hook(__FILE__, array('GOQMIERUCA', 'activate')); 25 register_deactivation_hook(__FILE__, array('GOQMIERUCA', 'deactivate')); 26 26 27 add_action( 'plugins_loaded', array('GOQMIERUCA', 'get_instance'));27 add_action('plugins_loaded', array('GOQMIERUCA', 'get_instance')); 28 28 29 if ( is_admin() ){30 require_once( GOQMIERUCA_PLUGIN_DIR . '/admin/class-goqmieruca-admin.php');29 if (is_admin()) { 30 require_once(GOQMIERUCA_PLUGIN_DIR . '/admin/class-goqmieruca-admin.php'); 31 31 add_action('plugins_loaded', array('GOQMIERUCA_Admin', 'get_instance')); 32 32 33 require_once( GOQMIERUCA_PLUGIN_DIR . '/admin/class-admin-page.php');33 require_once(GOQMIERUCA_PLUGIN_DIR . '/admin/class-admin-page.php'); 34 34 35 require_once( GOQMIERUCA_PLUGIN_DIR . '/admin/class-admin-setting.php');35 require_once(GOQMIERUCA_PLUGIN_DIR . '/admin/class-admin-setting.php'); 36 36 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'); 40 39 add_action('plugins_loaded', array('GOQMIERUCA_Front', 'get_instance')); 41 42 40 }
Note: See TracChangeset
for help on using the changeset viewer.