"
" ]); global $post; $new_content = str_replace("#post_link#", get_site_url().'/'.$post->post_name.'/suggestions', stripcslashes($options["propose_edit_link"])); $content .= $new_content; } return $content; } public function install(){ //General Settings delete_option("visitors_edits_options"); //Database Settings global $wpdb; $wpdb->show_errors(); $charset_collate = $wpdb->get_charset_collate(); $table_name = $wpdb->prefix . 'visitors_edits'; $sql = "CREATE TABLE $table_name ( edit_id bigint(20) NOT NULL AUTO_INCREMENT, edit_time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, visitor_name text DEFAULT '', visitor_email text DEFAULT '', visitor_comment longtext DEFAULT '', edit_content longtext DEFAULT '', post_id bigint(20), post_content longtext DEFAULT '', UNIQUE KEY (edit_id) ) $charset_collate;"; require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); dbDelta( $sql ); } public function query_vars($query_vars){ $query_vars[] = 'visitors_edits_post_name'; return $query_vars; } public function init(){ add_rewrite_rule( '(.*)?/suggestions/?$', 'index.php?visitors_edits_post_name=$matches[1]', 'top' ); flush_rewrite_rules(true); } public function parse_request($request){ if( isset( $request->query_vars['visitors_edits_post_name'] ) ): include( plugin_dir_path(__FILE__) . "/inc/editor.php" ); exit(); endif; return $request; } public function tinymce_btns($buttons){ if(isset($_GET["page"]) && $_GET["page"]==="visitors_edits_approve"){ array_push($buttons,'|','visitors_edits_approve','visitors_edits_reject','visitors_edits_clean'); } return $buttons; } public function tinymce_scripts($plugin_array){ $plugin_array['visitors_edits'] = plugins_url( 'js/approve.js',__FILE__ ); return $plugin_array; } static function scriptUrl($script){ return plugins_url( 'js/'.$script.'.js',__FILE__); } } new visitors_edits(); use Caxy\HtmlDiff\HtmlDiff; use PHPHtmlParser\Dom; function visitors_editsDIFF($oldHtml,$newHtml){ require "vendor/autoload.php"; $htmlDiff = new HtmlDiff($oldHtml, $newHtml); $htmlDiff->getConfig()->setGroupDiffs(false); return $htmlDiff->build(); } function visitors_editsDOM(){ return new Dom; } ?>