array('name' => 'AI Content Writer - ChatGPT','count' => 0)); if(file_exists(ACWC_PLUGIN_DIR.'backend/json/categories.json')){ $acwc_file_content = file_get_contents(ACWC_PLUGIN_DIR.'backend/json/categories.json'); $acwc_file_content = json_decode($acwc_file_content, true); if($acwc_file_content && is_array($acwc_file_content) && count($acwc_file_content)){ foreach($acwc_file_content as $key=>$item){ $acwc_categories[$key] = trim($item); } } } if(file_exists(ACWC_PLUGIN_DIR.'backend/json/prompts.json')){ $acwc_file_content = file_get_contents(ACWC_PLUGIN_DIR.'backend/json/prompts.json'); $acwc_file_content = json_decode($acwc_file_content, true); if($acwc_file_content && is_array($acwc_file_content) && count($acwc_file_content)){ foreach($acwc_file_content as $item){ $item['type'] = 'json'; $item['author'] = 'default'; $acwc_authors['default']['count'] += 1; $acwc_items[] = $item; } } } if(file_exists(ACWC_PLUGIN_DIR.'backend/json/models.json')){ $acwc_file_content = file_get_contents(ACWC_PLUGIN_DIR.'backend/json/models.json'); $acwc_file_content = json_decode($acwc_file_content, true); if($acwc_file_content && is_array($acwc_file_content) && isset($acwc_file_content['models']) && is_array($acwc_file_content['models']) && count($acwc_file_content['models'])){ foreach($acwc_file_content['models'] as $item){ $acwc_models[] = $item['name']; } } } $sql = "SELECT p.ID as id,p.post_title as title,p.post_author as author, p.post_content as description"; $acwc_meta_keys = array('prompt','editor','response','category','engine','max_tokens','temperature','top_p','best_of','frequency_penalty','presence_penalty','stop','bgcolor','header','ddraft','dclear','dnotice','generate_text','draft_text','clear_text','stop_text','cnotice_text'); foreach($acwc_meta_keys as $acwc_meta_key){ $sql .= ", (".$wpdb->prepare("SELECT %i.%i FROM %i %i WHERE %i.%i=%s AND p.ID=%i.%i LIMIT 1", $acwc_meta_key, 'meta_value', $wpdb->postmeta, $acwc_meta_key, $acwc_meta_key, 'meta_key', 'acwc_prompt_'.$acwc_meta_key, $acwc_meta_key, 'post_id' ).") as ".$acwc_meta_key; } $sql .= $wpdb->prepare(" FROM %i p WHERE p.post_type = 'acwc_prompt' AND p.post_status='publish' ORDER BY p.post_date DESC",$wpdb->posts); $acwc_custom_prompts = $wpdb->get_results($sql,ARRAY_A); if($acwc_custom_prompts && is_array($acwc_custom_prompts) && count($acwc_custom_prompts)){ foreach ($acwc_custom_prompts as $acwc_custom_prompt){ $acwc_custom_prompt['type'] = 'custom'; $acwc_items[] = $acwc_custom_prompt; if(!isset($acwc_authors[$acwc_custom_prompt['author']])){ $prompt_author = get_user_by('ID', $acwc_custom_prompt['author']); $acwc_authors[$acwc_custom_prompt['author']] = array('name' => $prompt_author->display_name, 'count' => 1); } else{ $acwc_authors[$acwc_custom_prompt['author']]['count'] += 1; } } } $acwc_per_page = 36; wp_enqueue_editor(); wp_enqueue_script('wp-color-picker'); wp_enqueue_style('wp-color-picker'); $kses_defaults = wp_kses_allowed_html( 'post' ); $svg_args = array( 'svg' => array( 'class' => true, 'aria-hidden' => true, 'aria-labelledby' => true, 'role' => true, 'xmlns' => true, 'width' => true, 'height' => true, 'viewbox' => true ), 'g' => array( 'fill' => true ), 'title' => array( 'title' => true ), 'path' => array( 'd' => true, 'fill' => true ) ); $allowed_tags = array_merge( $kses_defaults, $svg_args ); ?>
Success: Congrats! Your prompt created! You can add this shortcode to your page: [acwc_prompt id= custom=yes]