| @@ -1,60 +1,67 @@ | ||
| 1 | -<?php | |
| 1 | +<?php | |
| 2 | 2 | /* |
| 3 | 3 | Plugin Name: WP Comments Fields Manager |
| 4 | 4 | Plugin URI: http://www.najeebmedia.com |
| 5 | 5 | Description: This plugin allow users to add custom fields in post comments area. |
| 6 | -Version: 1.7 | |
| 7 | -Author: Najeeb Ahmad | |
| 6 | +Version: 2.3 | |
| 7 | +Author: nmedia82 | |
| 8 | 8 | Author URI: http://www.najeebmedia.com/ |
| 9 | 9 | Text Domain: nm-wpcomments |
| 10 | -Domain Path: | |
| 10 | +Domain Path: | |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | +// Exit if accessed directly. | |
| 14 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 15 | + exit; | |
| 16 | +} | |
| 13 | 17 | |
| 14 | -/* | |
| 15 | - * Lets start from here | |
| 16 | -*/ | |
| 18 | +/** | |
| 19 | + * Get the plugin url. | |
| 20 | + * | |
| 21 | + * @access public | |
| 22 | + * @return string | |
| 23 | + */ | |
| 24 | +function wpcf_get_url() { | |
| 25 | + return untrailingslashit( plugins_url( '/', __FILE__ ) ); | |
| 26 | +} | |
| 17 | 27 | |
| 28 | +/** | |
| 29 | + * Get the plugin path. | |
| 30 | + * | |
| 31 | + * @access public | |
| 32 | + * @return string | |
| 33 | + */ | |
| 34 | +function wpcf_get_path() { | |
| 35 | + return untrailingslashit( plugin_dir_path( __FILE__ ) ); | |
| 36 | +} | |
| 37 | + | |
| 38 | +/** | |
| 39 | + * Get the plugin classes path. | |
| 40 | + * | |
| 41 | + * @access public | |
| 42 | + * @return string | |
| 43 | + */ | |
| 44 | +function wpcf_get_class_path() { | |
| 45 | + return untrailingslashit( plugin_dir_path( __FILE__ ) . '/classes/' ); | |
| 46 | +} | |
| 47 | + | |
| 48 | + | |
| 18 | 49 | /* |
| 19 | 50 | * loading plugin config file |
| 20 | 51 | */ |
| 21 | -$_config = dirname(__FILE__).'/config.php'; | |
| 22 | -if( file_exists($_config)) | |
| 23 | - include_once($_config); | |
| 24 | -else | |
| 25 | - die('Reen, Reen, BUMP! not found '.$_config); | |
| 52 | +require_once wpcf_get_path() . '/config.php'; | |
| 26 | 53 | |
| 27 | - | |
| 28 | 54 | /* ======= the plugin main class =========== */ |
| 29 | -$_plugin = dirname(__FILE__).'/classes/plugin.class.php'; | |
| 30 | -if( file_exists($_plugin)) | |
| 31 | - include_once($_plugin); | |
| 32 | -else | |
| 33 | - die('Reen, Reen, BUMP! not found '.$_plugin); | |
| 55 | +require_once wpcf_get_class_path() . '/plugin.class.php'; | |
| 34 | 56 | |
| 35 | 57 | /* |
| 36 | 58 | * [1] |
| 37 | 59 | * TODO: just replace class name with your plugin |
| 38 | 60 | */ |
| 39 | -$nmwpcomment = NM_PLUGIN_WPComments::get_instance(); | |
| 61 | +$nmwpcomment = NM_PLUGIN_WPComments::get_instance(); | |
| 40 | 62 | NM_PLUGIN_WPComments::init(); |
| 41 | 63 | |
| 42 | 64 | |
| 43 | -if( is_admin() ){ | |
| 44 | - | |
| 45 | - $_admin = dirname(__FILE__).'/classes/admin.class.php'; | |
| 46 | - if( file_exists($_admin)) | |
| 47 | - include_once($_admin ); | |
| 48 | - else | |
| 49 | - die('file not found! '.$_admin); | |
| 50 | - | |
| 51 | - $nmwpcomment_admin = new NM_PLUGIN_WPComments_Admin(); | |
| 52 | -} | |
| 53 | - | |
| 54 | -/* | |
| 55 | - * activation/install the plugin data | |
| 56 | -*/ | |
| 57 | -register_activation_hook( __FILE__, array('NM_PLUGIN_WPComments', 'activate_plugin')); | |
| 58 | -register_deactivation_hook( __FILE__, array('NM_PLUGIN_WPComments', 'deactivate_plugin')); | |
| 59 | - | |
| 60 | - | |
| 65 | +if ( is_admin() ) { | |
| 66 | + require_once wpcf_get_class_path() . '/admin.class.php'; | |
| 67 | +} | |