[WP] Google Analytics Dashboard for WP (GADWP) の認証が突然切断される場合の応急処置

<?php/** * functions.phpに書いてね */// Google Analytics Dashboard for WP (GADWP) 専用処理// トラッキングコードをテーマ側での出力するため、プラグインの処理は停止function oc_wp_loaded_gadwp() { if ( class_exists( 'GADWP_Tracking' ) && function_exists( 'GADWP' ) ) { $oc_gadwp_plugin = GADWP(); if ( isset($oc_gadwp_plugin->tracking) && isset($oc_gadwp_plugin->tracking->analytics) ) { // GoogleAnalyticsコード出力用のアクションのみを取り除く remove_action( 'wp_head', array( $oc_gadwp_plugin->tracking->analytics, 'output' ), 99 ); remove_action( 'wp_footer', array( $oc_gadwp_plugin->tracking->analytics, 'output' ), 99 ); } }}add_action('wp_loaded', 'oc_wp_loaded_gadwp', 99);// GoogleAnalyticsコードの出力function oc_google_analytics() { ?> <script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-XXXXXXXX-1', 'auto'); ga('send', 'pageview'); </script><?php}add_action( 'wp_head', 'oc_google_analytics', 999 );

WordPressのプラグインで、get_template_part的なものを使いたい

<?php// wp-content/plugins/wp-onocom-plugin.php class wp_onocom_plugin { static $instance = null; function __construct(){ self::$instance = $this; } public static function get_instance() { if( self::$instance != null ) { return self::$instance; } else { return new self(); } } public function get_plugin_template_part($slug, $name = null) { $templates = array(); $name = (string) $name; if ( '' !== $name ) $templates[] = "{$slug}-{$name}.php"; $templates[] = "{$slug}.php"; $located = ''; foreach ( (array) $templates as $template_name ) { if ( !$template_name ) { continue; } if ( file_exists($this->get_plugin_path() . '/' . $template_name) ) { $located = $this->get_plugin_path() . '/' . $template_name; break; } } if($located) { require_once( $located ); } } public function get_plugin_url() { return plugins_url("",__FILE__); } public function get_plugin_path() { return dirname(__FILE__); }}