Version Description
- [ G3 ][ Specification Change ] Add filter vk_term_color_taxonomy / vk_get_single_term_with_color / vk_post_view
Download this release
Release Info
Developer | kurudrive |
Plugin | VK All in One Expansion Unit |
Version | 9.65.0.0 |
Comparing to | |
See all releases |
Code changes from version 9.64.5.0 to 9.65.0.0
- composer.json +3 -1
- composer.lock +73 -20
- inc/call-to-action/package/class-vk-call-to-action.php +30 -20
- inc/sns/sns.php +2 -2
- inc/sns/sns_customizer.php +20 -19
- inc/term-color/package/class.term-color.php +123 -88
- package-lock.json +3 -3
- package.json +1 -1
- phpunit.xml +1 -0
- phpunit.xml.dist +1 -0
- readme.txt +12 -6
- tests/test-cta-default-display.php +54 -0
- tests/test-cta.php +90 -0
- vkExUnit.php +1 -1
composer.json
CHANGED
@@ -7,7 +7,9 @@
|
|
7 |
"email": "info@vektor-inc.co.jp"
|
8 |
}
|
9 |
],
|
10 |
-
"require": {
|
|
|
|
|
11 |
"require-dev": {
|
12 |
"sirbrillig/phpcs-variable-analysis": "^2.8",
|
13 |
"wp-phpunit/wp-phpunit": "^5.4"
|
7 |
"email": "info@vektor-inc.co.jp"
|
8 |
}
|
9 |
],
|
10 |
+
"require": {
|
11 |
+
"vektor-inc/vk-wp-unit-test-tools": "^0.10.0"
|
12 |
+
},
|
13 |
"require-dev": {
|
14 |
"sirbrillig/phpcs-variable-analysis": "^2.8",
|
15 |
"wp-phpunit/wp-phpunit": "^5.4"
|
composer.lock
CHANGED
@@ -4,29 +4,67 @@
|
|
4 |
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
5 |
"This file is @generated automatically"
|
6 |
],
|
7 |
-
"content-hash": "
|
8 |
-
"packages": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
"packages-dev": [
|
10 |
{
|
11 |
"name": "sirbrillig/phpcs-variable-analysis",
|
12 |
-
"version": "v2.
|
13 |
"source": {
|
14 |
"type": "git",
|
15 |
"url": "https://github.com/sirbrillig/phpcs-variable-analysis.git",
|
16 |
-
"reference": "
|
17 |
},
|
18 |
"dist": {
|
19 |
"type": "zip",
|
20 |
-
"url": "https://api.github.com/repos/sirbrillig/phpcs-variable-analysis/zipball/
|
21 |
-
"reference": "
|
22 |
"shasum": ""
|
23 |
},
|
24 |
"require": {
|
25 |
"php": ">=5.4.0",
|
26 |
-
"squizlabs/php_codesniffer": "^3.
|
27 |
},
|
28 |
"require-dev": {
|
29 |
-
"dealerdirect/phpcodesniffer-composer-installer": "^0.
|
30 |
"limedeck/phpunit-detailed-printer": "^3.1 || ^4.0 || ^5.0",
|
31 |
"phpstan/phpstan": "^0.11.8",
|
32 |
"phpunit/phpunit": "^5.0 || ^6.5 || ^7.0 || ^8.0",
|
@@ -53,20 +91,25 @@
|
|
53 |
}
|
54 |
],
|
55 |
"description": "A PHPCS sniff to detect problems with variables.",
|
56 |
-
"
|
|
|
|
|
|
|
|
|
|
|
57 |
},
|
58 |
{
|
59 |
"name": "squizlabs/php_codesniffer",
|
60 |
-
"version": "3.
|
61 |
"source": {
|
62 |
"type": "git",
|
63 |
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
|
64 |
-
"reference": "
|
65 |
},
|
66 |
"dist": {
|
67 |
"type": "zip",
|
68 |
-
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/
|
69 |
-
"reference": "
|
70 |
"shasum": ""
|
71 |
},
|
72 |
"require": {
|
@@ -104,20 +147,25 @@
|
|
104 |
"phpcs",
|
105 |
"standards"
|
106 |
],
|
107 |
-
"
|
|
|
|
|
|
|
|
|
|
|
108 |
},
|
109 |
{
|
110 |
"name": "wp-phpunit/wp-phpunit",
|
111 |
-
"version": "5.
|
112 |
"source": {
|
113 |
"type": "git",
|
114 |
"url": "https://github.com/wp-phpunit/wp-phpunit.git",
|
115 |
-
"reference": "
|
116 |
},
|
117 |
"dist": {
|
118 |
"type": "zip",
|
119 |
-
"url": "https://api.github.com/repos/wp-phpunit/wp-phpunit/zipball/
|
120 |
-
"reference": "
|
121 |
"shasum": ""
|
122 |
},
|
123 |
"type": "library",
|
@@ -147,7 +195,12 @@
|
|
147 |
"test",
|
148 |
"wordpress"
|
149 |
],
|
150 |
-
"
|
|
|
|
|
|
|
|
|
|
|
151 |
}
|
152 |
],
|
153 |
"aliases": [],
|
@@ -157,5 +210,5 @@
|
|
157 |
"prefer-lowest": false,
|
158 |
"platform": [],
|
159 |
"platform-dev": [],
|
160 |
-
"plugin-api-version": "
|
161 |
}
|
4 |
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
5 |
"This file is @generated automatically"
|
6 |
],
|
7 |
+
"content-hash": "a4713ab3458ea05407ce9192c100291e",
|
8 |
+
"packages": [
|
9 |
+
{
|
10 |
+
"name": "vektor-inc/vk-wp-unit-test-tools",
|
11 |
+
"version": "0.10.0",
|
12 |
+
"source": {
|
13 |
+
"type": "git",
|
14 |
+
"url": "https://github.com/vektor-inc/vk-wp-unit-test-tools.git",
|
15 |
+
"reference": "5ce9eb397ba1ec76193664e6877288ffa22b9422"
|
16 |
+
},
|
17 |
+
"dist": {
|
18 |
+
"type": "zip",
|
19 |
+
"url": "https://api.github.com/repos/vektor-inc/vk-wp-unit-test-tools/zipball/5ce9eb397ba1ec76193664e6877288ffa22b9422",
|
20 |
+
"reference": "5ce9eb397ba1ec76193664e6877288ffa22b9422",
|
21 |
+
"shasum": ""
|
22 |
+
},
|
23 |
+
"type": "library",
|
24 |
+
"autoload": {
|
25 |
+
"psr-4": {
|
26 |
+
"VK_WP_Unit_Test_Tools\\": "src/"
|
27 |
+
}
|
28 |
+
},
|
29 |
+
"notification-url": "https://packagist.org/downloads/",
|
30 |
+
"license": [
|
31 |
+
"MIT"
|
32 |
+
],
|
33 |
+
"authors": [
|
34 |
+
{
|
35 |
+
"name": "kurudrive",
|
36 |
+
"email": "kurudrive@gmail.com"
|
37 |
+
}
|
38 |
+
],
|
39 |
+
"description": "WordPress PHPUnit test tools",
|
40 |
+
"support": {
|
41 |
+
"issues": "https://github.com/vektor-inc/vk-wp-unit-test-tools/issues",
|
42 |
+
"source": "https://github.com/vektor-inc/vk-wp-unit-test-tools/tree/0.10.0"
|
43 |
+
},
|
44 |
+
"time": "2021-09-03T10:14:12+00:00"
|
45 |
+
}
|
46 |
+
],
|
47 |
"packages-dev": [
|
48 |
{
|
49 |
"name": "sirbrillig/phpcs-variable-analysis",
|
50 |
+
"version": "v2.11.2",
|
51 |
"source": {
|
52 |
"type": "git",
|
53 |
"url": "https://github.com/sirbrillig/phpcs-variable-analysis.git",
|
54 |
+
"reference": "3fad28475bfbdbf8aa5c440f8a8f89824983d85e"
|
55 |
},
|
56 |
"dist": {
|
57 |
"type": "zip",
|
58 |
+
"url": "https://api.github.com/repos/sirbrillig/phpcs-variable-analysis/zipball/3fad28475bfbdbf8aa5c440f8a8f89824983d85e",
|
59 |
+
"reference": "3fad28475bfbdbf8aa5c440f8a8f89824983d85e",
|
60 |
"shasum": ""
|
61 |
},
|
62 |
"require": {
|
63 |
"php": ">=5.4.0",
|
64 |
+
"squizlabs/php_codesniffer": "^3.5"
|
65 |
},
|
66 |
"require-dev": {
|
67 |
+
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
|
68 |
"limedeck/phpunit-detailed-printer": "^3.1 || ^4.0 || ^5.0",
|
69 |
"phpstan/phpstan": "^0.11.8",
|
70 |
"phpunit/phpunit": "^5.0 || ^6.5 || ^7.0 || ^8.0",
|
91 |
}
|
92 |
],
|
93 |
"description": "A PHPCS sniff to detect problems with variables.",
|
94 |
+
"support": {
|
95 |
+
"issues": "https://github.com/sirbrillig/phpcs-variable-analysis/issues",
|
96 |
+
"source": "https://github.com/sirbrillig/phpcs-variable-analysis",
|
97 |
+
"wiki": "https://github.com/sirbrillig/phpcs-variable-analysis/wiki"
|
98 |
+
},
|
99 |
+
"time": "2021-07-06T23:45:17+00:00"
|
100 |
},
|
101 |
{
|
102 |
"name": "squizlabs/php_codesniffer",
|
103 |
+
"version": "3.6.0",
|
104 |
"source": {
|
105 |
"type": "git",
|
106 |
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
|
107 |
+
"reference": "ffced0d2c8fa8e6cdc4d695a743271fab6c38625"
|
108 |
},
|
109 |
"dist": {
|
110 |
"type": "zip",
|
111 |
+
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ffced0d2c8fa8e6cdc4d695a743271fab6c38625",
|
112 |
+
"reference": "ffced0d2c8fa8e6cdc4d695a743271fab6c38625",
|
113 |
"shasum": ""
|
114 |
},
|
115 |
"require": {
|
147 |
"phpcs",
|
148 |
"standards"
|
149 |
],
|
150 |
+
"support": {
|
151 |
+
"issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues",
|
152 |
+
"source": "https://github.com/squizlabs/PHP_CodeSniffer",
|
153 |
+
"wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki"
|
154 |
+
},
|
155 |
+
"time": "2021-04-09T00:54:41+00:00"
|
156 |
},
|
157 |
{
|
158 |
"name": "wp-phpunit/wp-phpunit",
|
159 |
+
"version": "5.8.0",
|
160 |
"source": {
|
161 |
"type": "git",
|
162 |
"url": "https://github.com/wp-phpunit/wp-phpunit.git",
|
163 |
+
"reference": "da3f6fc3bc5cae2c76af6f9a260620fc4f8d9f90"
|
164 |
},
|
165 |
"dist": {
|
166 |
"type": "zip",
|
167 |
+
"url": "https://api.github.com/repos/wp-phpunit/wp-phpunit/zipball/da3f6fc3bc5cae2c76af6f9a260620fc4f8d9f90",
|
168 |
+
"reference": "da3f6fc3bc5cae2c76af6f9a260620fc4f8d9f90",
|
169 |
"shasum": ""
|
170 |
},
|
171 |
"type": "library",
|
195 |
"test",
|
196 |
"wordpress"
|
197 |
],
|
198 |
+
"support": {
|
199 |
+
"docs": "https://github.com/wp-phpunit/docs",
|
200 |
+
"issues": "https://github.com/wp-phpunit/issues",
|
201 |
+
"source": "https://github.com/wp-phpunit/wp-phpunit"
|
202 |
+
},
|
203 |
+
"time": "2021-07-27T09:32:49+00:00"
|
204 |
}
|
205 |
],
|
206 |
"aliases": [],
|
210 |
"prefer-lowest": false,
|
211 |
"platform": [],
|
212 |
"platform-dev": [],
|
213 |
+
"plugin-api-version": "2.1.0"
|
214 |
}
|
inc/call-to-action/package/class-vk-call-to-action.php
CHANGED
@@ -70,6 +70,11 @@ if ( ! class_exists( 'Vk_Call_To_Action' ) ) {
|
|
70 |
);
|
71 |
}
|
72 |
|
|
|
|
|
|
|
|
|
|
|
73 |
public static function set_posttype() {
|
74 |
|
75 |
$labels = array(
|
@@ -100,10 +105,14 @@ if ( ! class_exists( 'Vk_Call_To_Action' ) ) {
|
|
100 |
register_post_type( self::POST_TYPE, $args );
|
101 |
}
|
102 |
|
103 |
-
|
|
|
|
|
|
|
|
|
104 |
public static function add_metabox_cta_register() {
|
105 |
|
106 |
-
// Meta box of CTA edit and register page
|
107 |
add_meta_box( 'vkExUnit_cta_url', __( 'CTA Contents', 'vk-all-in-one-expansion-unit' ), array( __CLASS__, 'render_meta_box_cta' ), self::POST_TYPE, 'normal', 'high' );
|
108 |
}
|
109 |
|
@@ -119,7 +128,7 @@ if ( ! class_exists( 'Vk_Call_To_Action' ) ) {
|
|
119 |
return $post_id; }
|
120 |
$noonce = isset( $_POST['_nonce_vkExUnit_custom_cta'] ) ? htmlspecialchars( $_POST['_nonce_vkExUnit_custom_cta'] ) : null;
|
121 |
|
122 |
-
// if autosave is to deny
|
123 |
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
124 |
return $post_id; }
|
125 |
|
@@ -127,18 +136,18 @@ if ( ! class_exists( 'Vk_Call_To_Action' ) ) {
|
|
127 |
return $post_id;
|
128 |
}
|
129 |
|
130 |
-
if ( $_POST['_vkExUnit_cta_switch']
|
131 |
$data = $_POST['vkexunit_cta_each_option'];
|
132 |
|
133 |
if ( get_post_meta( $post_id, 'vkexunit_cta_each_option' ) == '' ) {
|
134 |
add_post_meta( $post_id, 'vkexunit_cta_each_option', $data, true );
|
135 |
-
} elseif (
|
136 |
update_post_meta( $post_id, 'vkexunit_cta_each_option', $data );
|
137 |
} elseif ( ! $data ) {
|
138 |
delete_post_meta( $post_id, 'vkexunit_cta_each_option', get_post_meta( $post_id, 'vkexunit_cta_each_option', true ) );
|
139 |
}
|
140 |
return $post_id;
|
141 |
-
} elseif ( $_POST['_vkExUnit_cta_switch']
|
142 |
|
143 |
// カスタムフィールドの設定.
|
144 |
$custom_fields = array(
|
@@ -199,7 +208,7 @@ if ( ! class_exists( 'Vk_Call_To_Action' ) ) {
|
|
199 |
|
200 |
return $post_id;
|
201 |
}
|
202 |
-
}
|
203 |
|
204 |
/**
|
205 |
* [widget_init description]
|
@@ -296,19 +305,19 @@ if ( ! class_exists( 'Vk_Call_To_Action' ) ) {
|
|
296 |
<td>
|
297 |
<?php
|
298 |
$target_blank = get_post_meta( get_the_id(), 'vkExUnit_cta_use_type', true );
|
299 |
-
if (
|
300 |
$checked = ' checked';
|
301 |
} else {
|
302 |
$checked = '';
|
303 |
}
|
304 |
?>
|
305 |
-
<input type="checkbox" id="vkExUnit_cta_use_type" name="vkExUnit_cta_use_type" value="veu_cta_normal"<?php echo $checked; ?> />
|
306 |
<label for="vkExUnit_cta_use_type"><?php _e( 'Use following data (Do not use content data)', 'vk-all-in-one-expansion-unit' ); ?></label>
|
307 |
</td>
|
308 |
</tr>
|
309 |
|
310 |
<tr>
|
311 |
-
<th><?php
|
312 |
<td>
|
313 |
<div id="cta-thumbnail_box" >
|
314 |
<img id="cta-thumbnail_image" src="<?php echo ( $cta_image ) ? $cta_image[0] : ''; ?>" class="<?php echo ( $cta_image ) ? '' : 'noimage'; ?>" />
|
@@ -387,16 +396,17 @@ if ( ! class_exists( 'Vk_Call_To_Action' ) ) {
|
|
387 |
|
388 |
|
389 |
/**
|
390 |
-
*
|
391 |
*
|
392 |
-
* @param
|
393 |
-
* @return
|
394 |
*/
|
395 |
public static function get_cta_post( $id ) {
|
396 |
$args = array(
|
397 |
-
'post_type'
|
398 |
-
'p'
|
399 |
-
'post_count'
|
|
|
400 |
);
|
401 |
$query = new \WP_Query( $args );
|
402 |
if ( ! $query->post_count ) {
|
@@ -448,7 +458,7 @@ if ( ! class_exists( 'Vk_Call_To_Action' ) ) {
|
|
448 |
$content .= '<div class="veu_adminEdit"><a href="' . $url . '" class="btn btn-default" target="_blank">' . __( 'Edit CTA', 'vk-all-in-one-expansion-unit' ) . '</a></div>';
|
449 |
}
|
450 |
|
451 |
-
// リセットしないと$post
|
452 |
wp_reset_postdata();
|
453 |
|
454 |
// wp_kses_post でエスケープすると outerブロックが出力するstyle属性を無効化される.
|
@@ -604,7 +614,7 @@ if ( ! class_exists( 'Vk_Call_To_Action' ) ) {
|
|
604 |
)
|
605 |
);
|
606 |
foreach ( $posttypes as $key => $posttype ) {
|
607 |
-
$option[ $posttype ] =
|
608 |
}
|
609 |
return $option;
|
610 |
}
|
@@ -669,7 +679,7 @@ if ( ! class_exists( 'Vk_Call_To_Action' ) ) {
|
|
669 |
$options = self::get_option();
|
670 |
$ctas = self::get_ctas( true, ' - ' );
|
671 |
|
672 |
-
//
|
673 |
array_unshift(
|
674 |
$ctas,
|
675 |
array(
|
@@ -677,7 +687,7 @@ if ( ! class_exists( 'Vk_Call_To_Action' ) ) {
|
|
677 |
'label' => __( 'Random', 'vk-all-in-one-expansion-unit' ),
|
678 |
)
|
679 |
);
|
680 |
-
//
|
681 |
array_unshift(
|
682 |
$ctas,
|
683 |
array(
|
70 |
);
|
71 |
}
|
72 |
|
73 |
+
/**
|
74 |
+
* Set CTA Post Type
|
75 |
+
*
|
76 |
+
* @return void
|
77 |
+
*/
|
78 |
public static function set_posttype() {
|
79 |
|
80 |
$labels = array(
|
105 |
register_post_type( self::POST_TYPE, $args );
|
106 |
}
|
107 |
|
108 |
+
/**
|
109 |
+
* Add CTA Metabox
|
110 |
+
*
|
111 |
+
* @return void
|
112 |
+
*/
|
113 |
public static function add_metabox_cta_register() {
|
114 |
|
115 |
+
// Meta box of CTA edit and register page.
|
116 |
add_meta_box( 'vkExUnit_cta_url', __( 'CTA Contents', 'vk-all-in-one-expansion-unit' ), array( __CLASS__, 'render_meta_box_cta' ), self::POST_TYPE, 'normal', 'high' );
|
117 |
}
|
118 |
|
128 |
return $post_id; }
|
129 |
$noonce = isset( $_POST['_nonce_vkExUnit_custom_cta'] ) ? htmlspecialchars( $_POST['_nonce_vkExUnit_custom_cta'] ) : null;
|
130 |
|
131 |
+
// if autosave is to deny.
|
132 |
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
133 |
return $post_id; }
|
134 |
|
136 |
return $post_id;
|
137 |
}
|
138 |
|
139 |
+
if ( 'cta_number' === $_POST['_vkExUnit_cta_switch'] ) {
|
140 |
$data = $_POST['vkexunit_cta_each_option'];
|
141 |
|
142 |
if ( get_post_meta( $post_id, 'vkexunit_cta_each_option' ) == '' ) {
|
143 |
add_post_meta( $post_id, 'vkexunit_cta_each_option', $data, true );
|
144 |
+
} elseif ( get_post_meta( $post_id, 'vkexunit_cta_each_option', true ) !== $data ) {
|
145 |
update_post_meta( $post_id, 'vkexunit_cta_each_option', $data );
|
146 |
} elseif ( ! $data ) {
|
147 |
delete_post_meta( $post_id, 'vkexunit_cta_each_option', get_post_meta( $post_id, 'vkexunit_cta_each_option', true ) );
|
148 |
}
|
149 |
return $post_id;
|
150 |
+
} elseif ( 'cta_content' === $_POST['_vkExUnit_cta_switch'] ) {
|
151 |
|
152 |
// カスタムフィールドの設定.
|
153 |
$custom_fields = array(
|
208 |
|
209 |
return $post_id;
|
210 |
}
|
211 |
+
}
|
212 |
|
213 |
/**
|
214 |
* [widget_init description]
|
305 |
<td>
|
306 |
<?php
|
307 |
$target_blank = get_post_meta( get_the_id(), 'vkExUnit_cta_use_type', true );
|
308 |
+
if ( 'veu_cta_normal' === $target_blank ) {
|
309 |
$checked = ' checked';
|
310 |
} else {
|
311 |
$checked = '';
|
312 |
}
|
313 |
?>
|
314 |
+
<input type="checkbox" id="vkExUnit_cta_use_type" name="vkExUnit_cta_use_type" value="veu_cta_normal"<?php echo esc_attr( $checked ); ?> />
|
315 |
<label for="vkExUnit_cta_use_type"><?php _e( 'Use following data (Do not use content data)', 'vk-all-in-one-expansion-unit' ); ?></label>
|
316 |
</td>
|
317 |
</tr>
|
318 |
|
319 |
<tr>
|
320 |
+
<th><?php esc_html_e( 'CTA image', 'vk-all-in-one-expansion-unit' ); ?></th>
|
321 |
<td>
|
322 |
<div id="cta-thumbnail_box" >
|
323 |
<img id="cta-thumbnail_image" src="<?php echo ( $cta_image ) ? $cta_image[0] : ''; ?>" class="<?php echo ( $cta_image ) ? '' : 'noimage'; ?>" />
|
396 |
|
397 |
|
398 |
/**
|
399 |
+
* Get CTA Post
|
400 |
*
|
401 |
+
* @param int $id post_id of CTA.
|
402 |
+
* @return object CTA $post object.
|
403 |
*/
|
404 |
public static function get_cta_post( $id ) {
|
405 |
$args = array(
|
406 |
+
'post_type' => self::POST_TYPE,
|
407 |
+
'p' => $id,
|
408 |
+
'post_count' => 1,
|
409 |
+
'post_status' => array( 'publish' ),
|
410 |
);
|
411 |
$query = new \WP_Query( $args );
|
412 |
if ( ! $query->post_count ) {
|
458 |
$content .= '<div class="veu_adminEdit"><a href="' . $url . '" class="btn btn-default" target="_blank">' . __( 'Edit CTA', 'vk-all-in-one-expansion-unit' ) . '</a></div>';
|
459 |
}
|
460 |
|
461 |
+
// リセットしないと$postが改変されたままでコメント欄が表示されなくなるなどの弊害が発生する.
|
462 |
wp_reset_postdata();
|
463 |
|
464 |
// wp_kses_post でエスケープすると outerブロックが出力するstyle属性を無効化される.
|
614 |
)
|
615 |
);
|
616 |
foreach ( $posttypes as $key => $posttype ) {
|
617 |
+
$option[ $posttype ] = '0';
|
618 |
}
|
619 |
return $option;
|
620 |
}
|
679 |
$options = self::get_option();
|
680 |
$ctas = self::get_ctas( true, ' - ' );
|
681 |
|
682 |
+
// ランダムを先頭に追加.
|
683 |
array_unshift(
|
684 |
$ctas,
|
685 |
array(
|
687 |
'label' => __( 'Random', 'vk-all-in-one-expansion-unit' ),
|
688 |
)
|
689 |
);
|
690 |
+
// 表示しないを先頭に追加.
|
691 |
array_unshift(
|
692 |
$ctas,
|
693 |
array(
|
inc/sns/sns.php
CHANGED
@@ -72,8 +72,8 @@ function veu_get_sns_options_default() {
|
|
72 |
'enableTwitterCardTags' => true,
|
73 |
'enableSnsBtns' => true,
|
74 |
'snsBtn_exclude_post_types' => array(
|
75 |
-
'post' =>
|
76 |
-
'page' =>
|
77 |
),
|
78 |
'snsBtn_position' => array(
|
79 |
'before' => false,
|
72 |
'enableTwitterCardTags' => true,
|
73 |
'enableSnsBtns' => true,
|
74 |
'snsBtn_exclude_post_types' => array(
|
75 |
+
'post' => false,
|
76 |
+
'page' => false,
|
77 |
),
|
78 |
'snsBtn_position' => array(
|
79 |
'before' => false,
|
inc/sns/sns_customizer.php
CHANGED
@@ -12,6 +12,7 @@ if ( apply_filters( 'veu_customize_panel_activation', false ) ) {
|
|
12 |
}
|
13 |
|
14 |
function veu_customize_register_sns( $wp_customize ) {
|
|
|
15 |
/*
|
16 |
SNS Settings
|
17 |
/*-------------------------------------------*/
|
@@ -45,7 +46,7 @@ function veu_customize_register_sns( $wp_customize ) {
|
|
45 |
$wp_customize->add_setting(
|
46 |
'vkExUnit_sns_options[snsTitle_use_only_postTitle]',
|
47 |
array(
|
48 |
-
'default' =>
|
49 |
'type' => 'option', // 保存先 option or theme_mod
|
50 |
'capability' => 'edit_theme_options',
|
51 |
'sanitize_callback' => 'veu_sanitize_boolean',
|
@@ -84,7 +85,7 @@ function veu_customize_register_sns( $wp_customize ) {
|
|
84 |
$wp_customize->add_setting(
|
85 |
'vkExUnit_sns_options[fbAppId]',
|
86 |
array(
|
87 |
-
'default' => '',
|
88 |
'type' => 'option', // 保存先 option or theme_mod
|
89 |
'capability' => 'edit_theme_options',
|
90 |
'sanitize_callback' => 'sanitize_text_field',
|
@@ -105,7 +106,7 @@ function veu_customize_register_sns( $wp_customize ) {
|
|
105 |
$wp_customize->add_setting(
|
106 |
'vkExUnit_sns_options[fbPageUrl]',
|
107 |
array(
|
108 |
-
'default' => '',
|
109 |
'type' => 'option', // 保存先 option or theme_mod
|
110 |
'capability' => 'edit_theme_options',
|
111 |
'sanitize_callback' => 'sanitize_text_field',
|
@@ -126,7 +127,7 @@ function veu_customize_register_sns( $wp_customize ) {
|
|
126 |
$wp_customize->add_setting(
|
127 |
'vkExUnit_sns_options[ogImage]',
|
128 |
array(
|
129 |
-
'default' => '',
|
130 |
'type' => 'option',
|
131 |
'capability' => 'edit_theme_options',
|
132 |
'sanitize_callback' => 'esc_url_raw',
|
@@ -167,7 +168,7 @@ function veu_customize_register_sns( $wp_customize ) {
|
|
167 |
$wp_customize->add_setting(
|
168 |
'vkExUnit_sns_options[enableOGTags]',
|
169 |
array(
|
170 |
-
'default' =>
|
171 |
'type' => 'option', // 保存先 option or theme_mod
|
172 |
'capability' => 'edit_theme_options',
|
173 |
'sanitize_callback' => 'veu_sanitize_boolean',
|
@@ -206,7 +207,7 @@ function veu_customize_register_sns( $wp_customize ) {
|
|
206 |
$wp_customize->add_setting(
|
207 |
'vkExUnit_sns_options[twitterId]',
|
208 |
array(
|
209 |
-
'default' => '',
|
210 |
'type' => 'option', // 保存先 option or theme_mod
|
211 |
'capability' => 'edit_theme_options',
|
212 |
'sanitize_callback' => 'sanitize_text_field',
|
@@ -230,7 +231,7 @@ function veu_customize_register_sns( $wp_customize ) {
|
|
230 |
$wp_customize->add_setting(
|
231 |
'vkExUnit_sns_options[enableTwitterCardTags]',
|
232 |
array(
|
233 |
-
'default' =>
|
234 |
'type' => 'option', // 保存先 option or theme_mod
|
235 |
'capability' => 'edit_theme_options',
|
236 |
'sanitize_callback' => 'veu_sanitize_boolean',
|
@@ -270,7 +271,7 @@ function veu_customize_register_sns( $wp_customize ) {
|
|
270 |
$wp_customize->add_setting(
|
271 |
'vkExUnit_sns_options[enableSnsBtns]',
|
272 |
array(
|
273 |
-
'default' =>
|
274 |
'type' => 'option', // 保存先 option or theme_mod
|
275 |
'capability' => 'edit_theme_options',
|
276 |
'sanitize_callback' => 'veu_sanitize_boolean',
|
@@ -305,7 +306,7 @@ function veu_customize_register_sns( $wp_customize ) {
|
|
305 |
$wp_customize->add_setting(
|
306 |
'vkExUnit_sns_options[snsBtn_bg_fill_not]',
|
307 |
array(
|
308 |
-
'default' =>
|
309 |
'type' => 'option', // 保存先 option or theme_mod
|
310 |
'capability' => 'edit_theme_options',
|
311 |
'sanitize_callback' => 'veu_sanitize_boolean',
|
@@ -326,7 +327,7 @@ function veu_customize_register_sns( $wp_customize ) {
|
|
326 |
$wp_customize->add_setting(
|
327 |
'vkExUnit_sns_options[snsBtn_color]',
|
328 |
array(
|
329 |
-
'default' =>
|
330 |
'type' => 'option', // 保存先 option or theme_mod
|
331 |
'capability' => 'edit_theme_options',
|
332 |
'sanitize_callback' => 'sanitize_hex_color',
|
@@ -362,7 +363,7 @@ function veu_customize_register_sns( $wp_customize ) {
|
|
362 |
$wp_customize->add_setting(
|
363 |
'vkExUnit_sns_options[snsBtn_position][before]',
|
364 |
array(
|
365 |
-
'default' =>
|
366 |
'type' => 'option', // 保存先 option or theme_mod
|
367 |
'capability' => 'edit_theme_options',
|
368 |
'sanitize_callback' => 'veu_sanitize_boolean',
|
@@ -382,7 +383,7 @@ function veu_customize_register_sns( $wp_customize ) {
|
|
382 |
$wp_customize->add_setting(
|
383 |
'vkExUnit_sns_options[snsBtn_position][after]',
|
384 |
array(
|
385 |
-
'default' =>
|
386 |
'type' => 'option', // 保存先 option or theme_mod
|
387 |
'capability' => 'edit_theme_options',
|
388 |
'sanitize_callback' => 'veu_sanitize_boolean',
|
@@ -459,7 +460,7 @@ function veu_customize_register_sns( $wp_customize ) {
|
|
459 |
$wp_customize->add_setting(
|
460 |
'vkExUnit_sns_options[useFacebook]',
|
461 |
array(
|
462 |
-
'default' =>
|
463 |
'type' => 'option', // 保存先 option or theme_mod
|
464 |
'capability' => 'edit_theme_options',
|
465 |
'sanitize_callback' => 'veu_sanitize_boolean',
|
@@ -480,7 +481,7 @@ function veu_customize_register_sns( $wp_customize ) {
|
|
480 |
$wp_customize->add_setting(
|
481 |
'vkExUnit_sns_options[useTwitter]',
|
482 |
array(
|
483 |
-
'default' =>
|
484 |
'type' => 'option', // 保存先 option or theme_mod
|
485 |
'capability' => 'edit_theme_options',
|
486 |
'sanitize_callback' => 'veu_sanitize_boolean',
|
@@ -501,7 +502,7 @@ function veu_customize_register_sns( $wp_customize ) {
|
|
501 |
$wp_customize->add_setting(
|
502 |
'vkExUnit_sns_options[useHatena]',
|
503 |
array(
|
504 |
-
'default' =>
|
505 |
'type' => 'option', // 保存先 option or theme_mod
|
506 |
'capability' => 'edit_theme_options',
|
507 |
'sanitize_callback' => 'veu_sanitize_boolean',
|
@@ -522,7 +523,7 @@ function veu_customize_register_sns( $wp_customize ) {
|
|
522 |
$wp_customize->add_setting(
|
523 |
'vkExUnit_sns_options[usePocket]',
|
524 |
array(
|
525 |
-
'default' =>
|
526 |
'type' => 'option', // 保存先 option or theme_mod
|
527 |
'capability' => 'edit_theme_options',
|
528 |
'sanitize_callback' => 'veu_sanitize_boolean',
|
@@ -543,7 +544,7 @@ function veu_customize_register_sns( $wp_customize ) {
|
|
543 |
$wp_customize->add_setting(
|
544 |
'vkExUnit_sns_options[useLine]',
|
545 |
array(
|
546 |
-
'default' =>
|
547 |
'type' => 'option', // 保存先 option or theme_mod
|
548 |
'capability' => 'edit_theme_options',
|
549 |
'sanitize_callback' => 'veu_sanitize_boolean',
|
@@ -581,7 +582,7 @@ function veu_customize_register_sns( $wp_customize ) {
|
|
581 |
$wp_customize->add_setting(
|
582 |
'vkExUnit_sns_options[enableFollowMe]',
|
583 |
array(
|
584 |
-
'default' =>
|
585 |
'type' => 'option', // 保存先 option or theme_mod
|
586 |
'capability' => 'edit_theme_options',
|
587 |
'sanitize_callback' => 'veu_sanitize_boolean',
|
@@ -601,7 +602,7 @@ function veu_customize_register_sns( $wp_customize ) {
|
|
601 |
$wp_customize->add_setting(
|
602 |
'vkExUnit_sns_options[followMe_title]',
|
603 |
array(
|
604 |
-
'default' => '',
|
605 |
'type' => 'option', // 保存先 option or theme_mod
|
606 |
'capability' => 'edit_theme_options',
|
607 |
'sanitize_callback' => 'sanitize_text_field',
|
12 |
}
|
13 |
|
14 |
function veu_customize_register_sns( $wp_customize ) {
|
15 |
+
$default_options = veu_get_sns_options_default();
|
16 |
/*
|
17 |
SNS Settings
|
18 |
/*-------------------------------------------*/
|
46 |
$wp_customize->add_setting(
|
47 |
'vkExUnit_sns_options[snsTitle_use_only_postTitle]',
|
48 |
array(
|
49 |
+
'default' => $default_options['snsTitle_use_only_postTitle'],
|
50 |
'type' => 'option', // 保存先 option or theme_mod
|
51 |
'capability' => 'edit_theme_options',
|
52 |
'sanitize_callback' => 'veu_sanitize_boolean',
|
85 |
$wp_customize->add_setting(
|
86 |
'vkExUnit_sns_options[fbAppId]',
|
87 |
array(
|
88 |
+
'default' => $default_options['fbAppId'],
|
89 |
'type' => 'option', // 保存先 option or theme_mod
|
90 |
'capability' => 'edit_theme_options',
|
91 |
'sanitize_callback' => 'sanitize_text_field',
|
106 |
$wp_customize->add_setting(
|
107 |
'vkExUnit_sns_options[fbPageUrl]',
|
108 |
array(
|
109 |
+
'default' => $default_options['fbPageUrl'],
|
110 |
'type' => 'option', // 保存先 option or theme_mod
|
111 |
'capability' => 'edit_theme_options',
|
112 |
'sanitize_callback' => 'sanitize_text_field',
|
127 |
$wp_customize->add_setting(
|
128 |
'vkExUnit_sns_options[ogImage]',
|
129 |
array(
|
130 |
+
'default' => $default_options['ogImage'],
|
131 |
'type' => 'option',
|
132 |
'capability' => 'edit_theme_options',
|
133 |
'sanitize_callback' => 'esc_url_raw',
|
168 |
$wp_customize->add_setting(
|
169 |
'vkExUnit_sns_options[enableOGTags]',
|
170 |
array(
|
171 |
+
'default' => $default_options['enableOGTags'],
|
172 |
'type' => 'option', // 保存先 option or theme_mod
|
173 |
'capability' => 'edit_theme_options',
|
174 |
'sanitize_callback' => 'veu_sanitize_boolean',
|
207 |
$wp_customize->add_setting(
|
208 |
'vkExUnit_sns_options[twitterId]',
|
209 |
array(
|
210 |
+
'default' => $default_options['twitterId'],
|
211 |
'type' => 'option', // 保存先 option or theme_mod
|
212 |
'capability' => 'edit_theme_options',
|
213 |
'sanitize_callback' => 'sanitize_text_field',
|
231 |
$wp_customize->add_setting(
|
232 |
'vkExUnit_sns_options[enableTwitterCardTags]',
|
233 |
array(
|
234 |
+
'default' => $default_options['enableTwitterCardTags'],
|
235 |
'type' => 'option', // 保存先 option or theme_mod
|
236 |
'capability' => 'edit_theme_options',
|
237 |
'sanitize_callback' => 'veu_sanitize_boolean',
|
271 |
$wp_customize->add_setting(
|
272 |
'vkExUnit_sns_options[enableSnsBtns]',
|
273 |
array(
|
274 |
+
'default' => $default_options['enableSnsBtns'],
|
275 |
'type' => 'option', // 保存先 option or theme_mod
|
276 |
'capability' => 'edit_theme_options',
|
277 |
'sanitize_callback' => 'veu_sanitize_boolean',
|
306 |
$wp_customize->add_setting(
|
307 |
'vkExUnit_sns_options[snsBtn_bg_fill_not]',
|
308 |
array(
|
309 |
+
'default' => $default_options['snsBtn_bg_fill_not'],
|
310 |
'type' => 'option', // 保存先 option or theme_mod
|
311 |
'capability' => 'edit_theme_options',
|
312 |
'sanitize_callback' => 'veu_sanitize_boolean',
|
327 |
$wp_customize->add_setting(
|
328 |
'vkExUnit_sns_options[snsBtn_color]',
|
329 |
array(
|
330 |
+
'default' => $default_options['snsBtn_color'],
|
331 |
'type' => 'option', // 保存先 option or theme_mod
|
332 |
'capability' => 'edit_theme_options',
|
333 |
'sanitize_callback' => 'sanitize_hex_color',
|
363 |
$wp_customize->add_setting(
|
364 |
'vkExUnit_sns_options[snsBtn_position][before]',
|
365 |
array(
|
366 |
+
'default' => $default_options['snsBtn_position']['before'],
|
367 |
'type' => 'option', // 保存先 option or theme_mod
|
368 |
'capability' => 'edit_theme_options',
|
369 |
'sanitize_callback' => 'veu_sanitize_boolean',
|
383 |
$wp_customize->add_setting(
|
384 |
'vkExUnit_sns_options[snsBtn_position][after]',
|
385 |
array(
|
386 |
+
'default' => $default_options['snsBtn_position']['after'],
|
387 |
'type' => 'option', // 保存先 option or theme_mod
|
388 |
'capability' => 'edit_theme_options',
|
389 |
'sanitize_callback' => 'veu_sanitize_boolean',
|
460 |
$wp_customize->add_setting(
|
461 |
'vkExUnit_sns_options[useFacebook]',
|
462 |
array(
|
463 |
+
'default' => $default_options['useFacebook'],
|
464 |
'type' => 'option', // 保存先 option or theme_mod
|
465 |
'capability' => 'edit_theme_options',
|
466 |
'sanitize_callback' => 'veu_sanitize_boolean',
|
481 |
$wp_customize->add_setting(
|
482 |
'vkExUnit_sns_options[useTwitter]',
|
483 |
array(
|
484 |
+
'default' => $default_options['useTwitter'],
|
485 |
'type' => 'option', // 保存先 option or theme_mod
|
486 |
'capability' => 'edit_theme_options',
|
487 |
'sanitize_callback' => 'veu_sanitize_boolean',
|
502 |
$wp_customize->add_setting(
|
503 |
'vkExUnit_sns_options[useHatena]',
|
504 |
array(
|
505 |
+
'default' => $default_options['useHatena'],
|
506 |
'type' => 'option', // 保存先 option or theme_mod
|
507 |
'capability' => 'edit_theme_options',
|
508 |
'sanitize_callback' => 'veu_sanitize_boolean',
|
523 |
$wp_customize->add_setting(
|
524 |
'vkExUnit_sns_options[usePocket]',
|
525 |
array(
|
526 |
+
'default' => $default_options['usePocket'],
|
527 |
'type' => 'option', // 保存先 option or theme_mod
|
528 |
'capability' => 'edit_theme_options',
|
529 |
'sanitize_callback' => 'veu_sanitize_boolean',
|
544 |
$wp_customize->add_setting(
|
545 |
'vkExUnit_sns_options[useLine]',
|
546 |
array(
|
547 |
+
'default' => $default_options['useLine'],
|
548 |
'type' => 'option', // 保存先 option or theme_mod
|
549 |
'capability' => 'edit_theme_options',
|
550 |
'sanitize_callback' => 'veu_sanitize_boolean',
|
582 |
$wp_customize->add_setting(
|
583 |
'vkExUnit_sns_options[enableFollowMe]',
|
584 |
array(
|
585 |
+
'default' => $default_options['enableFollowMe'],
|
586 |
'type' => 'option', // 保存先 option or theme_mod
|
587 |
'capability' => 'edit_theme_options',
|
588 |
'sanitize_callback' => 'veu_sanitize_boolean',
|
602 |
$wp_customize->add_setting(
|
603 |
'vkExUnit_sns_options[followMe_title]',
|
604 |
array(
|
605 |
+
'default' => $default_options['followMe_title'],
|
606 |
'type' => 'option', // 保存先 option or theme_mod
|
607 |
'capability' => 'edit_theme_options',
|
608 |
'sanitize_callback' => 'sanitize_text_field',
|
inc/term-color/package/class.term-color.php
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/*
|
4 |
このファイルの元ファイルは
|
5 |
https://github.com/vektor-inc/vektor-wp-libraries
|
@@ -10,31 +9,58 @@ if ( ! class_exists( 'Vk_term_color' ) ) {
|
|
10 |
|
11 |
class Vk_term_color {
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
16 |
|
17 |
-
|
|
|
|
|
|
|
|
|
18 |
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
}
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
public static function sanitize_hex( $color ) {
|
27 |
-
// sanitize_hex_color() は undefined function
|
28 |
$color = ltrim( $color, '#' );
|
29 |
return preg_match( '/([A-Fa-f0-9]{3}){1,2}$/', $color ) ? $color : '';
|
30 |
}
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
38 |
?>
|
39 |
<div class="form-field">
|
40 |
<?php wp_nonce_field( basename( __FILE__ ), 'term_color_nonce' ); ?>
|
@@ -44,39 +70,45 @@ if ( ! class_exists( 'Vk_term_color' ) ) {
|
|
44 |
<?php
|
45 |
}
|
46 |
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
|
|
|
|
51 |
|
52 |
-
// put the term ID into a variable
|
53 |
$term_color = self::get_term_color( $term->term_id );
|
54 |
?>
|
55 |
<tr class="form-field">
|
56 |
-
<th scope="row" valign="top"><label for="term_color"><?php
|
57 |
<td>
|
58 |
<?php wp_nonce_field( basename( __FILE__ ), 'term_color_nonce' ); ?>
|
59 |
-
<input type="text" name="term_color" id="term_color" class="term_color" value="<?php echo $term_color; ?>">
|
60 |
</td>
|
61 |
</tr>
|
62 |
<?php
|
63 |
}
|
64 |
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
|
|
|
|
|
|
70 |
|
71 |
-
// verify the nonce --- remove if you don't care
|
72 |
if ( ! isset( $_POST['term_color_nonce'] ) || ! wp_verify_nonce( $_POST['term_color_nonce'], basename( __FILE__ ) ) ) {
|
73 |
return;
|
74 |
}
|
75 |
|
76 |
if ( isset( $_POST['term_color'] ) ) {
|
77 |
$now_value = get_term_meta( $term_id, 'term_color', true );
|
78 |
-
$new_value = $_POST['term_color'];
|
79 |
-
if ( $now_value
|
80 |
update_term_meta( $term_id, 'term_color', $new_value );
|
81 |
} else {
|
82 |
add_term_meta( $term_id, 'term_color', $new_value );
|
@@ -84,23 +116,26 @@ if ( ! class_exists( 'Vk_term_color' ) ) {
|
|
84 |
}
|
85 |
}
|
86 |
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
// return;
|
95 |
|
96 |
wp_enqueue_style( 'wp-color-picker' );
|
97 |
wp_enqueue_script( 'wp-color-picker' );
|
98 |
|
99 |
-
|
100 |
-
add_action( 'admin_footer', array( $this, 'term_colors_print_scripts' ) );
|
101 |
}
|
102 |
|
103 |
-
|
|
|
|
|
|
|
|
|
|
|
104 |
?>
|
105 |
|
106 |
<style type="text/css">
|
@@ -110,9 +145,13 @@ if ( ! class_exists( 'Vk_term_color' ) ) {
|
|
110 |
<?php
|
111 |
}
|
112 |
|
113 |
-
|
|
|
|
|
|
|
|
|
|
|
114 |
?>
|
115 |
-
|
116 |
<script type="text/javascript">
|
117 |
jQuery( document ).ready( function( $ ) {
|
118 |
$( '.term_color' ).wpColorPicker();
|
@@ -121,11 +160,13 @@ if ( ! class_exists( 'Vk_term_color' ) ) {
|
|
121 |
<?php
|
122 |
}
|
123 |
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
|
|
|
|
129 |
|
130 |
$columns['color'] = __( 'Color', 'vk-all-in-one-expansion-unit' );
|
131 |
|
@@ -133,7 +174,15 @@ if ( ! class_exists( 'Vk_term_color' ) ) {
|
|
133 |
}
|
134 |
|
135 |
|
136 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
|
138 |
if ( 'color' === $column ) {
|
139 |
|
@@ -149,9 +198,12 @@ if ( ! class_exists( 'Vk_term_color' ) ) {
|
|
149 |
return $out;
|
150 |
}
|
151 |
|
152 |
-
|
153 |
-
|
154 |
-
|
|
|
|
|
|
|
155 |
public static function get_term_color( $term_id ) {
|
156 |
$term_color_default = '#999999';
|
157 |
$term_color_default = apply_filters( 'term_color_default_custom', $term_color_default );
|
@@ -164,9 +216,13 @@ if ( ! class_exists( 'Vk_term_color' ) ) {
|
|
164 |
return $term_color;
|
165 |
}
|
166 |
|
167 |
-
|
168 |
-
|
169 |
-
|
|
|
|
|
|
|
|
|
170 |
public static function get_single_term_with_color( $post = '', $args = array() ) {
|
171 |
if ( ! $post ) {
|
172 |
global $post;
|
@@ -195,8 +251,8 @@ if ( ! class_exists( 'Vk_term_color' ) ) {
|
|
195 |
|
196 |
$single_term_with_color = '';
|
197 |
if ( $taxonomies ) :
|
198 |
-
// get $taxonomy name
|
199 |
-
$taxonomy = key( $taxonomies );
|
200 |
$terms = get_the_terms( $post->ID, $taxonomy );
|
201 |
if ( ! $terms ) {
|
202 |
return;
|
@@ -221,13 +277,15 @@ if ( ! class_exists( 'Vk_term_color' ) ) {
|
|
221 |
}
|
222 |
|
223 |
endif;
|
224 |
-
return $single_term_with_color;
|
225 |
}
|
226 |
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
|
|
|
|
231 |
/*
|
232 |
最初Global変数指定をしていたが、 Global変数では
|
233 |
複数の term color が存在した場合に実行タイミングの都合上任意に指定が効かないため、
|
@@ -240,36 +298,13 @@ if ( ! class_exists( 'Vk_term_color' ) ) {
|
|
240 |
$taxonomies = array( 'category', 'post_tag' );
|
241 |
}
|
242 |
$taxonomies = apply_filters( 'term_color_taxonomies_custom', $taxonomies );
|
243 |
-
//
|
244 |
$taxonomies = array_unique( $taxonomies );
|
245 |
-
//
|
246 |
$taxonomies = array_values( $taxonomies );
|
247 |
return $taxonomies;
|
248 |
}
|
249 |
-
/*
|
250 |
-
実行
|
251 |
-
/*-------------------------------------------*/
|
252 |
-
public function __construct() {
|
253 |
-
add_action( 'init', array( $this, 'term_meta_color' ) );
|
254 |
-
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
|
255 |
-
|
256 |
-
/*
|
257 |
-
管理画面 _ 各種処理発火
|
258 |
-
/*-------------------------------------------*/
|
259 |
-
// カラーピッカーを追加するタクソノミー
|
260 |
-
|
261 |
-
$taxonomies = self::get_term_color_taxonomies();
|
262 |
|
263 |
-
// 該当のタクソノミー分ループ処理する
|
264 |
-
foreach ( $taxonomies as $key => $value ) {
|
265 |
-
add_action( $value . '_add_form_fields', array( $this, 'taxonomy_add_new_meta_field_color' ), 10, 2 );
|
266 |
-
add_action( $value . '_edit_form_fields', array( $this, 'taxonomy_add_edit_meta_field_color' ), 10, 2 );
|
267 |
-
add_action( 'edited_' . $value, array( $this, 'save_term_meta_color' ), 10, 2 );
|
268 |
-
add_action( 'create_' . $value, array( $this, 'save_term_meta_color' ), 10, 2 );
|
269 |
-
add_filter( 'manage_edit-' . $value . '_columns', array( $this, 'edit_term_columns' ) );
|
270 |
-
add_filter( 'manage_' . $value . '_custom_column', array( $this, 'manage_term_custom_column' ), 10, 3 );
|
271 |
-
}
|
272 |
-
}
|
273 |
}
|
274 |
|
275 |
$Vk_term_color = new Vk_term_color();
|
1 |
<?php
|
|
|
2 |
/*
|
3 |
このファイルの元ファイルは
|
4 |
https://github.com/vektor-inc/vektor-wp-libraries
|
9 |
|
10 |
class Vk_term_color {
|
11 |
|
12 |
+
/**
|
13 |
+
* Construct
|
14 |
+
*/
|
15 |
+
public function __construct() {
|
16 |
+
add_action( 'init', array( $this, 'term_meta_color' ) );
|
17 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
|
18 |
|
19 |
+
/********************************************
|
20 |
+
* 管理画面 _ 各種処理発火
|
21 |
+
*/
|
22 |
+
// カラーピッカーを追加するタクソノミー.
|
23 |
+
$taxonomies = self::get_term_color_taxonomies();
|
24 |
|
25 |
+
// 該当のタクソノミー分ループ処理する.
|
26 |
+
foreach ( $taxonomies as $key => $value ) {
|
27 |
+
add_action( $value . '_add_form_fields', array( $this, 'taxonomy_add_new_meta_field_color' ), 10, 2 );
|
28 |
+
add_action( $value . '_edit_form_fields', array( $this, 'taxonomy_add_edit_meta_field_color' ), 10, 2 );
|
29 |
+
add_action( 'edited_' . $value, array( $this, 'save_term_meta_color' ), 10, 2 );
|
30 |
+
add_action( 'create_' . $value, array( $this, 'save_term_meta_color' ), 10, 2 );
|
31 |
+
add_filter( 'manage_edit-' . $value . '_columns', array( $this, 'edit_term_columns' ) );
|
32 |
+
add_filter( 'manage_' . $value . '_custom_column', array( $this, 'manage_term_custom_column' ), 10, 3 );
|
33 |
+
}
|
34 |
}
|
35 |
|
36 |
+
/**
|
37 |
+
* REGISTER TERM META
|
38 |
+
*
|
39 |
+
* @return void
|
40 |
+
*/
|
41 |
+
public static function term_meta_color() {
|
42 |
+
register_meta( 'term', 'term_color', array( $this, 'sanitize_hex' ) );
|
43 |
+
}
|
44 |
|
45 |
+
/**
|
46 |
+
* SANITIZE color method
|
47 |
+
*
|
48 |
+
* @param string $color : color code.
|
49 |
+
* @return string
|
50 |
+
*/
|
51 |
public static function sanitize_hex( $color ) {
|
52 |
+
// sanitize_hex_color() は undefined function くらう.
|
53 |
$color = ltrim( $color, '#' );
|
54 |
return preg_match( '/([A-Fa-f0-9]{3}){1,2}$/', $color ) ? $color : '';
|
55 |
}
|
56 |
|
57 |
+
/**
|
58 |
+
* タクソノミー新規追加ページでの日本語入力フォーム
|
59 |
+
*
|
60 |
+
* @return void
|
61 |
+
*/
|
62 |
+
public static function taxonomy_add_new_meta_field_color() {
|
63 |
+
// this will add the custom meta field to the add new term page.
|
64 |
?>
|
65 |
<div class="form-field">
|
66 |
<?php wp_nonce_field( basename( __FILE__ ), 'term_color_nonce' ); ?>
|
70 |
<?php
|
71 |
}
|
72 |
|
73 |
+
/**
|
74 |
+
* タクソノミー編集ページでのフォーム
|
75 |
+
*
|
76 |
+
* @param object $term : term object.
|
77 |
+
* @return void
|
78 |
+
*/
|
79 |
+
public static function taxonomy_add_edit_meta_field_color( $term ) {
|
80 |
|
81 |
+
// put the term ID into a variable.
|
82 |
$term_color = self::get_term_color( $term->term_id );
|
83 |
?>
|
84 |
<tr class="form-field">
|
85 |
+
<th scope="row" valign="top"><label for="term_color"><?php esc_html_e( 'Color', 'vk-all-in-one-expansion-unit' ); ?></label></th>
|
86 |
<td>
|
87 |
<?php wp_nonce_field( basename( __FILE__ ), 'term_color_nonce' ); ?>
|
88 |
+
<input type="text" name="term_color" id="term_color" class="term_color" value="<?php echo esc_attr( $term_color ); ?>">
|
89 |
</td>
|
90 |
</tr>
|
91 |
<?php
|
92 |
}
|
93 |
|
94 |
+
/**
|
95 |
+
* カラーの保存処理
|
96 |
+
* Save extra taxonomy fields callback function.
|
97 |
+
*
|
98 |
+
* @param int $term_id : term id.
|
99 |
+
* @return void
|
100 |
+
*/
|
101 |
+
public static function save_term_meta_color( $term_id ) {
|
102 |
|
103 |
+
// verify the nonce --- remove if you don't care.
|
104 |
if ( ! isset( $_POST['term_color_nonce'] ) || ! wp_verify_nonce( $_POST['term_color_nonce'], basename( __FILE__ ) ) ) {
|
105 |
return;
|
106 |
}
|
107 |
|
108 |
if ( isset( $_POST['term_color'] ) ) {
|
109 |
$now_value = get_term_meta( $term_id, 'term_color', true );
|
110 |
+
$new_value = esc_html( wp_unslash( $_POST['term_color'] ) );
|
111 |
+
if ( $now_value !== $new_value ) {
|
112 |
update_term_meta( $term_id, 'term_color', $new_value );
|
113 |
} else {
|
114 |
add_term_meta( $term_id, 'term_color', $new_value );
|
116 |
}
|
117 |
}
|
118 |
|
119 |
+
/**
|
120 |
+
* 管理画面 _ カラーピッカーのスクリプトの読み込み
|
121 |
+
*
|
122 |
+
* @param string $hook_suffix : page suffix.
|
123 |
+
* @return void
|
124 |
+
*/
|
125 |
+
public static function admin_enqueue_scripts( $hook_suffix ) {
|
|
|
126 |
|
127 |
wp_enqueue_style( 'wp-color-picker' );
|
128 |
wp_enqueue_script( 'wp-color-picker' );
|
129 |
|
130 |
+
add_action( 'admin_footer', array( __CLASS__, 'term_colors_print_scripts' ) );
|
|
|
131 |
}
|
132 |
|
133 |
+
/**
|
134 |
+
* Color style
|
135 |
+
*
|
136 |
+
* @return void
|
137 |
+
*/
|
138 |
+
public static function term_colors_print_styles() {
|
139 |
?>
|
140 |
|
141 |
<style type="text/css">
|
145 |
<?php
|
146 |
}
|
147 |
|
148 |
+
/**
|
149 |
+
* Add Color Picker
|
150 |
+
*
|
151 |
+
* @return void
|
152 |
+
*/
|
153 |
+
public static function term_colors_print_scripts() {
|
154 |
?>
|
|
|
155 |
<script type="text/javascript">
|
156 |
jQuery( document ).ready( function( $ ) {
|
157 |
$( '.term_color' ).wpColorPicker();
|
160 |
<?php
|
161 |
}
|
162 |
|
163 |
+
/**
|
164 |
+
* 管理画面 _ カテゴリー一覧でカラムの追加
|
165 |
+
*
|
166 |
+
* @param string $columns : column name.
|
167 |
+
* @return string $columns
|
168 |
+
*/
|
169 |
+
public static function edit_term_columns( $columns ) {
|
170 |
|
171 |
$columns['color'] = __( 'Color', 'vk-all-in-one-expansion-unit' );
|
172 |
|
174 |
}
|
175 |
|
176 |
|
177 |
+
/**
|
178 |
+
* Insert color column
|
179 |
+
*
|
180 |
+
* @param string $out : admin insert html.
|
181 |
+
* @param string $column insert target column.
|
182 |
+
* @param int $term_id : term id.
|
183 |
+
* @return string $out admin insert html.
|
184 |
+
*/
|
185 |
+
public static function manage_term_custom_column( $out, $column, $term_id ) {
|
186 |
|
187 |
if ( 'color' === $column ) {
|
188 |
|
198 |
return $out;
|
199 |
}
|
200 |
|
201 |
+
/**
|
202 |
+
* Termのカラーを取得
|
203 |
+
*
|
204 |
+
* @param int $term_id : term id.
|
205 |
+
* @return string $term_color : color code
|
206 |
+
*/
|
207 |
public static function get_term_color( $term_id ) {
|
208 |
$term_color_default = '#999999';
|
209 |
$term_color_default = apply_filters( 'term_color_default_custom', $term_color_default );
|
216 |
return $term_color;
|
217 |
}
|
218 |
|
219 |
+
/**
|
220 |
+
* Term名とカラーを取得
|
221 |
+
*
|
222 |
+
* @param object $post : post object.
|
223 |
+
* @param array $args : setting parametor.
|
224 |
+
* @return void
|
225 |
+
*/
|
226 |
public static function get_single_term_with_color( $post = '', $args = array() ) {
|
227 |
if ( ! $post ) {
|
228 |
global $post;
|
251 |
|
252 |
$single_term_with_color = '';
|
253 |
if ( $taxonomies ) :
|
254 |
+
// get $taxonomy name.
|
255 |
+
$taxonomy = apply_filters( 'vk_term_color_taxonomy', key( $taxonomies ) );
|
256 |
$terms = get_the_terms( $post->ID, $taxonomy );
|
257 |
if ( ! $terms ) {
|
258 |
return;
|
277 |
}
|
278 |
|
279 |
endif;
|
280 |
+
return apply_filters( 'vk_get_single_term_with_color', $single_term_with_color, $post );
|
281 |
}
|
282 |
|
283 |
+
/**
|
284 |
+
* Undocumented function
|
285 |
+
*
|
286 |
+
* @return array $taxonomies
|
287 |
+
*/
|
288 |
+
public static function get_term_color_taxonomies() {
|
289 |
/*
|
290 |
最初Global変数指定をしていたが、 Global変数では
|
291 |
複数の term color が存在した場合に実行タイミングの都合上任意に指定が効かないため、
|
298 |
$taxonomies = array( 'category', 'post_tag' );
|
299 |
}
|
300 |
$taxonomies = apply_filters( 'term_color_taxonomies_custom', $taxonomies );
|
301 |
+
// 重複の値を削除.
|
302 |
$taxonomies = array_unique( $taxonomies );
|
303 |
+
// 特に影響はないがキーを振り直す.
|
304 |
$taxonomies = array_values( $taxonomies );
|
305 |
return $taxonomies;
|
306 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
307 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
308 |
}
|
309 |
|
310 |
$Vk_term_color = new Vk_term_color();
|
package-lock.json
CHANGED
@@ -7626,9 +7626,9 @@
|
|
7626 |
"dev": true
|
7627 |
},
|
7628 |
"path-parse": {
|
7629 |
-
"version": "1.0.
|
7630 |
-
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.
|
7631 |
-
"integrity": "sha512-
|
7632 |
"dev": true
|
7633 |
},
|
7634 |
"path-root": {
|
7626 |
"dev": true
|
7627 |
},
|
7628 |
"path-parse": {
|
7629 |
+
"version": "1.0.7",
|
7630 |
+
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz",
|
7631 |
+
"integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==",
|
7632 |
"dev": true
|
7633 |
},
|
7634 |
"path-root": {
|
package.json
CHANGED
@@ -37,7 +37,7 @@
|
|
37 |
"composer:install:win": "wp-env run composer \"composer install\"",
|
38 |
"composer:install:mac": "wp-env run composer 'composer install'",
|
39 |
"phpunit:win": "wp-env run phpunit \"phpunit -c /var/www/html/wp-content/plugins/vk-all-in-one-expansion-unit/phpunit.xml.dist --verbose\"",
|
40 |
-
"phpunit
|
41 |
},
|
42 |
"repository": {
|
43 |
"type": "git",
|
37 |
"composer:install:win": "wp-env run composer \"composer install\"",
|
38 |
"composer:install:mac": "wp-env run composer 'composer install'",
|
39 |
"phpunit:win": "wp-env run phpunit \"phpunit -c /var/www/html/wp-content/plugins/vk-all-in-one-expansion-unit/phpunit.xml.dist --verbose\"",
|
40 |
+
"phpunit": "wp-env run phpunit 'phpunit -c /var/www/html/wp-content/plugins/vk-all-in-one-expansion-unit/phpunit.xml.dist --verbose'"
|
41 |
},
|
42 |
"repository": {
|
43 |
"type": "git",
|
phpunit.xml
CHANGED
@@ -9,6 +9,7 @@
|
|
9 |
<testsuites>
|
10 |
<testsuite name="default">
|
11 |
<directory prefix="test-" suffix=".php">./tests/</directory>
|
|
|
12 |
</testsuite>
|
13 |
</testsuites>
|
14 |
</phpunit>
|
9 |
<testsuites>
|
10 |
<testsuite name="default">
|
11 |
<directory prefix="test-" suffix=".php">./tests/</directory>
|
12 |
+
<directory prefix="test-" suffix=".php">./vendor/vektor-inc/vk-wp-unit-test-tools/src/tests/</directory>
|
13 |
</testsuite>
|
14 |
</testsuites>
|
15 |
</phpunit>
|
phpunit.xml.dist
CHANGED
@@ -10,6 +10,7 @@
|
|
10 |
<testsuites>
|
11 |
<testsuite>
|
12 |
<directory prefix="test-" suffix=".php">./tests/</directory>
|
|
|
13 |
<exclude>./tests/test-sample.php</exclude>
|
14 |
</testsuite>
|
15 |
</testsuites>
|
10 |
<testsuites>
|
11 |
<testsuite>
|
12 |
<directory prefix="test-" suffix=".php">./tests/</directory>
|
13 |
+
<directory prefix="test-" suffix=".php">./vendor/vektor-inc/vk-wp-unit-test-tools/src/tests/</directory>
|
14 |
<exclude>./tests/test-sample.php</exclude>
|
15 |
</testsuite>
|
16 |
</testsuites>
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: vektor-inc,kurudrive,hinaloe,jim912,hideokamoto,nc30,SaoriMiyazaki
|
|
3 |
Donate link:
|
4 |
Tags: Google Analytics, New posts, Related Posts, sitemap, sns, twitter card, Facebook Page Plugin, OG tags,
|
5 |
Requires at least: 5.3.0
|
6 |
-
Tested up to: 5.8.
|
7 |
-
Stable tag: 9.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -83,11 +83,17 @@ e.g.
|
|
83 |
|
84 |
== Changelog ==
|
85 |
|
86 |
-
= 9.
|
87 |
-
* [
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
|
89 |
= 9.64.4.0 =
|
90 |
-
* [Bug fix]
|
91 |
|
92 |
= 9.64.3.0 =
|
93 |
* [ Bug fix ][ Call To Action ] Fix global $post pollution it's bring to bug for child page list and so on.
|
@@ -736,7 +742,7 @@ Restore version 9
|
|
736 |
* [ Bug fix ][ VK Blocks ][ outer ] Lightning Pro theme(No child) no work bug fix
|
737 |
|
738 |
= 7.7.1 =
|
739 |
-
* [Bug fix][ VK Blocks ][ outer ] Child theme no work bug fix
|
740 |
|
741 |
= 7.7.0 =
|
742 |
* [ Add function ][ CTA ] Add content field free layout function
|
3 |
Donate link:
|
4 |
Tags: Google Analytics, New posts, Related Posts, sitemap, sns, twitter card, Facebook Page Plugin, OG tags,
|
5 |
Requires at least: 5.3.0
|
6 |
+
Tested up to: 5.8.1
|
7 |
+
Stable tag: 9.65.0.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
83 |
|
84 |
== Changelog ==
|
85 |
|
86 |
+
= 9.65.0.0 =
|
87 |
+
* [ G3 ][ Specification Change ] Add filter vk_term_color_taxonomy / vk_get_single_term_with_color / vk_post_view
|
88 |
+
|
89 |
+
= 9.64.6.0 =
|
90 |
+
* [ Other ][ CTA ] PHPUnit test update
|
91 |
+
|
92 |
+
= 9.64.5.0 =
|
93 |
+
* [ Bug fix ][ CTA ] Fix Old CTA ( by Custom Fieleds ) Title
|
94 |
|
95 |
= 9.64.4.0 =
|
96 |
+
* [ Bug fix ][ Banner widget ] Added due to missing URL input field
|
97 |
|
98 |
= 9.64.3.0 =
|
99 |
* [ Bug fix ][ Call To Action ] Fix global $post pollution it's bring to bug for child page list and so on.
|
742 |
* [ Bug fix ][ VK Blocks ][ outer ] Lightning Pro theme(No child) no work bug fix
|
743 |
|
744 |
= 7.7.1 =
|
745 |
+
* [ Bug fix ][ VK Blocks ][ outer ] Child theme no work bug fix
|
746 |
|
747 |
= 7.7.0 =
|
748 |
* [ Add function ][ CTA ] Add content field free layout function
|
tests/test-cta-default-display.php
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class WidgetPage
|
4 |
+
*
|
5 |
+
* @package Vk_All_In_One_Expansion_Unit
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* WidgetPage test case.
|
10 |
+
*/
|
11 |
+
class CTADiaplayTest extends WP_UnitTestCase {
|
12 |
+
|
13 |
+
function test_cta_display() {
|
14 |
+
|
15 |
+
$test_array = array(
|
16 |
+
array(
|
17 |
+
'options' => null,
|
18 |
+
'target_post_type' => 'post',
|
19 |
+
'correct' => '0',
|
20 |
+
),
|
21 |
+
array(
|
22 |
+
'options' => array(
|
23 |
+
'post' => '0',
|
24 |
+
),
|
25 |
+
'target_post_type' => 'post',
|
26 |
+
'correct' => '0',
|
27 |
+
),
|
28 |
+
array(
|
29 |
+
'options' => array(
|
30 |
+
'post' => 1,
|
31 |
+
),
|
32 |
+
'target_post_type' => 'post',
|
33 |
+
'correct' => 1,
|
34 |
+
),
|
35 |
+
);
|
36 |
+
|
37 |
+
print PHP_EOL;
|
38 |
+
print '------------------------------------' . PHP_EOL;
|
39 |
+
print 'test_cta_default_display' . PHP_EOL;
|
40 |
+
print '------------------------------------' . PHP_EOL;
|
41 |
+
|
42 |
+
foreach ( $test_array as $key => $test_value ) {
|
43 |
+
|
44 |
+
update_option( 'vkExUnit_cta_settings', $test_value['options'] );
|
45 |
+
|
46 |
+
$return = Vk_Call_To_Action::get_option();
|
47 |
+
|
48 |
+
$this->assertEquals( $test_value['correct'], $return[$test_value['target_post_type']] );
|
49 |
+
print 'correct ::::' . $test_value['correct'] . PHP_EOL;
|
50 |
+
print 'return ::::' . $return[$test_value['target_post_type']] . PHP_EOL;
|
51 |
+
}
|
52 |
+
|
53 |
+
} // function test_chlild_page_excerpt() {
|
54 |
+
}
|
tests/test-cta.php
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* CTA test
|
4 |
+
*
|
5 |
+
* @package Vk_All_In_One_Expansion_Unit
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* CTA Test.
|
10 |
+
*/
|
11 |
+
class CTATest extends WP_UnitTestCase {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Create test post
|
15 |
+
*
|
16 |
+
* @return array $test_posts
|
17 |
+
*/
|
18 |
+
public static function create_cta() {
|
19 |
+
|
20 |
+
$test_posts = array();
|
21 |
+
// Create test post.
|
22 |
+
$post = array(
|
23 |
+
'post_title' => 'cta_published',
|
24 |
+
'post_type' => 'CTA',
|
25 |
+
'post_status' => 'publish',
|
26 |
+
'post_content' => 'content',
|
27 |
+
);
|
28 |
+
$test_posts['post_id'] = wp_insert_post( $post );
|
29 |
+
|
30 |
+
$post = array(
|
31 |
+
'post_title' => 'cta_private',
|
32 |
+
'post_type' => 'CTA',
|
33 |
+
'post_status' => 'private',
|
34 |
+
'post_content' => 'content',
|
35 |
+
);
|
36 |
+
$test_posts['post_id_private'] = wp_insert_post( $post );
|
37 |
+
|
38 |
+
$post = array(
|
39 |
+
'post_title' => 'cta_draft',
|
40 |
+
'post_type' => 'CTA',
|
41 |
+
'post_status' => 'draft',
|
42 |
+
'post_content' => 'content',
|
43 |
+
);
|
44 |
+
$test_posts['post_id_draft'] = wp_insert_post( $post );
|
45 |
+
|
46 |
+
return $test_posts;
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Test get_cta_post()
|
51 |
+
*
|
52 |
+
* @return void
|
53 |
+
*/
|
54 |
+
function test_get_cta_post() {
|
55 |
+
$test_posts = self::create_cta();
|
56 |
+
$test_array = array(
|
57 |
+
// 公開.
|
58 |
+
array(
|
59 |
+
'post_id' => $test_posts['post_id'],
|
60 |
+
'correct' => 'cta_published',
|
61 |
+
),
|
62 |
+
// 非公開.
|
63 |
+
array(
|
64 |
+
'post_id' => $test_posts['post_id_private'],
|
65 |
+
'correct' => null,
|
66 |
+
),
|
67 |
+
// 下書きは表示しない.
|
68 |
+
array(
|
69 |
+
'post_id' => $test_posts['post_id_draft'],
|
70 |
+
'correct' => null,
|
71 |
+
),
|
72 |
+
);
|
73 |
+
|
74 |
+
print PHP_EOL;
|
75 |
+
print '------------------------------------' . PHP_EOL;
|
76 |
+
print 'test_get_cta_post' . PHP_EOL;
|
77 |
+
print '------------------------------------' . PHP_EOL;
|
78 |
+
foreach ( $test_array as $key => $test_value ) {
|
79 |
+
$return = '';
|
80 |
+
$return = Vk_Call_To_Action::get_cta_post( $test_value['post_id'] );
|
81 |
+
if ( isset( $return->post_title ) ) {
|
82 |
+
$return = $return->post_title;
|
83 |
+
}
|
84 |
+
print 'correct ::::' . esc_attr( $test_value['correct'] ) . PHP_EOL;
|
85 |
+
print 'return ::::' . esc_attr( $return ) . PHP_EOL;
|
86 |
+
$this->assertEquals( $test_value['correct'], $return );
|
87 |
+
|
88 |
+
}
|
89 |
+
}
|
90 |
+
}
|
vkExUnit.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: VK All in One Expansion Unit
|
4 |
* Plugin URI: https://ex-unit.nagoya
|
5 |
* Description: This plug-in is an integrated plug-in with a variety of features that make it powerful your web site. Many features can be stopped individually. Example Facebook Page Plugin,Social Bookmarks,Print OG Tags,Print Twitter Card Tags,Print Google Analytics tag,New post widget,Insert Related Posts and more!
|
6 |
-
* Version: 9.
|
7 |
* Author: Vektor,Inc.
|
8 |
* Text Domain: vk-all-in-one-expansion-unit
|
9 |
* Domain Path: /languages
|
3 |
* Plugin Name: VK All in One Expansion Unit
|
4 |
* Plugin URI: https://ex-unit.nagoya
|
5 |
* Description: This plug-in is an integrated plug-in with a variety of features that make it powerful your web site. Many features can be stopped individually. Example Facebook Page Plugin,Social Bookmarks,Print OG Tags,Print Twitter Card Tags,Print Google Analytics tag,New post widget,Insert Related Posts and more!
|
6 |
+
* Version: 9.65.0.0
|
7 |
* Author: Vektor,Inc.
|
8 |
* Text Domain: vk-all-in-one-expansion-unit
|
9 |
* Domain Path: /languages
|