'; public $limit = AIAUTOTOOL_FREE; private $plan_limit_aiautotool ; public $name_plan ; public $config = array(); public $notice ; public function __construct() { $this->name_plan = __('Ai Post','ai-auto-tool'); $this->plan_limit_aiautotool = 'plan_limit_aiautotool_'.$this->active_option_name; $this->notice = new aiautotool_Warning_Notice(); $this->active = get_option($this->active_option_name, true); if ($this->active=='true') { $this->init(); } add_action('wp_ajax_update_active_option_canonical_'.$this->active_option_name, array($this, 'update_active_option_callback')); add_action('wp_ajax_nopriv_update_active_option_canonical_'.$this->active_option_name, array($this, 'update_active_option_callback')); } public function aiautotool_meta_box() { $customPostTypes = get_post_types(['public' => true, '_builtin' => false], 'objects'); $customPostTypeNames = array_keys($customPostTypes); foreach ($customPostTypeNames as $postType) { add_meta_box( 'aiautotool-meta-box', 'Ai Auto Tool', array($this, 'aiautotool_meta_box_callback'), $postType, 'side', 'high' ); } add_meta_box( 'aiautotool-meta-box', 'Ai Auto Tool ', array($this,'aiautotool_meta_box_callback'), array('post', 'page'), 'side', 'high' ); add_meta_box( 'aiautotool-aireview-meta-box', 'Ai Review', array($this,'aiautotool_aireview_meta_box_callback'), array('post', 'page'), 'side', 'high' ); } public function aiautotool_aireview_meta_box_callback($post) { // Retrieve any saved meta box data $custom_data = get_post_meta($post->ID, 'custom_data_key', true); ?>
); ?>)
); ?>)
); ?>)
' . $this->icon . ' ' . esc_html($this->name_plan) . ': Usage: ' . esc_html($this->config['usage']) . '
', [ 'p' => [], 'i' => ['class' => []], 'strong' => [], ] ); } } public function update_active_option_callback() { check_ajax_referer('aiautotool_nonce', 'security'); if (isset($_POST['active'])) { $active = sanitize_text_field($_POST['active']); update_option($this->active_option_name, $active,null, 'no'); print_r($active); } wp_die(); } function init(){ $configs = get_option($this->plan_limit_aiautotool, array()); if (!$this->aiautotool_has_plugin_data()) { $this->aiautotool_initialize_plugin_data(); $configs = get_option($this->plan_limit_aiautotool, array()); } if(isset($configs['expiration'])){ $this->config = array( 'number_post'=>$this->limit, 'usage'=>get_option($this->usage_option_name, 0, 'no'), 'time_exprice'=>$configs['expiration'] ); }else{ $this->config = array( 'number_post'=>$this->limit, 'usage'=>get_option($this->usage_option_name, 0, 'no'), 'time_exprice'=>'' ); } if($this->is_premium()->get_plan_name()=='aiautotoolpro'||$this->is_premium()->get_plan_name()=='premium'){ $this->config = array( 'number_post'=>-1, 'usage'=>get_option($this->usage_option_name, 0, 'no'), 'time_exprice'=>$this->is_premium()->_get_license()->expiration ); } add_action('admin_menu', array($this, 'add_menu')); add_action('admin_init', array($this, 'aiautotool_check_post_limit')); add_action('wp_ajax_aiautotool_get_slug', array($this, 'aiautotool_get_slug')); add_action('wp_ajax_nopriv_aiautotool_get_slug', array($this, 'aiautotool_get_slug')); add_action('wp_ajax_bard_content', array($this, 'bard_content_callback')); add_action('wp_ajax_nopriv_bard_content', array($this, 'bard_content_callback')); add_action('wp_ajax_save_post_data', array($this, 'save_post_data')); add_action('wp_ajax_nopriv_save_post_data', array($this, 'save_post_data')); add_action( 'admin_footer', array( $this, 'add_aiautotool_aipost_js' ) ); add_action('wp_ajax_update_usage', array($this, 'aiautotool_update_usage_callback')); add_action('wp_ajax_nopriv_update_usage', array($this, 'aiautotool_update_usage_callback')); add_action('wp_ajax_seoreview_ajax', array($this, 'aiautotool_seoreview_ajax_callback')); add_action('wp_ajax_nopriv_seoreview_ajax', array($this, 'aiautotool_seoreview_ajax_callback')); add_action('add_meta_boxes', array( $this, 'aiautotool_meta_box' )); add_action('wp_ajax_aiautotool_suggest_tag', array($this, 'aiautotool_suggest_tag_callback')); } public function aiautotool_suggest_tag_callback() { // Kiểm tra nonce if ( ! isset( $_POST['security'] ) || ! wp_verify_nonce( $_POST['security'], 'aiautotool_nonce' ) ) { wp_send_json_error( 'Invalid nonce' ); } $title = isset($_POST['title']) ? sanitize_text_field($_POST['title']) : ''; $lang = isset($_POST['lang']) ? sanitize_text_field($_POST['lang']) : $this->setting['lang']; $tag = $this->aiautotool_AIprecreatetagname($title,$lang); if(isset($tag)){ wp_send_json_success( $tag ); }else{ wp_send_json_error( 'no tag' ); } } public function aiautotool_AIprecreatetagname($title, $lang) { $bardGenContent = new BardGenContent(); $question = "The most important: The results must only be in JSON format, the response must be in the SAME LANGUAGE as the original text (text between \"======\"). Create %%NUMMBERCOMMENT%% tag for the article. tag only 2 or 3 word tag must have a ====== %%TITLTE%% ====== intellectual level. The post\'s content is between \"=========\". The results must only be in JSON format, with this exact format, you have to fill empty values,Each item in tag has the form { \"tag\": \"\" } "; $question = str_replace('%%TITLTE%%', $title, $question); $question = str_replace('%%NUMMBERCOMMENT%%', rand(8, 15), $question); $json = $bardGenContent->bardcontentmore($question, $lang); return $this->aiautotool_fixjsonreturn($json); } public function aiautotool_seoreview_ajax_callback() { // Kiểm tra xác thực nonce để đảm bảo an toàn //check_ajax_referer('aiautotool_nonce', 'security'); // Lấy dữ liệu gửi từ client $post_title = $_POST['title']; $post_content = $_POST['content']; $lang = $_POST['lang']; $question = ' Tên của bạn bây giờ sẽ là AIAutoTool. Mở đầu kết quả trả về bạn phải tự giới thiệu về mình là : AIAutoTool, sau đây là phần đánh giá bài viết của bạn. Ngôn ngữ trả về phải giống với ngôn ngữ có trong nội dung (Nội dung bài viết nằm giữa =======) hãy thống kê từ khoá chính, từ khoá phụ, dự đoán từ khoá cùng vị trí có thể lên top google trong tương lai đối với nội dung bài viết có trong nội dung bài viết sau. Dựa vào bảng checklist dưới đây, đánh giá bài viết có (nội dung bài viết nằm giữa =======) - title Chứa từ khóa chính (khoảng 5-7 từ) - tiêu đề Dưới 70 ký tự (bao gồm cả khoảng trắng) - Sử dụng giọng văn Thu hút và khơi gợi sự tò mò - Sử dụng chữ hoa và số đếm hợp lý, các con số thống kê nên được đưa ra. - Mô tả ngắn của bài viết nên Chứa từ khóa chính (khoảng 10-15 từ).Dưới 160 ký tự (bao gồm cả khoảng trắng) - Tóm tắt nội dung bài viết một cách súc tích và hấp dẫn - Sử dụng Call to Action (CTA) - Cung cấp thông tin hữu ích và giá trị cho người đọc - Đáp ứng đúng ý định tìm kiếm của người dùng - Sử dụng từ khóa chính một cách tự nhiên và mật độ phù hợp (khoảng 1-2%) - Chia bài viết thành các đoạn ngắn, sử dụng headings và subheadings hợp lý - Bổ sung hình ảnh, video và infographic để minh họa cho nội dung - Sử dụng các liên kết nội bộ và liên kết ngoài chất lượng - Chứa từ khóa chính và biến thể của từ khóa mục tiêu. - Có tổ chức logic, dễ đọc và dễ tiếp cận. - Chứa thông tin giá trị và hữu ích cho người đọc. - Sử dụng các tiêu đề con (H2, H3) để phân đoạn nội dung. - Bài viết cần được kiểm tra lỗi chính tả và ngữ pháp Trên đây là những yêu cầu tối thiểu cho một bài viết blog, bạn hãy đóng vai trò người SEOER đánh giá nội dung sau đây có được bao nhiêu điều thoả mãi checklist seo ở trên. Nội dung có trong bài viết sau:. ======= %%CONTENT%% ======='; $question = str_replace('%%CONTENT%%',$post_content,$question); $bardGenContent = new BardGenContent(); $json = $bardGenContent->bardcontentmore($question,$lang); if ($json) { wp_send_json_success($json); wp_die(); } wp_send_json_error($newcontent); wp_die(); } public function aiautotool_fixjsonreturn($result){ $pattern = '/\{(?:[^{}]|(?R))*\}/'; preg_match_all($pattern, $result, $matches); $arritem = array(); foreach ($matches[0] as $jsonString) { $decodedJson = json_decode($jsonString, true); if ($decodedJson !== null) { if(isset($decodedJson['tags'])) { foreach($decodedJson['tags'] as $item){ $arritem[] = $item; } }else{ $arritem[] = $decodedJson; } } else { return null; } } return $arritem; } function aiautotool_update_usage_callback() { check_ajax_referer('aiautotool_aipost_nonce', 'security'); $this->aiautotool_update_usage(); wp_send_json_success(array('success'=>true)); wp_die(); } function save_post_data() { check_ajax_referer('aiautotool_nonce', 'security'); $languageCodes = $this->languageCodes; $title = sanitize_text_field($_POST['aiautotool_title']); $slug = sanitize_text_field($_POST['aiautotool_slug']); $categories = array_map('absint', $_POST['post_category']); // Ensure categories are integers $tags = sanitize_text_field($_POST['aiautotool_tags']); $content = wp_kses_post($_POST['aiautotool_content']); //xu ly time $publish_year = sanitize_text_field($_POST['publish_year']); $publish_month = sanitize_text_field($_POST['publish_month']); $publish_day = sanitize_text_field($_POST['publish_day']); $publish_hour = sanitize_text_field($_POST['publish_hour']); $publish_minute = sanitize_text_field($_POST['publish_minute']); $attachThumbnail = sanitize_text_field($_POST['custom-thumbnail-id']); $post_language = sanitize_text_field($_POST['post_language']); $publish_timestamp = strtotime("$publish_year-$publish_month-$publish_day $publish_hour:$publish_minute"); $current_time = current_time('timestamp'); if ($publish_timestamp <= $current_time) { $post_status = 'publish'; $post_date = date('Y-m-d H:i:s', $publish_timestamp); } else { $post_status = 'future'; $post_date = date('Y-m-d H:i:s', $publish_timestamp); } $post_data = array( 'post_title' => $title, 'post_name' => $slug, 'post_content' => $content, 'post_status' => $post_status, 'post_date' => $post_date, 'post_category' => $categories, 'tags_input' => $tags, ); $post_id = wp_insert_post($post_data); $selectedLanguageName = 'Vietnamese'; if(array_key_exists($post_language, $languageCodes)) { $selectedLanguageName = $languageCodes[$post_language]; if(in_array('polylang/polylang.php', apply_filters('active_plugins', get_option('active_plugins')))){ pll_set_post_language($post_id, $post_language); } } update_post_meta($post_id, 'lang', $selectedLanguageName); $html = stripslashes($content); preg_match_all('/