array('name' => 'AI Content Writer - ChatGPT','count' => 0)); if(file_exists(ACWC_PLUGIN_DIR.'backend/json/gptcategories.json')){ $acwc_file_content = file_get_contents(ACWC_PLUGIN_DIR.'backend/json/gptcategories.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/icons.json')){ $acwc_file_content = file_get_contents(ACWC_PLUGIN_DIR.'backend/json/icons.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_icons[$key] = trim($item); } } } if(file_exists(ACWC_PLUGIN_DIR.'backend/json/gptforms.json')){ $acwc_file_content = file_get_contents(ACWC_PLUGIN_DIR.'backend/json/gptforms.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('fields','editor','prompt','response','category','engine','max_tokens','temperature','top_p','best_of','frequency_penalty','presence_penalty','stop','color','icon','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 {$acwc_meta_key}.meta_value FROM {$wpdb->postmeta} {$acwc_meta_key} WHERE {$acwc_meta_key}.meta_key = %s AND p.ID = {$acwc_meta_key}.post_id LIMIT 1) as {$acwc_meta_key}", "acwc_form_{$acwc_meta_key}" ); } $sql .= $wpdb->prepare(" FROM {$wpdb->posts} p WHERE p.post_type = %s AND p.post_status = 'publish' ORDER BY p.post_date DESC", 'acwc_form'); $acwc_custom_templates = $wpdb->get_results($sql,ARRAY_A); if($acwc_custom_templates && is_array($acwc_custom_templates) && count($acwc_custom_templates)){ foreach ($acwc_custom_templates as $acwc_custom_template){ $acwc_custom_template['type'] = 'custom'; $acwc_items[] = $acwc_custom_template; if(!isset($acwc_authors[$acwc_custom_template['author']])){ $prompt_author = get_user_by('ID', $acwc_custom_template['author']); $acwc_authors[$acwc_custom_template['author']] = array('name' => $prompt_author->display_name, 'count' => 1); } else{ $acwc_authors[$acwc_custom_template['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 template created! You can add this shortcode to your page: [acwc_form id= custom=yes]

Author

Category

'; if(isset($acwc_item['icon']) && !empty($acwc_item['icon']) && isset($acwc_icons[$acwc_item['icon']]) && !empty($acwc_icons[$acwc_item['icon']])){ $acwc_icon = $acwc_icons[$acwc_item['icon']]; } $acwc_icon_color = isset($acwc_item['color']) && !empty($acwc_item['color']) ? $acwc_item['color'] : '#19c37d'; $acwc_engine = isset($acwc_item['engine']) && !empty($acwc_item['engine']) ? $acwc_item['engine'] : $this->acwc_engine; $acwc_max_tokens = isset($acwc_item['max_tokens']) && !empty($acwc_item['max_tokens']) ? $acwc_item['max_tokens'] : $this->acwc_max_tokens; $acwc_temperature = isset($acwc_item['temperature']) && !empty($acwc_item['temperature']) ? $acwc_item['temperature'] : $this->acwc_temperature; $acwc_top_p = isset($acwc_item['top_p']) && !empty($acwc_item['top_p']) ? $acwc_item['top_p'] : $this->acwc_top_p; $acwc_best_of = isset($acwc_item['best_of']) && !empty($acwc_item['best_of']) ? $acwc_item['best_of'] : $this->acwc_best_of; $acwc_frequency_penalty = isset($acwc_item['frequency_penalty']) && !empty($acwc_item['frequency_penalty']) ? $acwc_item['frequency_penalty'] : $this->acwc_frequency_penalty; $acwc_presence_penalty = isset($acwc_item['presence_penalty']) && !empty($acwc_item['presence_penalty']) ? $acwc_item['presence_penalty'] : $this->acwc_presence_penalty; $acwc_stop = isset($acwc_item['stop']) && !empty($acwc_item['stop']) ? $acwc_item['stop'] : $this->acwc_stop; $acwc_stop_lists = ''; if(is_array($acwc_stop) && count($acwc_stop)){ foreach($acwc_stop as $item_stop){ if($item_stop === "\n"){ $item_stop = '\n'; } $acwc_stop_lists = empty($acwc_stop_lists) ? $item_stop : ','.$item_stop; } } elseif(is_array($acwc_stop) && !count($acwc_stop)){ $acwc_stop_lists = ''; } else{ $acwc_stop_lists = $acwc_stop; } if(count($acwc_item_categories)){ foreach($acwc_item_categories as $acwc_item_category){ if(isset($acwc_categories[$acwc_item_category]) && !empty($acwc_categories[$acwc_item_category])){ $acwc_item_categories_name[] = $acwc_categories[$acwc_item_category]; } } } $acwc_fields = isset($acwc_item['fields']) && !empty($acwc_item['fields']) ? $acwc_item['fields'] : ''; if(!empty($acwc_fields) && !is_array($acwc_fields) && strpos($acwc_fields,'\"') !== false) { $acwc_fields = str_replace('\"', '[QUOTE]', $acwc_fields); } if(!empty($acwc_fields) && !is_array($acwc_fields) && strpos($acwc_fields,"\'") !== false) { $acwc_fields = str_replace('\\', '', $acwc_fields); } ?>
'.esc_html($acwc_item['description']).'

'; } ?>