PluginProbe
Tag, Category, and Taxonomy Manager – Autotagger Automatically Add Terms / 3.6.2
Tag, Category, and Taxonomy Manager – Autotagger Automatically Add Terms v3.6.2
3.53.0 3.52.0 3.51.0 3.50.0 3.45.0 3.38.0 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.40.0 3.40.1 3.41.0 3.42.0 3.43.0 3.44.0 3.5.0 3.5.1 3.5.2 3.5.3 3.6.0 3.6.1 3.6.2 All 177 releases
simple-tags / inc / posts-tags-widget.php

posts-tags-widget.php in Tag, Category, and Taxonomy Manager – Autotagger Automatically Add Terms 3.6.2, at inc/posts-tags-widget.php

142 lines 4.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * TaxoPress widget class
5 *
6 */
7 class SimpleTags_PostTags_Widget extends WP_Widget {
8 /**
9 * Constructor widget
10 *
11 * @return void
12 * @author Olatechpro
13 */
14 public function __construct() {
15 parent::__construct( 'simpletags-posttags', esc_html__( 'Terms for Current Post (TaxoPress)', 'simple-tags' ),
16 array(
17 'classname' => 'widget-simpletags-posttags',
18 'description' => esc_html__( 'Taxopress Terms for Current Post Shortcode', 'simple-tags' )
19 )
20 );
21 }
22
23 /**
24 * Default settings for widget
25 *
26 * @return array
27 * @author Olatechpro
28 */
29 public static function get_fields() {
30 return array(
31 'posttags_id' => 0,
32 );
33 }
34
35 /**
36 * Method for theme render
37 *
38 * @param array $args
39 * @param array $instance
40 *
41 * @return void
42 * @author Olatechpro
43 */
44 public function widget( $args, $instance ) {
45 extract( $args );
46
47 // Set values and clean it
48 foreach ( (array) self::get_fields() as $field => $field_value ) {
49 ${$field} = isset($instance[$field]) ? trim($instance[$field]) : '';
50 }//$posttags_id;
51
52 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
53 echo $before_widget;
54 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
55 echo do_shortcode('[taxopress_postterms id="'.$posttags_id.'"]');
56 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
57 echo $after_widget;
58 }
59
60 /**
61 * Update widget settings
62 *
63 * @param array $new_instance
64 * @param array $old_instance
65 *
66 * @return array
67 * @author Olatechpro
68 */
69 public function update( $new_instance, $old_instance ) {
70 $instance = $old_instance;
71
72 foreach ( (array) self::get_fields() as $field => $field_value ) {
73 $instance[ $field ] = $new_instance[ $field ];
74 }
75
76 return $instance;
77 }
78
79 /**
80 * Admin form for widgets
81 *
82 * @param array $instance
83 *
84 * @return void
85 * @author Olatechpro
86 */
87 public function form( $instance ) {
88 //Defaults
89 $instance = wp_parse_args( (array) $instance, self::get_fields() );
90
91 $posttags_data = taxopress_get_posttags_data();
92 if(count($posttags_data) > 0){
93 $shortcode_page = sprintf(
94 '<a href="%s">%s</a>',
95 add_query_arg(
96 [
97 'page' => 'st_post_tags',
98 ],
99 admin_url('admin.php')
100 ),
101 esc_html__('this page.', 'simple-tags')
102 );
103
104 echo '<p>'.esc_html__( 'Terms for Current Post are added on ', 'simple-tags' );
105 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
106 echo $shortcode_page;
107 echo '</p>'
108
109 ?>
110 <p>
111 <label for="<?php echo esc_attr($this->get_field_id( 'posttags_id' )); ?>">
112 <?php esc_html_e( 'Select widget terms for current post.', 'simple-tags' ); ?>
113 <select id="<?php echo esc_attr($this->get_field_id( 'posttags_id' )); ?>"
114 name="<?php echo esc_attr($this->get_field_name( 'posttags_id' )); ?>">
115 <?php foreach($posttags_data as $key => $value ){ ?>
116 <option <?php selected( esc_attr($instance['posttags_id']), esc_attr($key) ); ?>
117 value="<?php echo esc_attr($key); ?>"><?php echo esc_html($value['title']); ?></option>
118 <?php } ?>
119 </select>
120 </label>
121 </p>
122
123 <?php
124 }else{
125 $shortcode_page = sprintf(
126 '<a href="%s">%s</a>',
127 add_query_arg(
128 [
129 'page' => 'st_post_tags',
130 ],
131 admin_url('admin.php')
132 ),
133 esc_html__('Here', 'simple-tags')
134 );
135
136 echo '<br />'.esc_html__( 'No terms for current post shortcode available. Add new shortcode ', 'simple-tags' );
137 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
138 echo $shortcode_page;
139 echo '<br /><br />';
140 }
141 }
142 }