| 1 |
<?php |
| 2 |
/* =================================== |
| 3 |
Plugin Name: Comment Form WP |
| 4 |
Plugin URI: https://plugin.habibcoder.com/comment-form-wp/hello-world/ |
| 5 |
Author: HabibCoder |
| 6 |
Author URI: http://habibcoder.com |
| 7 |
Version: 2.0.1 |
| 8 |
Required at least: 6.0 |
| 9 |
Required PHP: 7.0 |
| 10 |
Tested up to: 7.0 |
| 11 |
License: General Public License v-2 or later |
| 12 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html |
| 13 |
Tags: comment form, advanced comment form, comment field change, WordPress Comment Form, Customize Comment Form |
| 14 |
Description: WordPress default comment form can modified by the Comment Form WP Plugin. You can remove/add/change comment fields and texts with more functionality. |
| 15 |
Text Domain: comment-form-wp |
| 16 |
=================================== */ |
| 17 |
|
| 18 |
// ABSPATH Defined |
| 19 |
if (! defined('ABSPATH')) { |
| 20 |
exit('not valid'); |
| 21 |
} |
| 22 |
|
| 23 |
|
| 24 |
/* ========================== |
| 25 |
Register Text Domain |
| 26 |
========================== */ |
| 27 |
add_action('plugins_loaded', 'commentformwp_load_textdomain'); |
| 28 |
function commentformwp_load_textdomain(){ |
| 29 |
load_plugin_textdomain('comment-form-wp', false, dirname( plugin_basename( __FILE__ ) ) . '/languages'); |
| 30 |
} |
| 31 |
|
| 32 |
|
| 33 |
/* ================================================== |
| 34 |
Get Plugin Directory & URL and Define Constant |
| 35 |
================================================== */ |
| 36 |
//Get plugin Dir & Url |
| 37 |
$commentformwp_dir = plugin_dir_path( __FILE__ ); |
| 38 |
$commentformwp_url = plugin_dir_url( __FILE__ ); |
| 39 |
|
| 40 |
//Define Dir & Url as a Constants |
| 41 |
define( 'COMMENTFORMWP_PLUGIN_DIR', $commentformwp_dir ); |
| 42 |
define( 'COMMENTFORMWP_PLUGIN_URL', $commentformwp_url ); |
| 43 |
|
| 44 |
|
| 45 |
/* ========================== |
| 46 |
Requires File |
| 47 |
========================== */ |
| 48 |
// Dashboard Require |
| 49 |
$commentformwp_admin_dir = COMMENTFORMWP_PLUGIN_DIR .'form-backend/commentformwp-backend.php'; |
| 50 |
if(file_exists( $commentformwp_admin_dir )){ |
| 51 |
require_once( $commentformwp_admin_dir ); |
| 52 |
} |
| 53 |
// Frontend |
| 54 |
$commentformwp_frontend_dir = COMMENTFORMWP_PLUGIN_DIR .'form-frontend/commentformwp-frontend.php'; |
| 55 |
if(file_exists( $commentformwp_frontend_dir )){ |
| 56 |
require_once( $commentformwp_frontend_dir ); |
| 57 |
} |
| 58 |
|
| 59 |
/* ============================ |
| 60 |
Enqueue in Admin Panel |
| 61 |
============================ */ |
| 62 |
add_action('admin_enqueue_scripts', 'commentformwp_admin_enqueue'); |
| 63 |
function commentformwp_admin_enqueue(){ |
| 64 |
// Scripts |
| 65 |
wp_enqueue_script('jquery'); |
| 66 |
wp_enqueue_script('jquery-ui-tabs'); |
| 67 |
// Stylesheet |
| 68 |
wp_enqueue_style('commentformwp-style', PLUGINS_URL('css/commentformwp-backend.css', __FILE__), array(), '1.0.0', 'all'); |
| 69 |
} |
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
/* ========================== |
| 74 |
Redirect to plugin |
| 75 |
========================== */ |
| 76 |
register_activation_hook( __FILE__, 'commentformwp_plugin_activation' ); |
| 77 |
function commentformwp_plugin_activation(){ |
| 78 |
add_option('commentformwp_plugin_do_activate', true); |
| 79 |
} |
| 80 |
|
| 81 |
add_action('admin_init', 'commentformwp_plugin_redirect'); |
| 82 |
function commentformwp_plugin_redirect(){ |
| 83 |
if (is_admin() && get_option('commentformwp_plugin_do_activate', false)) { |
| 84 |
delete_option('commentformwp_plugin_do_activate'); |
| 85 |
|
| 86 |
if (!isset($_GET['active_multi'])) { |
| 87 |
wp_safe_redirect( admin_url('tools.php?page=comment-form-wp') ); |
| 88 |
exit; |
| 89 |
} |
| 90 |
|
| 91 |
} |
| 92 |
}; |