admin_url( 'admin-ajax.php' ), 'wdc_nonce' => wp_create_nonce( 'wdc_nonce' )) ); } add_action( 'wp_enqueue_scripts', 'wdc_load_styles' ); add_action( 'admin_enqueue_scripts', 'wdc_load_styles' ); function wdc_display_func(){ check_ajax_referer( 'wdc_nonce', 'security' ); if(isset($_POST['domain'])) { $domain = str_replace(array('www.', 'http://'), NULL, $_POST['domain']); $split = explode('.', $domain); if(count($split) == 1) { $domain = $domain.".com"; } $domain = preg_replace("/[^-a-zA-Z0-9.]+/", "", $domain); if(strlen($domain) > 0) { include ('DomainAvailability.php'); $Domains = new DomainAvailability(); $available = $Domains->is_available($domain); $custom_found_result_text = __('Congratulations! '.$domain.' is available!', 'wdc'); $custom_not_found_result_text = __('Sorry! '.$domain.' is already taken!', 'wdc'); if ($available == '1') { $result = array('status'=>1,'domain'=>$domain, 'text'=> '
'.$custom_found_result_text.'
'); echo json_encode($result); } elseif ($available == '0') { $result = array('status'=>0,'domain'=>$domain, 'text'=> ''.$custom_not_found_result_text.'
'); echo json_encode($result); }elseif ($available == '2'){ $result = array('status'=>0,'domain'=>$domain, 'text'=> 'WHOIS server not found for that TLD
'); echo json_encode($result); } } else { echo 'Please enter the domain name'; } } die(); } add_action('wp_ajax_wdc_display','wdc_display_func'); add_action('wp_ajax_nopriv_wdc_display','wdc_display_func'); function wdc_display_dashboard(){ do_shortcode('[wpdomainchecker width="350"]'); } function wdc_add_dashboard_widgets() { wp_add_dashboard_widget( 'wdc_dashboard_widget', 'WP Domain Checker', 'wdc_display_dashboard' ); } add_action( 'wp_dashboard_setup', 'wdc_add_dashboard_widgets' ); function wdc_display_shortcode($atts){ $image = plugins_url( '/load.gif', __FILE__ ); $atts = shortcode_atts( array( 'width' => '600', 'button' => 'Check' ), $atts ); $content = '