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]