PluginProbe
Topic SEO Content Optimization Tool / 1.0.21
Topic SEO Content Optimization Tool v1.0.21
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
topic / index.php

index.php in Topic SEO Content Optimization Tool 1.0.21, at index.php

102 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Topic
4 * Plugin URI: https://www.usetopic.com/
5 * Description: Topic helps editors and agencies create content briefs in half the time.
6 * Author: Topic
7 * License: GPL v2 or later
8 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
9 * Version: 1.0.22
10 */
11 if( ! defined( 'ABSPATH') ) {
12 exit;
13 }
14
15
16 class useTopicSeo {
17
18
19 public function __construct() {
20 global $pagenow;
21 if($pagenow == 'post.php' || $pagenow == 'post-new.php'){
22 add_action( 'post_submitbox_misc_actions', array($this, 'add_usetopic_button_classic_editor') );
23 add_action( 'admin_enqueue_scripts', array($this, 'topic_enqueue_assets_classic') );
24 add_action('admin_footer', array($this, 'useTopicSeo_sidebar_box'));
25 add_action( 'enqueue_block_editor_assets', array($this,'topic_enqueue_assets') );
26 }
27 add_action('wp_ajax_get_permalink_for_post_id', array($this, 'get_permalink_for_post_id'));
28 add_action('wp_ajax_search_posts', array($this, 'search_posts'));
29 }
30
31
32 public function add_usetopic_button_classic_editor(){
33 $html = '<div id="major-publishing-actions-use-topic" style="overflow:hidden"><p>'.__( 'Topic SEO Content Optimization Tool', 'usetopic-plugin' ).'</p>';
34 $html .= '<div id="publishing-action-use-topic">';
35 $html .= '<button type="button" aria-pressed="true" aria-expanded="true" id="usetopicMain" class="components-button is-pressed has-icon" aria-label="Topic SEO Content Optimization Tool">Grade Content</button>';
36 $html .= '</div>';
37 $html .= '</div>';
38 echo $html;
39 }
40
41 public function topic_enqueue_assets() {
42 wp_enqueue_script(
43 'topic-gutenberg-sidebar',
44 plugins_url( 'build/index.js', __FILE__ ),
45 array( 'wp-plugins', 'wp-edit-post', 'wp-i18n', 'wp-element' )
46 );
47 wp_enqueue_style('topic-sidebar-global', plugins_url( 'build/index.css', __FILE__ ), array(), time(), 'all');
48 }
49
50 public function topic_enqueue_assets_classic() {
51 wp_enqueue_script(
52 'topic-gutenberg-sidebar-classic',
53 plugins_url( 'build/index-classic.js', __FILE__ ), array('wp-plugins'), time(), true
54 );
55 wp_enqueue_style('topic-classic-sidebar', plugins_url( 'classic-editor/classic.css', __FILE__ ), array(), time(), 'all');
56 wp_enqueue_style('topic-sidebar-global', plugins_url( 'build/index.css', __FILE__ ), array(), time(), 'all');
57 }
58
59 public function useTopicSeo_sidebar_box($data) {
60 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>';
61 }
62
63 public function get_permalink_for_post_id(){
64 if(isset($_POST['post_id'])){
65 $post_id = $_POST['post_id'];
66 $permalink = get_permalink(intval($post_id));
67
68 wp_send_json([
69 'permalink' => $permalink
70 ]);
71 }
72 wp_die();
73 }
74
75 public function search_posts(){
76 if(isset($_POST['s'])){
77 $s = $_POST['s'];
78
79 global $wpdb;
80 $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 ) .'%') );
81 $post_array = array();
82 foreach ( $myposts as $mypost )
83 {
84 // $post = get_post($mypost);
85 $permalink = get_permalink(intval($mypost->ID));
86 $mypost->permalink = $permalink;
87 $mypost->post_content = "";
88 array_push($post_array, $mypost);
89 }
90
91 wp_send_json([
92 'posts' => $post_array
93 ]);
94 }
95 wp_die();
96 }
97
98
99 }
100
101 $wpUseTopic= new useTopicSeo();
102