Version Description
*
Download this release
Release Info
Developer | xserverjp |
Plugin | TypeSquare Webfonts for エックスサーバー |
Version | 0.9.0 |
Comparing to | |
See all releases |
Version 0.9.0
- inc/admin-base.php +49 -0
- inc/admin-fonttheme.php +200 -0
- inc/admin-root.php +452 -0
- inc/app.js +30072 -0
inc/admin-base.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class TypeSquare_Admin_Base {
|
3 |
+
private static $instance;
|
4 |
+
|
5 |
+
private static $text_domain;
|
6 |
+
|
7 |
+
const MENU_ID = 'typesquare-admin-menu';
|
8 |
+
const FONT_THEME = 'typesquare_fonttheme';
|
9 |
+
const MESSAGE_KEY = 'typesquare-admin-errors';
|
10 |
+
const MENU_FONTTHEME = 'typesquare-admin-fonttheme';
|
11 |
+
const MENU_FONTGEN = 'typesquare-admin-fontgen';
|
12 |
+
const FONT_THEME_MAX = 10;
|
13 |
+
private function __construct(){}
|
14 |
+
|
15 |
+
public static function get_instance() {
|
16 |
+
if ( ! isset( self::$instance ) ) {
|
17 |
+
$c = __CLASS__;
|
18 |
+
self::$instance = new $c();
|
19 |
+
}
|
20 |
+
return self::$instance;
|
21 |
+
}
|
22 |
+
|
23 |
+
public function get_auth_params() {
|
24 |
+
$auth = TypeSquare_ST_Auth::get_instance();
|
25 |
+
$param = $auth->get_auth_params();
|
26 |
+
return $param;
|
27 |
+
}
|
28 |
+
|
29 |
+
public function set_error_messages( $wp_error ) {
|
30 |
+
$msg[] = $wp_error->get_error_message();
|
31 |
+
set_transient( self::MESSAGE_KEY , $msg, 10 );
|
32 |
+
}
|
33 |
+
|
34 |
+
public function typesquare_admin_notices() {
|
35 |
+
$messages = get_transient( self::MESSAGE_KEY );
|
36 |
+
if ( ! $messages ) {
|
37 |
+
return;
|
38 |
+
}
|
39 |
+
?>
|
40 |
+
<div class="error">
|
41 |
+
<ul>
|
42 |
+
<?php foreach ( $messages as $message ) : ?>
|
43 |
+
<li><?php echo esc_html( $message );?></li>
|
44 |
+
<?php endforeach;?>
|
45 |
+
</ul>
|
46 |
+
</div>
|
47 |
+
<?php
|
48 |
+
}
|
49 |
+
}
|
inc/admin-fonttheme.php
ADDED
@@ -0,0 +1,200 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class TypeSquare_Admin_Fonttheme extends TypeSquare_Admin_Base {
|
3 |
+
private static $instance;
|
4 |
+
private static $text_domain;
|
5 |
+
|
6 |
+
private function __construct(){}
|
7 |
+
|
8 |
+
public static function get_instance() {
|
9 |
+
if ( ! isset( self::$instance ) ) {
|
10 |
+
$c = __CLASS__;
|
11 |
+
self::$instance = new $c();
|
12 |
+
}
|
13 |
+
return self::$instance;
|
14 |
+
}
|
15 |
+
|
16 |
+
public function fonttheme_setting() {
|
17 |
+
$option_name = 'typesquare_auth';
|
18 |
+
$nonce_key = TypeSquare_ST::OPTION_NAME;
|
19 |
+
echo "<div class='wrap'>";
|
20 |
+
echo '<h2>'. __( 'カスタムフォントテーマ' , self::$text_domain ). '</h2>';
|
21 |
+
echo '<p>'. __( 'オリジナルのフォントテーマの作成や編集が行えます。' , self::$text_domain ). '</p>';
|
22 |
+
do_action( 'typesquare_add_setting_before' );
|
23 |
+
$auth_param = $this->get_auth_params();
|
24 |
+
if ( false !== $auth_param['typesquare_auth']['auth_status'] ) {
|
25 |
+
echo $this->_get_custome_font_theme_list_form();
|
26 |
+
}
|
27 |
+
do_action( 'typesquare_add_setting_after' );
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @TODO: to use font theme generator
|
32 |
+
**/
|
33 |
+
public function get_font_select_form() {
|
34 |
+
$options = get_option( 'typesquare_custom_theme' );
|
35 |
+
$edit_theme = false;
|
36 |
+
if ( isset( $_POST['edit_theme'] ) ) {
|
37 |
+
$edit_theme = esc_attr( $_POST['edit_theme'] );
|
38 |
+
}
|
39 |
+
$fonts = TypeSquare_ST_Fonts::get_instance();
|
40 |
+
/* @TODO Debug Code
|
41 |
+
$option_name = 'typesquare_fonttheme';
|
42 |
+
$param = get_option( $option_name );
|
43 |
+
unset($param['fonts']);
|
44 |
+
update_option( $option_name, $param );
|
45 |
+
$param = $fonts->get_fonttheme_options();
|
46 |
+
*/
|
47 |
+
$font_list = $theme_id = $theme_name = '';
|
48 |
+
if ( $edit_theme && $options['theme'][ $edit_theme ] ) {
|
49 |
+
$theme_name = $options['theme'][ $edit_theme ]['name'];
|
50 |
+
$theme_id = $options['theme'][ $edit_theme ]['id'];
|
51 |
+
$font_list = $options['fonts'][ $edit_theme ];
|
52 |
+
}
|
53 |
+
|
54 |
+
$html = '';
|
55 |
+
$html .= '<hr/>';
|
56 |
+
$query = './admin.php?page='. self::MENU_FONTTHEME;
|
57 |
+
$html .= "<form method='post' action='{$query}' id='". self::MENU_FONTTHEME. "'>";
|
58 |
+
$html .= wp_nonce_field( 'ts_update_font_name_setting', 'ts_update_font_name_setting', true , false );
|
59 |
+
if ( $theme_id ) {
|
60 |
+
$theme_input = "<input type='hidden' name='typesquare_custom_theme[id]' value='{$theme_id}' />";
|
61 |
+
$html .= "<input type='hidden' name='ts_edit_mode' value='update' />";
|
62 |
+
$html .= $theme_input;
|
63 |
+
} else {
|
64 |
+
$theme_id = uniqid();
|
65 |
+
$theme_input = false;
|
66 |
+
$html .= "<input type='hidden' name='ts_edit_mode' value='new' />";
|
67 |
+
$html .= "<input type='hidden' name='typesquare_custom_theme[id]' value='{$theme_id}' maxlength='16' style='width:100%;' pattern='^[0-9A-Za-z]+$' required/>";
|
68 |
+
}
|
69 |
+
$html .= '<h4>■'. __( 'フォントテーマ名' , self::$text_domain ). '</h4>';
|
70 |
+
$html .= '<p>'. __( 'フォントテーマの名称を設定します。(最大16文字まで)' , self::$text_domain ). '</p>';
|
71 |
+
$html .= "<input type='text' name='typesquare_custom_theme[name]' value='{$theme_name}' maxlength='16' style='width:100%;' required/>";
|
72 |
+
$html .= '<h4>■'. __( 'フォントテーマの設定' , self::$text_domain ). '</h4>';
|
73 |
+
$html .= '<p>'. __( '各クラスに設定するフォントを選択します。' , self::$text_domain ). '</p>';
|
74 |
+
$html .= "<div id='ts-react-search-font'></div>";
|
75 |
+
$html .= get_submit_button( __( 'フォントテーマを設定する', self::$text_domain ) );
|
76 |
+
$html .= '</form>';
|
77 |
+
$html .= $this->_get_delete_fonttheme_form( $theme_input );
|
78 |
+
$html .= $this->_get_script( $font_list );
|
79 |
+
return $html;
|
80 |
+
}
|
81 |
+
|
82 |
+
private function _get_script( $font_list ) {
|
83 |
+
$vars = "var form_id = '#". self::MENU_FONTTHEME. "';";
|
84 |
+
$vars .= "var notify_text = '". __( 'フォントを1種類以上選択してください。', self::$text_domain ). "';";
|
85 |
+
$script = <<<EOM
|
86 |
+
{$vars}
|
87 |
+
jQuery( document ).ready(function() {
|
88 |
+
jQuery( form_id ).submit(function() {
|
89 |
+
var title = jQuery( 'select[name="typesquare_custom_theme[fonts][title][font]"]' ).val();
|
90 |
+
var lead = jQuery( 'select[name="typesquare_custom_theme[fonts][lead][font]"]' ).val();
|
91 |
+
var text = jQuery( 'select[name="typesquare_custom_theme[fonts][text][font]"]' ).val();
|
92 |
+
var bold = jQuery( 'select[name="typesquare_custom_theme[fonts][bold][font]"]' ).val();
|
93 |
+
if (
|
94 |
+
title === 'false' &&
|
95 |
+
lead === 'false' &&
|
96 |
+
text === 'false' &&
|
97 |
+
bold === 'false'
|
98 |
+
) {
|
99 |
+
alert( notify_text );
|
100 |
+
return false;
|
101 |
+
}
|
102 |
+
});
|
103 |
+
});
|
104 |
+
EOM;
|
105 |
+
$html = '<script>';
|
106 |
+
$endpoint = path_join( TS_PLUGIN_URL , 'inc/font.json' );
|
107 |
+
$html .= "var json_endpoint = '{$endpoint}';";
|
108 |
+
if ( $font_list ) {
|
109 |
+
$html .= "var current_font = ". json_encode( $font_list ) .';';
|
110 |
+
} else {
|
111 |
+
$html .= "var current_font = false;";
|
112 |
+
}
|
113 |
+
$html .= $script;
|
114 |
+
$html .= '</script>';
|
115 |
+
return $html;
|
116 |
+
}
|
117 |
+
|
118 |
+
private function _get_delete_fonttheme_form( $theme_input ) {
|
119 |
+
$html = '';
|
120 |
+
$query = './admin.php?page='. self::MENU_FONTTHEME;
|
121 |
+
if ( $theme_input ) {
|
122 |
+
$html .= "<form method='post' action='{$query}'>";
|
123 |
+
$html .= "<input type='hidden' name='ts_edit_mode' value='delete' />";
|
124 |
+
$html .= $theme_input;
|
125 |
+
$html .= wp_nonce_field( 'ts_update_font_name_setting', 'ts_update_font_name_setting', true , false );
|
126 |
+
$html .= get_submit_button( __( 'フォントテーマを削除する', self::$text_domain ) );
|
127 |
+
$html .= '</form>';
|
128 |
+
}
|
129 |
+
return $html;
|
130 |
+
}
|
131 |
+
|
132 |
+
private function _get_custome_font_theme_list_form() {
|
133 |
+
$options = get_option( 'typesquare_custom_theme' );
|
134 |
+
$query = './admin.php?page='. self::MENU_FONTGEN;
|
135 |
+
$html = '';
|
136 |
+
if ( is_array( $options['theme'] ) && ! empty( $options['theme'] ) ) {
|
137 |
+
$html .= '<h3>■'. __( 'カスタムフォントテーマ一覧' , self::$text_domain ). '</h3>';
|
138 |
+
$html .= "<table class='widefat form-table'>";
|
139 |
+
$html .= '<tbody>';
|
140 |
+
$html .= '<tr><td>';
|
141 |
+
$html .= "<form method='POST' action='{$query}'>";
|
142 |
+
$html .= "<select name='edit_theme'>";
|
143 |
+
foreach ( $options['theme'] as $option ) {
|
144 |
+
$name = $option['name'];
|
145 |
+
$id = $option['id'];
|
146 |
+
$fonts = $this->_get_font_data( $option['fonts'] );
|
147 |
+
$fonts = "( {$fonts} )";
|
148 |
+
$html .= "<option value='{$id}'>{$name}{$fonts}</option>";
|
149 |
+
}
|
150 |
+
$html .= '</select>';
|
151 |
+
$html .= "<input type='hidden' name='ts_edit_mode' value='update' />";
|
152 |
+
$html .= get_submit_button( __( '編集する', self::$text_domain ) );
|
153 |
+
$html .= wp_nonce_field( 'ts_update_font_list' , 'ts_update_font_list' , true , false );
|
154 |
+
$html .= '</form>';
|
155 |
+
$html .= '</td></tr>';
|
156 |
+
$html .= '</tbody>';
|
157 |
+
$html .= '</table>';
|
158 |
+
}
|
159 |
+
if (count($options['theme']) < self::FONT_THEME_MAX) {
|
160 |
+
$html .= "<form method='POST' action='{$query}'>";
|
161 |
+
$html .= "<input type='hidden' name='ts_edit_mode' value='new' />";
|
162 |
+
$html .= get_submit_button( __( '新しいカスタムフォントテーマを作成する', self::$text_domain ) );
|
163 |
+
$html .= wp_nonce_field( 'ts_update_font_list' , 'ts_update_font_list' , true , false );
|
164 |
+
$html .= '</form>';
|
165 |
+
}
|
166 |
+
return $html;
|
167 |
+
}
|
168 |
+
|
169 |
+
private function _get_font_data( $fonts ) {
|
170 |
+
$text = '';
|
171 |
+
if ( isset( $fonts['title'] ) ) {
|
172 |
+
$text .= __( '見出し:', self::$text_domain ). $fonts['title']. ',';
|
173 |
+
}
|
174 |
+
if ( isset( $fonts['lead'] ) ) {
|
175 |
+
$text .= __( 'リード:', self::$text_domain ). $fonts['lead']. ',';
|
176 |
+
}
|
177 |
+
if ( isset( $fonts['text'] ) ) {
|
178 |
+
$text .= __( '本文:', self::$text_domain ). $fonts['text']. ',';
|
179 |
+
}
|
180 |
+
if ( isset( $fonts['bold'] ) ) {
|
181 |
+
$text .= __( '太字:', self::$text_domain ). $fonts['bold']. ',';
|
182 |
+
}
|
183 |
+
$text = rtrim( $text, ',' );
|
184 |
+
$text = str_replace( ",", " / ", $text );
|
185 |
+
return $text;
|
186 |
+
}
|
187 |
+
|
188 |
+
public function fonttheme_generator() {
|
189 |
+
$option_name = 'typesquare_auth';
|
190 |
+
$nonce_key = TypeSquare_ST::OPTION_NAME;
|
191 |
+
echo "<div class='wrap'>";
|
192 |
+
echo '<h2>'. __( 'フォントテーマエディタ' , self::$text_domain ). '</h2>';
|
193 |
+
do_action( 'typesquare_add_setting_before' );
|
194 |
+
$auth_param = $this->get_auth_params();
|
195 |
+
if ( false !== $auth_param['typesquare_auth']['auth_status'] ) {
|
196 |
+
echo $this->get_font_select_form();
|
197 |
+
}
|
198 |
+
echo '</div>';
|
199 |
+
}
|
200 |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class TypeSquare_Admin_Root extends TypeSquare_Admin_Base {
|
3 |
+
private static $instance;
|
4 |
+
private static $text_domain;
|
5 |
+
private function __construct(){}
|
6 |
+
|
7 |
+
public static function get_instance() {
|
8 |
+
if ( ! isset( self::$instance ) ) {
|
9 |
+
$c = __CLASS__;
|
10 |
+
self::$instance = new $c();
|
11 |
+
}
|
12 |
+
return self::$instance;
|
13 |
+
}
|
14 |
+
|
15 |
+
public function typesquare_post_metabox() {
|
16 |
+
$fonts = TypeSquare_ST_Fonts::get_instance();
|
17 |
+
$param = $fonts->get_fonttheme_params();
|
18 |
+
if ( 'false' == $param['typesquare_themes']['show_post_form'] || ! $param['typesquare_themes']['show_post_form'] ) {
|
19 |
+
return;
|
20 |
+
}
|
21 |
+
$post_type = array( 'post', 'page' );
|
22 |
+
foreach ( $post_type as $type ) {
|
23 |
+
add_meta_box( 'typesquare_post_metabox', __( 'TypeSquare Webfonts for エックスサーバー', self::$text_domain ), array( $this, 'typesquare_post_metabox_inside' ), $type, 'advanced', 'low' );
|
24 |
+
}
|
25 |
+
}
|
26 |
+
|
27 |
+
public function typesquare_post_metabox_inside() {
|
28 |
+
$html = '';
|
29 |
+
$html .= '<p>'. __( 'この記事に適用するフォントを選択してください', self::$text_domain ) . '</p>';
|
30 |
+
|
31 |
+
$html .= $this->_get_post_font_theme_selector();
|
32 |
+
$html .= '<input type="hidden" name="typesquare_nonce_postmeta" id="typesquare_nonce_postmeta" value="' . wp_create_nonce( plugin_basename( __FILE__ ) ) . '" />';
|
33 |
+
echo $html;
|
34 |
+
}
|
35 |
+
|
36 |
+
private function _get_post_font_theme_selector() {
|
37 |
+
$html = '';
|
38 |
+
$fonts = TypeSquare_ST_Fonts::get_instance();
|
39 |
+
$all_font_theme = $fonts->load_all_font_data( );
|
40 |
+
$selected_theme = $fonts->get_selected_post_fonttheme( get_the_ID() );
|
41 |
+
$option = '';
|
42 |
+
$option .= "<option value='false'>テーマを設定しない</option>";
|
43 |
+
foreach ( $all_font_theme as $key => $fonttheme ) {
|
44 |
+
$fonttheme_name = $this->get_fonts_text( $fonttheme['name'] );
|
45 |
+
$font_text = $this->_get_fonttheme_text( $fonttheme );
|
46 |
+
$selected = '';
|
47 |
+
if ( $key === $selected_theme ) {
|
48 |
+
$selected = 'selected';
|
49 |
+
}
|
50 |
+
$option .= "<option value='{$key}' {$selected}>";
|
51 |
+
$option .= "{$fonttheme_name} ( {$font_text} )";
|
52 |
+
$option .= '</option>';
|
53 |
+
}
|
54 |
+
$html .= '<h3>'. __( 'フォントテーマから選ぶ', self::$text_domain ) . '</h3>';
|
55 |
+
$html .= "<select name='typesquare_fonttheme[theme]'>{$option}</select>";
|
56 |
+
return $html;
|
57 |
+
}
|
58 |
+
|
59 |
+
public function typesquare_save_post( $post_id ) {
|
60 |
+
if ( ! isset( $_POST['typesquare_nonce_postmeta'] ) ) {
|
61 |
+
return;
|
62 |
+
}
|
63 |
+
//Verify
|
64 |
+
if ( ! wp_verify_nonce( $_POST['typesquare_nonce_postmeta'], plugin_basename( __FILE__ ) ) ) {
|
65 |
+
return $post_id;
|
66 |
+
}
|
67 |
+
// if auto save
|
68 |
+
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
69 |
+
return $post_id;
|
70 |
+
}
|
71 |
+
|
72 |
+
// permission check
|
73 |
+
if ( 'page' == $_POST['post_type'] ) {
|
74 |
+
if ( ! current_user_can( 'edit_page', $post_id ) ) {
|
75 |
+
return $post_id;
|
76 |
+
}
|
77 |
+
} else {
|
78 |
+
if ( ! current_user_can( 'edit_post', $post_id ) ) {
|
79 |
+
return $post_id;
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
+
// save action
|
84 |
+
$fonttheme = $_POST['typesquare_fonttheme'];
|
85 |
+
$current_option = get_post_meta( $post_id, 'typesquare_fonttheme' );
|
86 |
+
$fonts = TypeSquare_ST_Fonts::get_instance();
|
87 |
+
if ( isset( $current_option[0] ) ) {
|
88 |
+
$current = $current_option[0];
|
89 |
+
} else {
|
90 |
+
$current = $fonttheme;
|
91 |
+
}
|
92 |
+
$font['theme'] = esc_attr( $fonttheme['theme'] );
|
93 |
+
update_post_meta( $post_id, 'typesquare_fonttheme', $font );
|
94 |
+
return $post_id;
|
95 |
+
}
|
96 |
+
|
97 |
+
private function get_fonts_text( $fonts ) {
|
98 |
+
if ( is_array( $fonts ) ) {
|
99 |
+
$text_font = '';
|
100 |
+
foreach ( $fonts as $key => $font ) {
|
101 |
+
$text_font .= esc_attr( $font );
|
102 |
+
if ( count( $fonts ) - 1 > $key ) {
|
103 |
+
$text_font .= ' + ';
|
104 |
+
}
|
105 |
+
}
|
106 |
+
} else {
|
107 |
+
$text_font = esc_attr( $fonts );
|
108 |
+
}
|
109 |
+
return $text_font;
|
110 |
+
}
|
111 |
+
|
112 |
+
public function typesquare_admin_menu() {
|
113 |
+
$param = $this->get_auth_params();
|
114 |
+
$option_name = 'typesquare_auth';
|
115 |
+
$nonce_key = TypeSquare_ST::OPTION_NAME;
|
116 |
+
echo "<div class='wrap'>";
|
117 |
+
echo '<h2>'. __( 'TypeSquare Webfonts Plugin for エックスサーバー' , self::$text_domain ). '</h2>';
|
118 |
+
do_action( 'typesquare_add_setting_before' );
|
119 |
+
$autho_param = $this->get_auth_params();
|
120 |
+
if ( false !== $autho_param['typesquare_auth']['auth_status'] ) {
|
121 |
+
echo $this->get_font_theme_form();
|
122 |
+
echo '<hr/>';
|
123 |
+
echo "<div class='ts-custome_form_row'>";
|
124 |
+
echo '<span><h3 class="toggleText toggleAdvanced mTop20">'. __( '上級者向けのカスタマイズ', self::$text_domain ). '<span class="advancedTriangle">▼</span></h3></span>';
|
125 |
+
echo "<div class='ts-custome_form hidden'>";
|
126 |
+
echo $this->get_font_target_form();
|
127 |
+
echo $this->update_font_list_form();
|
128 |
+
echo $this->_get_post_font_form();
|
129 |
+
echo '</div>';
|
130 |
+
echo '</div>';
|
131 |
+
}
|
132 |
+
do_action( 'typesquare_add_setting_after' );
|
133 |
+
}
|
134 |
+
|
135 |
+
private function _get_post_font_form() {
|
136 |
+
$option_name = 'typesquare_fonttheme';
|
137 |
+
$fonts = TypeSquare_ST_Fonts::get_instance();
|
138 |
+
$param = $fonts->get_fonttheme_params();
|
139 |
+
$keys = $param['typesquare_themes_keys'];
|
140 |
+
$html = '';
|
141 |
+
$html .= '<hr/>';
|
142 |
+
$html .= "<form method='post' action=''>";
|
143 |
+
$html .= '<h3>'. __( '個別記事フォント設定' , self::$text_domain ). '</h3>';
|
144 |
+
$html .= '<p>'. __( '個別記事作成画面にフォント設定を表示します。' , self::$text_domain ). '</p>';
|
145 |
+
$html .= wp_nonce_field( 'ts_update_font_settings' , 'ts_update_font_settings' , true , false );
|
146 |
+
$html .= "<table class='widefat form-table'>";
|
147 |
+
$html .= '<tbody>';
|
148 |
+
$html .= "<tr><th> {$keys['show_post_form']}</th><td>";
|
149 |
+
$value = esc_attr( $param['typesquare_themes']['show_post_form'] );
|
150 |
+
$html .= '<label>';
|
151 |
+
$html .= "<input name='{$option_name}[show_post_form]' type='hidden' id='show_post_form' value='false' class='code'/>";
|
152 |
+
$html .= "<input name='{$option_name}[show_post_form]' value='true' id='show_post_form' type='checkbox' class='code' ".checked( $value, 'true', true )."/>";
|
153 |
+
$html .= __( '有効化する' , self::$text_domain );
|
154 |
+
$html .= '</label>';
|
155 |
+
$html .= '<p>'. __( 'デフォルトではフォントテーマ設定が無効化されています。' , self::$text_domain ). '</p>';
|
156 |
+
$html .= '</td></tr>';
|
157 |
+
$html .= '<tr><th></th><td style="position: relative; left: -208px;">' . get_submit_button( __( '個別記事フォント設定を更新する', self::$text_domain ) ) . '</td></tr>';
|
158 |
+
$html .= '</tbody>';
|
159 |
+
$html .= '</table>';
|
160 |
+
$html .= '</form>';
|
161 |
+
return $html;
|
162 |
+
|
163 |
+
}
|
164 |
+
|
165 |
+
public function get_font_theme_form() {
|
166 |
+
$current = get_option('typesquare_fonttheme');
|
167 |
+
$options = get_option( 'typesquare_custom_theme' );
|
168 |
+
$edit_theme = false;
|
169 |
+
$display = 'display:none';
|
170 |
+
if ( isset( $_POST['typesquare_fonttheme']['font_theme'] ) ) {
|
171 |
+
$edit_theme = esc_attr( $_POST['typesquare_fonttheme']['font_theme'] );
|
172 |
+
$display = "";
|
173 |
+
}
|
174 |
+
$edit_theme = '';
|
175 |
+
if( isset($_POST['ts_change_edit_theme']) ){
|
176 |
+
$edit_theme = 'change';
|
177 |
+
}
|
178 |
+
$edit_mode = '';
|
179 |
+
if( isset( $_POST['ts_edit_mode'] ) ) {
|
180 |
+
$edit_mode = $_POST['ts_edit_mode'];
|
181 |
+
}
|
182 |
+
if($edit_theme === 'change'){$display = 'display:none';}
|
183 |
+
if($edit_mode === 'delete' || $edit_mode === 'new' || $edit_theme === 'false' || !$edit_theme || !$edit_theme){ $display = 'display:none'; }
|
184 |
+
else{$display = "";}
|
185 |
+
$option_name = 'typesquare_fonttheme';
|
186 |
+
$fonts = TypeSquare_ST_Fonts::get_instance();
|
187 |
+
$param = $fonts->get_fonttheme_params();
|
188 |
+
$all_font_theme = $fonts->load_all_font_data( );
|
189 |
+
$font_theme = TypeSquare_ST_Fonttheme::get_instance();
|
190 |
+
$custom_theme_json = $font_theme->get_custom_theme_json();
|
191 |
+
if ( $current['font_theme'] && $options['theme'][ $current['font_theme'] ] && $edit_mode !== 'new' ) { $display = ""; }
|
192 |
+
if( isset($_POST['typesquare_fonttheme']['font_theme']) && $_POST['typesquare_fonttheme']['font_theme'] !== 'new'){
|
193 |
+
$param['typesquare_themes']['font_theme'] = $_POST['typesquare_fonttheme']['font_theme'];
|
194 |
+
}
|
195 |
+
$html = '';
|
196 |
+
$html .= '<hr/>';
|
197 |
+
$html .= "<form method='post' action='' id='custmeFontForm'>";
|
198 |
+
$html .= '<h3>'. __( 'フォントテーマ設定' , self::$text_domain ). '</h3>';
|
199 |
+
$html .= '<p>'. __( 'フォントテーマを選択してください。' , self::$text_domain ). '<br/>';
|
200 |
+
$html .= '<strong>'. __( '※「新しくテーマを作成する」から、自由にフォントテーマを作成できます。' , self::$text_domain ). '</strong></p>';
|
201 |
+
$html .= wp_nonce_field( 'ts_update_font_settings' , 'ts_update_font_settings' , true , false );
|
202 |
+
$html .= "<table class='widefat form-table'>";
|
203 |
+
$html .= '<thead>';
|
204 |
+
$html .= "<tr><th> {$param['typesquare_themes_keys']['font_theme']}</th></tr>";
|
205 |
+
$html .= '</thead>';
|
206 |
+
$html .= '<tbody>';
|
207 |
+
$html .= '<tr><td>';
|
208 |
+
$html .= "<select id='fontThemeSelect' name='{$option_name}[font_theme]'>";
|
209 |
+
$html .= "<option value='false'>テーマを設定しない</option>";
|
210 |
+
$newSelect = '';
|
211 |
+
if($edit_mode === 'new'){
|
212 |
+
$newSelect = 'selected';
|
213 |
+
}
|
214 |
+
$html .= "<option value='new' {$newSelect}>新しくテーマを作成する</option>";
|
215 |
+
foreach ( $all_font_theme as $fonttheme_key => $fonttheme ) {
|
216 |
+
$fonttheme_name = esc_attr( $fonttheme['name'] );
|
217 |
+
$font_text = $this->_get_fonttheme_text( $fonttheme );
|
218 |
+
$selected = '';
|
219 |
+
if ( $fonttheme_key == $param['typesquare_themes']['font_theme'] && $fonttheme_key !== 'false' && !$newSelect ) {
|
220 |
+
$selected = 'selected';
|
221 |
+
}
|
222 |
+
$html .= "<option value='{$fonttheme_key}' {$selected}>";
|
223 |
+
$html .= "{$fonttheme_name} ( {$font_text} )";
|
224 |
+
$html .= '</option>';
|
225 |
+
}
|
226 |
+
$html .= '</select>';
|
227 |
+
$html .= $this->_get_custome_font_theme_list_form();
|
228 |
+
$html .= "<table>";
|
229 |
+
$html .= "<th>";
|
230 |
+
$html .= get_submit_button( __( 'フォントテーマを更新する', self::$text_domain ), 'primary', 'fontThemeUpdateButton');
|
231 |
+
$html .= "</th>";
|
232 |
+
$html .= "<th>";
|
233 |
+
$style = array("style"=>"margin-top:15px;".$display);
|
234 |
+
$html .= get_submit_button( __( 'フォントテーマを削除する', self::$text_domain ), 'delete', 'fontThemeDeleteButton', null, $style);
|
235 |
+
$html .= "</th>";
|
236 |
+
$html .= "</table>";
|
237 |
+
$html .= '<input type="hidden" name="typesquare_nonce_postmeta" id="typesquare_nonce_postmeta" value="' . wp_create_nonce( plugin_basename( __FILE__ ) ) . '" />';
|
238 |
+
$html .= '</td></tr>';
|
239 |
+
$html .= '</tbody>';
|
240 |
+
$html .= '</table>';
|
241 |
+
$html .= '</form>';
|
242 |
+
return $html;
|
243 |
+
}
|
244 |
+
|
245 |
+
public function _get_custome_font_theme_list_form() {
|
246 |
+
$options = get_option( 'typesquare_custom_theme' );
|
247 |
+
$current = get_option('typesquare_fonttheme');
|
248 |
+
$edit_theme = false;
|
249 |
+
$hidden = ' hidden';
|
250 |
+
$require = '';
|
251 |
+
if ( isset( $_POST['typesquare_fonttheme'] ) && isset( $_POST['ts_change_edit_theme'] ) ) {
|
252 |
+
$edit_theme = esc_attr( $_POST['typesquare_fonttheme']['font_theme'] );
|
253 |
+
$hidden = ' hidden';
|
254 |
+
}else if($current['font_theme'] && $current['font_theme'] !== 'false'){
|
255 |
+
$edit_theme = $current['font_theme'];
|
256 |
+
}
|
257 |
+
$fonts = TypeSquare_ST_Fonts::get_instance();
|
258 |
+
/* @TODO Debug Code
|
259 |
+
$option_name = 'typesquare_fonttheme';
|
260 |
+
$param = get_option( $option_name );
|
261 |
+
unset($param['fonts']);
|
262 |
+
update_option( $option_name, $param );
|
263 |
+
$param = $fonts->get_fonttheme_options();
|
264 |
+
*/
|
265 |
+
$edit_mode = '';
|
266 |
+
if( isset( $_POST['ts_edit_mode'] ) ) {
|
267 |
+
$edit_mode = $_POST['ts_edit_mode'];
|
268 |
+
}
|
269 |
+
$font_list = $theme_id = $theme_name = '';
|
270 |
+
if ( $edit_theme && $options['theme'][ $edit_theme ] ) {
|
271 |
+
$theme_name = $options['theme'][ $edit_theme ]['name'];
|
272 |
+
$theme_id = $options['theme'][ $edit_theme ]['id'];
|
273 |
+
$font_list = $options['fonts'][ $edit_theme ];
|
274 |
+
$hidden = ' ';
|
275 |
+
$edit_mode = 'update';
|
276 |
+
}
|
277 |
+
$html = '';
|
278 |
+
if ( $theme_id ) {
|
279 |
+
$theme_input = "<input type='hidden' id='ts_custome_theme_id' name='typesquare_custom_theme[id]' value='{$theme_id}' />";
|
280 |
+
$html .= "<input type='hidden' name='ts_edit_mode' value='update' />";
|
281 |
+
$html .= $theme_input;
|
282 |
+
} else {
|
283 |
+
$theme_id = uniqid();
|
284 |
+
$theme_input = false;
|
285 |
+
$html .= "<input type='hidden' name='ts_edit_mode' value='update' />";
|
286 |
+
if(!$edit_theme || !$edit_mode || $edit_theme === 'false' || $edit_mode === 'delete' || $edit_mode === 'update'){
|
287 |
+
$theme_id = '';
|
288 |
+
}
|
289 |
+
if($theme_id !== ''){
|
290 |
+
$html .= "<input type='hidden' id='ts_custome_theme_id' name='typesquare_custom_theme[id]' value='{$theme_id}' maxlength='16' style='width:100%;' pattern='^[0-9A-Za-z]+$' required/>";
|
291 |
+
}else {
|
292 |
+
$html .= '<input type="hidden" name="ts_custome_theme_id" id="typesquare_custom_theme[id]" value="' . wp_create_nonce( plugin_basename( __FILE__ ) ) . '" />';
|
293 |
+
}
|
294 |
+
}
|
295 |
+
if($edit_mode === 'new'){
|
296 |
+
$hidden = ' ';
|
297 |
+
}
|
298 |
+
if($edit_theme === 'new'){
|
299 |
+
$hidden = ' ';
|
300 |
+
}
|
301 |
+
if(!$edit_theme || !$edit_mode || $edit_theme === 'false' || $edit_mode === 'delete'){
|
302 |
+
$hidden = ' hidden';
|
303 |
+
}
|
304 |
+
if($hidden === ' '){
|
305 |
+
$require = 'required';
|
306 |
+
}
|
307 |
+
$html .= '<hr/>';
|
308 |
+
$html .= "<div id='customeFontThemeForm'{$hidden}>";
|
309 |
+
$html .= wp_nonce_field( 'ts_update_font_name_setting', 'ts_update_font_name_setting', true , false );
|
310 |
+
$html .= "<table class='widefat' style='border: 0px'>";
|
311 |
+
$html .= '<tbody>';
|
312 |
+
$html .= "<tr><th width='20%''>テーマタイトル</th><td>";
|
313 |
+
$html .= "<input type='hidden' id='current_custome_font_name' value='{$theme_name}'/>";
|
314 |
+
$html .= "<input type='text' id='custome_font_name' name='typesquare_custom_theme[name]' value='{$theme_name}' maxlength='16' style='width:30%;' {$require}/>";
|
315 |
+
$html .= '</td></tr>';
|
316 |
+
$html .= '</tbody>';
|
317 |
+
$html .= '</table>';
|
318 |
+
$html .= "<div id='ts-react-search-font'></div>";
|
319 |
+
$html .= "</div>";
|
320 |
+
$html .= $this->_get_script( $font_list );
|
321 |
+
return $html;
|
322 |
+
}
|
323 |
+
|
324 |
+
private function _get_script( $font_list ) {
|
325 |
+
$vars = "var form_id = '#". self::MENU_FONTTHEME. "';";
|
326 |
+
$vars .= "var notify_text = '". __( 'フォントを1種類以上選択してください。', self::$text_domain ). "';";
|
327 |
+
$vars .= "var unique_id ='". uniqid() ."';";
|
328 |
+
$options = get_option('typesquare_custom_theme');
|
329 |
+
$vars .= "var option_font_list = ". json_encode( $options ) .";";
|
330 |
+
$vars .= "var plugin_base = '".wp_create_nonce( plugin_basename( __FILE__ ) )."';";
|
331 |
+
$fonts = TypeSquare_ST_Fonts::get_instance();
|
332 |
+
$all_font_theme = $fonts->load_all_font_data( );
|
333 |
+
$vars .= 'var all_font_list = '. json_encode( $all_font_theme ) .';';
|
334 |
+
$script = <<<EOM
|
335 |
+
{$vars}
|
336 |
+
jQuery( document ).ready(function() {
|
337 |
+
jQuery( form_id ).submit(function() {
|
338 |
+
var title = jQuery( 'select[name="typesquare_custom_theme[fonts][title][font]"]' ).val();
|
339 |
+
var lead = jQuery( 'select[name="typesquare_custom_theme[fonts][lead][font]"]' ).val();
|
340 |
+
var text = jQuery( 'select[name="typesquare_custom_theme[fonts][text][font]"]' ).val();
|
341 |
+
var bold = jQuery( 'select[name="typesquare_custom_theme[fonts][bold][font]"]' ).val();
|
342 |
+
if (
|
343 |
+
title === 'false' &&
|
344 |
+
lead === 'false' &&
|
345 |
+
text === 'false' &&
|
346 |
+
bold === 'false'
|
347 |
+
) {
|
348 |
+
alert( notify_text );
|
349 |
+
return false;
|
350 |
+
}
|
351 |
+
});
|
352 |
+
});
|
353 |
+
EOM;
|
354 |
+
$html = '<script>';
|
355 |
+
$endpoint = path_join( TS_PLUGIN_URL , 'inc/font.json' );
|
356 |
+
$html .= "var json_endpoint = '{$endpoint}';";
|
357 |
+
if ( $font_list ) {
|
358 |
+
$html .= "var current_font = ". json_encode( $font_list ) .';';
|
359 |
+
} else {
|
360 |
+
$html .= "var current_font = false;";
|
361 |
+
}
|
362 |
+
$html .= $script;
|
363 |
+
$html .= '</script>';
|
364 |
+
return $html;
|
365 |
+
}
|
366 |
+
|
367 |
+
private function _get_fonttheme_text( $fonttheme ) {
|
368 |
+
$font_text = '';
|
369 |
+
if ( isset( $fonttheme['fonts']['title'] ) ) {
|
370 |
+
$font_text .= __( '見出し:', self::$text_domain );
|
371 |
+
$font_text .= $this->get_fonts_text( $fonttheme['fonts']['title'] );
|
372 |
+
$font_text .= ',';
|
373 |
+
}
|
374 |
+
if ( isset( $fonttheme['fonts']['lead'] ) ) {
|
375 |
+
$font_text .= __( 'リード:', self::$text_domain );
|
376 |
+
$font_text .= $this->get_fonts_text( $fonttheme['fonts']['lead'] );
|
377 |
+
$font_text .= ',';
|
378 |
+
}
|
379 |
+
if ( isset( $fonttheme['fonts']['content'] ) ) {
|
380 |
+
$font_text .= __( '本文:', self::$text_domain );
|
381 |
+
$font_text .= $this->get_fonts_text( $fonttheme['fonts']['content'] );
|
382 |
+
$font_text .= ',';
|
383 |
+
}
|
384 |
+
if ( isset( $fonttheme['fonts']['text'] ) ) {
|
385 |
+
$font_text .= __( '本文:', self::$text_domain );
|
386 |
+
$font_text .= $this->get_fonts_text( $fonttheme['fonts']['text'] );
|
387 |
+
$font_text .= ',';
|
388 |
+
}
|
389 |
+
if ( isset( $fonttheme['fonts']['bold'] ) ) {
|
390 |
+
$font_text .= __( '太字:', self::$text_domain );
|
391 |
+
$font_text .= $this->get_fonts_text( $fonttheme['fonts']['bold'] );
|
392 |
+
}
|
393 |
+
$font_text = rtrim( $font_text, ',' );
|
394 |
+
$font_text = str_replace( ",", " / ", $font_text );
|
395 |
+
return $font_text;
|
396 |
+
}
|
397 |
+
|
398 |
+
public function get_font_target_form() {
|
399 |
+
$fonts = TypeSquare_ST_Fonts::get_instance();
|
400 |
+
$param = $fonts->get_fonttheme_params();
|
401 |
+
$html = '';
|
402 |
+
$html .= "<form method='post' action=''>";
|
403 |
+
$html .= '<h3>'. __( 'フォント設定クラス' , self::$text_domain ). '</h3>';
|
404 |
+
$html .= '<p>'. __( 'フォントを適用するクラスを指定します。' , self::$text_domain ). '</p>';
|
405 |
+
$html .= "<table class='widefat form-table'>";
|
406 |
+
$html .= '<thead>';
|
407 |
+
$key = $param['typesquare_themes_keys'];
|
408 |
+
$html .= "<tr><th> {$key['title_target']}</th><th> {$key['lead_target']}</th><th> {$key['text_target']}</th><th> {$key['bold_target']}</th></tr>";
|
409 |
+
$html .= '</thead>';
|
410 |
+
$html .= '<tbody>';
|
411 |
+
$data = $param['typesquare_themes'];
|
412 |
+
$html .= "<tr><td><input type='text' name='typesquare_fonttheme[title_target]' value='{$data['title_target']}' required/></td>";
|
413 |
+
$html .= "<td><input type='text' name='typesquare_fonttheme[lead_target]' value='{$data['lead_target']}' required/></td>";
|
414 |
+
$html .= "<td><input type='text' name='typesquare_fonttheme[text_target]' value='{$data['text_target']}' required/></td>";
|
415 |
+
$html .= "<td><input type='text' name='typesquare_fonttheme[bold_target]' value='{$data['bold_target']}' required/></td></tr>";
|
416 |
+
$html .= "<tr><td>";
|
417 |
+
$html .= get_submit_button( __( '設定クラスを更新する', self::$text_domain ) );
|
418 |
+
$html .= "</td></tr>";
|
419 |
+
$html .= '</tbody>';
|
420 |
+
$html .= '</table>';
|
421 |
+
$html .= wp_nonce_field( 'ts_update_font_settings' , 'ts_update_font_settings' , true , false );
|
422 |
+
$html .= '</form>';
|
423 |
+
return $html;
|
424 |
+
}
|
425 |
+
|
426 |
+
public function update_font_list_form() {
|
427 |
+
$fonts = TypeSquare_ST_Fonts::get_instance();
|
428 |
+
$auth_param = $this->get_auth_params();
|
429 |
+
if ( false == $auth_param['typesquare_auth']['api_status'] ) {
|
430 |
+
return;
|
431 |
+
}
|
432 |
+
$font_file_path = path_join( TS_PLUGIN_PATH , 'inc/font.json' );
|
433 |
+
$param = date("y/m/d", filemtime($font_file_path));
|
434 |
+
$html = '';
|
435 |
+
$html .= "<form method='post' action=''>";
|
436 |
+
$html .= '<h3>'. __( 'フォント一覧の更新' , self::$text_domain ). '</h3>';
|
437 |
+
$html .= '<p>'. __( '利用可能フォントの一覧を最新版に更新します。' , self::$text_domain ). '</p>';
|
438 |
+
$html .= "<table class='widefat form-table'>";
|
439 |
+
$html .= '<thead>';
|
440 |
+
$html .= "<tr></tr>";
|
441 |
+
$html .= '</thead>';
|
442 |
+
$html .= "<tbody>";
|
443 |
+
$html .= "<tr><td style='width: 1%;'>".get_submit_button( __( 'フォント一覧を更新する', self::$text_domain ) )."</td>";
|
444 |
+
$html .= "<td>最終更新日: ".$param."</td></tr>";
|
445 |
+
$html .= '</tbody>';
|
446 |
+
$html .= '</table>';
|
447 |
+
$html .= wp_nonce_field( 'ts_update_font_list' , 'ts_update_font_list' , true , false );
|
448 |
+
$html .= '</form>';
|
449 |
+
return $html;
|
450 |
+
}
|
451 |
+
|
452 |
+
}
|
inc/app.js
ADDED
@@ -0,0 +1,30072 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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