PluginProbe
Pochipp / 1.20.2
Pochipp v1.20.2
1.20.2 1.20.0 1.20.1 1.19.1 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.8.0 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.9.0 1.9.1 1.9.10 1.9.11 1.9.2 1.9.3 1.9.4 1.9.5 All 98 releases
pochipp / pochipp.php

pochipp.php in Pochipp 1.20.2, at pochipp.php

162 lines 4.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Pochipp
4 * Plugin URI: https://pochipp.com/
5 * Description: Amazon・楽天市場・Yahooショッピングなどのアフィリエイトリンクを簡単に作成・管理できる、ブロックエディターに最適化されたプラグインです。
6 * Author: ひろ
7 * Version: 1.20.2
8 * Requires at least: 6.3
9 * Author URI: https://twitter.com/hiro_develop127
10 * Text Domain: pochipp
11 * License: GPL3 or later
12 * License URI: https://www.gnu.org/licenses/gpl-3.0.html
13 */
14
15 if ( ! defined( 'ABSPATH' ) ) exit;
16
17
18 /**
19 * Define
20 */
21 define( 'POCHIPP_URL', plugins_url( '/', __FILE__ ) );
22 define( 'POCHIPP_PATH', plugin_dir_path( __FILE__ ) );
23 define( 'POCHIPP_BASENAME', plugin_basename( __FILE__ ) );
24
25
26 /**
27 * Autoload
28 */
29 spl_autoload_register( function( $classname ) {
30
31 if ( false === strpos( $classname, 'POCHIPP' ) ) return;
32
33 $file_name = str_replace( 'POCHIPP\\', '', $classname );
34 $file_name = str_replace( '\\', '/', $file_name );
35 $file = POCHIPP_PATH . 'class/' . $file_name . '.php';
36
37 if ( file_exists( $file ) ) require $file;
38 });
39
40 /**
41 * POCHIPP
42 */
43 class POCHIPP extends \POCHIPP\Data {
44 use \POCHIPP\Setting, \POCHIPP\Helper;
45
46 public function __construct() {
47
48 $file_data = get_file_data( __FILE__, [ 'version' => 'Version' ] );
49 self::$version = $file_data['version'];
50 if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
51 self::$version = date( 'mdGis' );
52 }
53
54 if ( ! class_exists( '\AwsV4' ) ) {
55 require_once POCHIPP_PATH . 'inc/paapi5/AwsV4.php';
56 }
57 if ( ! class_exists( '\GetItemsRequest' ) ) {
58 require_once POCHIPP_PATH . 'inc/paapi5/GetItemsRequest.php';
59 }
60 if ( ! class_exists( '\SearchItemsRequest' ) ) {
61 require_once POCHIPP_PATH . 'inc/paapi5/SearchItemsRequest.php';
62 }
63
64 if ( ! class_exists( '\POCHIPP\CreatorsApiClient' ) ) {
65 require_once POCHIPP_PATH . 'inc/creatorsapi/CreatorsApiClient.php';
66 require_once POCHIPP_PATH . 'inc/creatorsapi/functions.php';
67 }
68
69 add_action( 'init', [ $this, 'set_setting_data' ], 1 );
70 add_action( 'after_setup_theme', [ $this, 'load_pluggable' ], 99 );
71
72 require_once POCHIPP_PATH . 'inc/block_api_version.php';
73 require_once POCHIPP_PATH . 'inc/enqueues.php';
74 require_once POCHIPP_PATH . 'inc/output.php';
75 require_once POCHIPP_PATH . 'inc/register_pt.php';
76 require_once POCHIPP_PATH . 'inc/register_tax.php';
77 require_once POCHIPP_PATH . 'inc/register_meta.php';
78 require_once POCHIPP_PATH . 'inc/common/auto_update.php';
79 require_once POCHIPP_PATH . 'inc/render_inline_element.php';
80 require_once POCHIPP_PATH . 'inc/register_blocks.php';
81 require_once POCHIPP_PATH . 'inc/register_shortcode.php';
82 require_once POCHIPP_PATH . 'inc/cron.php';
83 require_once POCHIPP_PATH . 'inc/ajax.php';
84
85 if ( is_admin() ) {
86 require_once POCHIPP_PATH . 'inc/thickbox.php';
87 require_once POCHIPP_PATH . 'inc/menu.php';
88 require_once POCHIPP_PATH . 'inc/menu/notices.php';
89 require_once POCHIPP_PATH . 'inc/manage_columns.php';
90
91 add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), function ( $links ) {
92 if ( class_exists( 'Pochipp_Pro' ) ) {
93 return $links;
94 }
95 return array_merge( $links, [
96 '<a target="_blank" href="https://pochipp.com/pochipp-pro/" style="color: #e48b06;font-weight: 700;">PRO機能を今すぐ�
97 �手する</a>',
98 ]);
99 } );
100 }
101 }
102
103
104 /**
105 * load_pluggable
106 */
107 public function load_pluggable() {
108 require_once POCHIPP_PATH . 'inc/pluggable.php';
109 }
110
111 /**
112 * set_setting_data
113 */
114 public function set_setting_data() {
115 $setting_data = get_option( self::DB_NAME ) ?: [];
116 self::$setting_data = array_merge( self::$default_data, $setting_data );
117 self::$has_affi = [
118 'amazon' => (bool) self::$setting_data['amazon_traccking_id'] || self::$setting_data['moshimo_amazon_aid'],
119 'rakuten' => (bool) self::$setting_data['rakuten_affiliate_id'] || self::$setting_data['moshimo_rakuten_aid'],
120 'yahoo' => (bool) self::$setting_data['yahoo_linkswitch'] || self::$setting_data['moshimo_yahoo_aid'],
121 'mercari' => (bool) self::$setting_data['mercari_ambassador_id'],
122 ];
123 self::$mercari_hidden_settings = self::$setting_data['mercari_hidden_settings'] ?? [];
124 }
125
126
127 /**
128 * get_setting
129 */
130 public static function get_setting( $key = null ) {
131 if ( null !== $key ) {
132 return self::$setting_data[ $key ] ?? '';
133 }
134 return self::$setting_data;
135 }
136
137 /**
138 * update_setting
139 */
140 public static function update_setting( $data ) {
141 $update_data = array_merge( self::$setting_data, $data );
142 update_option( self::DB_NAME, $update_data );
143 }
144 }
145
146 /**
147 * Start
148 */
149 add_action( 'plugins_loaded', function() {
150 new POCHIPP();
151 }, 11 );
152
153 register_activation_hook( __FILE__, function() {
154 require_once POCHIPP_PATH . 'inc/cron.php';
155 \POCHIPP\schedule_auto_update();
156 } );
157
158 register_deactivation_hook( __FILE__, function() {
159 require_once POCHIPP_PATH . 'inc/cron.php';
160 \POCHIPP\clear_auto_update_schedule();
161 } );
162