PluginProbe
Topic SEO Content Optimization Tool / 1.0.8
Topic SEO Content Optimization Tool v1.0.8
1.0.43 1.0.42 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.2 1.0.20 1.0.21 1.0.22 1.0.23 1.0.24 1.0.25 1.0.3 1.0.31 1.0.32 All 40 releases
← All changes | index.php +245 -30 1.0.141.0.8 View file →
@@ -5,9 +5,9 @@
5 5 * Description: Topic helps editors and agencies create content briefs in half the time.
6 6 * Author: Topic
7 7 * License: GPL v2 or later
8 8 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
9 - * Version: 1.0.14
9 + * Version: 1.0.8
10 10 */
11 11 if( ! defined( 'ABSPATH') ) {
12 12 exit;
13 13 }
@@ -17,9 +17,8 @@
17 17 'topic-gutenberg-sidebar',
18 18 plugins_url( 'build/index.js', __FILE__ ),
19 19 array( 'wp-plugins', 'wp-edit-post', 'wp-i18n', 'wp-element' )
20 20 );
21 - wp_enqueue_style('topic-sidebar-global', plugins_url( 'build/index.css', __FILE__ ), array(), time(), 'all');
22 21 }
23 22 add_action( 'enqueue_block_editor_assets', 'topic_enqueue_assets' );
24 23
25 24 class useTopicSeo {
@@ -28,10 +27,18 @@
28 27 public function __construct() {
29 28 add_action( 'post_submitbox_misc_actions', array($this, 'add_usetopic_button_classic_editor') );
30 29 add_action( 'admin_enqueue_scripts', array($this, 'topic_enqueue_assets_classic') );
31 30 add_action('admin_footer', array($this, 'useTopicSeo_sidebar_box'));
32 - add_action('wp_ajax_get_permalink_for_post_id', array($this, 'get_permalink_for_post_id'));
33 - add_action('wp_ajax_search_posts', array($this, 'search_posts'));
31 + add_action('wp_ajax_get_first_click_template_topic', array($this, 'get_first_click_template_topic'));
32 +
33 + add_action('wp_ajax_logout_topic_user', array($this, 'logout_topic_user_func'));
34 + add_action('wp_ajax_brief_detail_page', array($this, 'brief_detail_page'));
35 + add_action('wp_ajax_brief_detail_page_back', array($this, 'brief_detail_page_back'));
36 + add_action('wp_ajax_brief_detail_page_grades_update', array($this, 'brief_detail_page_grades_update'));
37 + add_filter( 'tiny_mce_before_init', array($this, 'add_js_for_onchange_usetopic') );
38 + add_filter( 'wp_ajax_topic_keyword_detail_view', array($this, 'topic_keyword_detail_view') );
39 + add_filter( 'wp_ajax_search_briefs_by_keyword', array($this, 'search_briefs_by_keyword') );
40 +
34 41 }
35 42
36 43
37 44 public function add_usetopic_button_classic_editor(){
@@ -45,54 +52,262 @@
45 52
46 53 public function topic_enqueue_assets_classic() {
47 54 wp_enqueue_script(
48 55 'topic-gutenberg-sidebar-classic',
49 - plugins_url( 'build/index-classic.js', __FILE__ ),
56 + plugins_url( 'classic-editor/index-classic.js', __FILE__ ),
50 57 array( 'wp-plugins', 'wp-edit-post', 'wp-i18n', 'wp-element' ),time()
51 58 );
52 - wp_enqueue_style('topic-classic-sidebar', plugins_url( 'classic-editor/classic.css', __FILE__ ), array(), time(), 'all');
53 - wp_enqueue_style('topic-sidebar-global', plugins_url( 'build/index.css', __FILE__ ), array(), time(), 'all');
59 + wp_enqueue_style('topic-classic-sidebar', plugins_url( 'classic-editor/classic.css', __FILE__ ), array(), time(), 'all');
54 60 }
55 61
56 62 public function useTopicSeo_sidebar_box($data) {
57 63 echo '<div id="usetopicData"><div class="closeTopicdata"><strong>'.__( 'Topic SEO Content Optimization Tool', 'usetopic-plugin' ).'</strong><button type="button" class="close" aria-label="Close plugin"><svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" role="img" aria-hidden="true" focusable="false"><path d="M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"></path></svg><p class="usetopic-tooltip">Close Plugin</p></button></div><div class="content"></div></div>';
58 64 }
65 +
66 + public function get_first_click_template_topic(){
67 + if( current_user_can('administrator') || current_user_can('manage_options') ) {
68 + include dirname(__FILE__) .'/api/usetopicapi.php';
69 + $UseTopicApi = new UseTopicAPI();
59 70
60 - public function get_permalink_for_post_id(){
61 - if(isset($_POST['post_id'])){
62 - $post_id = $_POST['post_id'];
63 - $permalink = get_permalink(intval($post_id));
64 71
65 - wp_send_json([
66 - 'permalink' => $permalink
67 - ]);
72 + $preloginToken = get_option('usetopicapi_token');
73 + if(!empty($preloginToken)){
74 + $allBriefs = $UseTopicApi->getBriefsbyTopicToken($preloginToken);
75 + if(is_object( json_decode( $allBriefs ) )){
76 +
77 + ob_start();
78 + include dirname(__FILE__) .'/templates/briefs.php';
79 + $data = ob_get_clean();
80 + echo $data ;
81 +
82 + }else{
83 +
84 + update_option('usetopicapi_token','');
85 + update_option('usetopicapi_email','');
86 + ob_start();
87 + include dirname(__FILE__) .'/templates/login.php';
88 + $data = ob_get_clean();
89 + echo $data ;
90 +
91 + }
92 + wp_die();
93 + }
94 +
95 + if(isset($_POST['email']) && isset($_POST['password'])){
96 + $loginData = $UseTopicApi->authenticateUsetopicUser($_POST['email'], $_POST['password']);
97 + $res = json_decode( $loginData );
98 + if(property_exists($res , 'error')){
99 + wp_send_json([
100 + 'success' => false,
101 + 'message' => $res->error
102 + ]);
103 +
104 + }elseif(property_exists($res , 'token')){
105 +
106 + //update to database
107 + update_option('usetopicapi_token', $res->token);
108 + update_option('usetopicapi_id', $res->id);
109 + update_option('usetopicapi_email', $_POST['email']);
110 + $allBriefs = $UseTopicApi->getBriefsbyTopicToken($res->token);
111 +
112 + ob_start();
113 + include dirname(__FILE__) .'/templates/briefs.php';
114 + $html = ob_get_clean();
115 +
116 + wp_send_json([
117 + 'success' => true,
118 + 'html' => $html
119 + ]);
120 +
121 + }else{
122 + wp_send_json([
123 + 'success' => false,
124 + 'message' => 'invalid username or password'
125 + ]);
126 + }
127 +
128 + }else{
129 +
130 + ob_start();
131 + include dirname(__FILE__) .'/templates/login.php';
132 + $data = ob_get_clean();
133 + echo $data ;
134 + }
135 +
136 + die();
68 137 }
138 + }
139 +
140 + public function logout_topic_user_func(){
141 + if( current_user_can('administrator') || current_user_can('manage_options') ) {
142 + if(isset($_POST['usetopiclogout']) && $_POST['usetopiclogout'] == true){
143 + update_option('usetopicapi_token','');
144 + update_option('usetopicapi_email','');
145 + ob_start();
146 + include dirname(__FILE__) .'/templates/login.php';
147 + $data = ob_get_clean();
148 + echo $data ;
149 +
150 + }
151 + }
69 152 wp_die();
70 153 }
154 + public function brief_detail_page(){
155 + if( current_user_can('administrator') || current_user_can('manage_options') ) {
156 + include dirname(__FILE__) .'/api/usetopicapi.php';
157 + $UseTopicApi = new UseTopicAPI();
71 158
72 - public function search_posts(){
73 - if(isset($_POST['s'])){
74 - $s = $_POST['s'];
159 + if(isset($_POST['briefID']) && !empty( $_POST['briefID'] ) ){
160 + $briefID = $_POST['briefID'];
161 + $briefContent = $_POST['content'];
162 + $briefToken = get_option('usetopicapi_token');
163 + $briefDetail = $UseTopicApi->getBriefDetailByID( $briefID, $briefToken );
164 + $briefFromURL = false;
75 165
76 - global $wpdb;
77 - $myposts = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' AND post_title LIKE '%s'", '%'. $wpdb->esc_like( $s ) .'%') );
78 - $post_array = array();
79 - foreach ( $myposts as $mypost )
80 - {
81 - // $post = get_post($mypost);
82 - $permalink = get_permalink(intval($mypost->ID));
83 - $mypost->permalink = $permalink;
84 - $mypost->post_content = "";
85 - array_push($post_array, $mypost);
166 + ob_start();
167 + include dirname(__FILE__) .'/templates/brief-detail.php';
168 + $data = ob_get_clean();
169 +
170 + wp_send_json([
171 + 'success' => true,
172 + 'html' => $data,
173 + 'briefdetailar'=> json_encode( $rcTopic )
174 + ]);
175 +
176 + }elseif( isset($_POST['burl']) && !empty( $_POST['burl']) ){
177 +
178 + update_option('usetopicapi_token', '');
179 + update_option('usetopicapi_id', '');
180 + update_option('usetopicapi_email', '');
181 + $briefFromURL = true;
182 +
183 + $burl = $_POST['burl'];
184 + $briefPath = parse_url( $burl )['path'];
185 + if( !empty( $briefPath ) ){
186 +
187 + $briefid = explode( "/", $briefPath )[2];
188 + if(!empty($briefid)){
189 +
190 + $briefDetail = $UseTopicApi->getBriefDetailByURL( $briefid );
191 + if( isset(json_decode($briefDetail, true)['error']) && !empty( json_decode($briefDetail, true)['error'] ) ){
192 + wp_send_json([
193 + 'success' => false,
194 + 'message' => 'Invalid URL, Please make sure brief is public'
195 + ]);
196 + }else{
197 +
198 + ob_start();
199 + include dirname(__FILE__) .'/templates/brief-detail.php';
200 + $data = ob_get_clean();
201 +
202 + wp_send_json([
203 + 'success' => true,
204 + 'html' => $data,
205 + 'briefid' => $briefid,
206 + 'briefdetailar'=> json_encode( $rcTopic )
207 + ]);
208 + }
209 +
210 + }else{
211 + wp_send_json([
212 + 'success' => false,
213 + 'message' => 'Invalid URL, Please make sure brief is public'
214 + ]);
215 + }
216 + }else{
217 + wp_send_json([
218 + 'success' => false,
219 + 'message' => 'Invalid URL, Please make sure brief is public'
220 + ]);
221 + }
222 +
86 223 }
224 + }
225 + wp_die();
226 + }
87 227
88 - wp_send_json([
89 - 'posts' => $post_array
90 - ]);
228 + public function brief_detail_page_back(){
229 + if( current_user_can('administrator') || current_user_can('manage_options') ) {
230 + include dirname(__FILE__) .'/api/usetopicapi.php';
231 + $UseTopicApi = new UseTopicAPI();
232 + $preloginToken = get_option('usetopicapi_token');
233 + $allBriefs = $UseTopicApi->getBriefsbyTopicToken($preloginToken);
234 + ob_start();
235 + include dirname(__FILE__) .'/templates/briefs.php';
236 + $data = ob_get_clean();
237 + echo $data ;
91 238 }
92 239 wp_die();
93 240 }
94 241
242 + public function brief_detail_page_grades_update(){
243 + if( current_user_can('administrator') || current_user_can('manage_options') ) {
244 + include dirname(__FILE__) .'/api/usetopicapi.php';
245 + $UseTopicApi = new UseTopicAPI();
246 +
247 + if(isset($_POST['briefID']) && !empty( $_POST['briefID'] ) ){
248 + if( isset($_POST['byURLBF']) && $_POST['byURLBF'] == 'yes' ){
249 + $briefID = $_POST['briefID'];
250 + $briefContent = $_POST['content'];
251 + $briefDetailUP = $UseTopicApi->getBriefUpdatedReportURL($briefID, $briefContent);
252 + echo $briefDetailUP;
253 +
254 + }else{
255 + $briefID = $_POST['briefID'];
256 + $briefContent = $_POST['content'];
257 + $briefToken = get_option('usetopicapi_token');
258 + $briefDetailUP = $UseTopicApi->getBriefUpdatedReport($briefID, $briefToken, $briefContent);
259 + echo $briefDetailUP;
260 + }
261 +
262 +
263 + }
264 + }
265 + wp_die();
266 + }
267 + public function topic_keyword_detail_view(){
268 + if( current_user_can('administrator') || current_user_can('manage_options') ) {
269 + if( isset($_POST['usetopicBriefArray']) ){
270 + $rcTopics = $_POST['usetopicBriefArray'];
271 + $keyIndex = $_POST['indexval'];
272 + $keystatus = $_POST['keystatus'];
273 + ob_start();
274 + include dirname(__FILE__) .'/templates/topic-keyword-detail.php';
275 + $data = ob_get_clean();
276 + echo $data ;
277 +
278 + }
279 + }
280 + wp_die();
281 + }
282 + public function search_briefs_by_keyword(){
283 + if( current_user_can('administrator') || current_user_can('manage_options') ) {
284 + include dirname(__FILE__) .'/api/usetopicapi.php';
285 + $UseTopicApi = new UseTopicAPI();
286 + if( isset($_POST['search']) ){
287 + $search = $_POST['search'];
288 + $briefToken = get_option('usetopicapi_token');
289 + $allBriefs = $UseTopicApi->getBriefsBySearch( $search, $briefToken );
290 + ob_start();
291 + include dirname(__FILE__) .'/templates/search.php';
292 + $data = ob_get_clean();
293 + echo $data ;
294 +
295 + }
296 + }
297 + wp_die();
298 + }
299 +
300 +
301 +
302 + public function add_js_for_onchange_usetopic( $initArray ) {
303 + $initArray['setup'] = 'function(ed){
304 + ed.on("change", function(ed) {
305 + updateUsetopicFrontGrades();
306 + });
307 + }';
308 + return $initArray;
309 + }
95 310
96 311 }
97 312
98 313 $wpUseTopic= new useTopicSeo();