$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/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){ $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']; } } } $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 ); global $wpdb; if(isset($atts) && is_array($atts) && isset($atts['id']) && !empty($atts['id'])){ $acwc_item_id = sanitize_text_field($atts['id']); $acwc_item = false; $acwc_custom = isset($atts['custom']) && $atts['custom'] == 'yes' ? true : false; if(count($acwc_items) && !$acwc_custom){ foreach ($acwc_items as $acwc_prompt){ if(isset($acwc_prompt['id']) && $acwc_prompt['id'] == $acwc_item_id){ $acwc_item = $acwc_prompt; $acwc_item['type'] = 'json'; } } } if($acwc_custom){ $sql = "SELECT p.ID as id,p.post_title as title, 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','color','icon','bgcolor','header','dans','ddraft','dclear','dnotice','generate_text','noanswer_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' AND p.ID=%d ORDER BY p.post_date DESC",$wpdb->posts,$acwc_item_id); $acwc_item = $wpdb->get_row($sql, ARRAY_A); if($acwc_item){ $acwc_item['type'] = 'custom'; } } if($acwc_item){ $acwc_item_categories = array(); $acwc_item_categories_name = array(); if(isset($acwc_item['category']) && !empty($acwc_item['category'])){ $acwc_item_categories = array_map('trim', explode(',', $acwc_item['category'])); } $acwc_icon = ''; 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_generate_text = isset($acwc_item['generate_text']) && !empty($acwc_item['generate_text']) ? $acwc_item['generate_text'] : 'Generate'; $acwc_draft_text = isset($acwc_item['draft_text']) && !empty($acwc_item['draft_text']) ? $acwc_item['draft_text'] : 'Save Draft'; $acwc_noanswer_text = isset($acwc_item['noanswer_text']) && !empty($acwc_item['noanswer_text']) ? $acwc_item['noanswer_text'] : 'Number of Answers'; $acwc_clear_text = isset($acwc_item['clear_text']) && !empty($acwc_item['clear_text']) ? $acwc_item['clear_text'] : 'Clear'; $acwc_stop_text = isset($acwc_item['stop_text']) && !empty($acwc_item['stop_text']) ? $acwc_item['stop_text'] : 'Stop'; $acwc_cnotice_text = isset($acwc_item['cnotice_text']) && !empty($acwc_item['cnotice_text']) ? $acwc_item['cnotice_text'] : 'Please register to save your result'; $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; } } 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]; } } } if(is_user_logged_in()){ wp_enqueue_editor(); } $acwc_show_setting = false; if(isset($atts['settings']) && $atts['settings'] == 'yes'){ $acwc_show_setting = true; } ?>

'.esc_html($acwc_item['description']).'

'; } ?>

Enter Your Text

true, 'textarea_name' => 'acwc_prompt_result')); } else{ ?>
'; if(!is_user_logged_in()){ if(isset($acwc_item['dnotice']) && $acwc_item['dnotice'] == 'no'){ } else{ ?>