'ar-SA', 'Chinese, Mandarin (cmn-CN)' => 'cmn-CN', 'Croatian' => 'hr', 'Czech' => 'cs', 'Danish' => 'da-DK', 'Dutch' => 'nl-NL', 'English' => 'en-us', 'Estonian' => 'et', 'Finnish' => 'fi', 'French' => 'fr', 'German' => 'de', 'Greek' => 'el', 'Hebrew' => 'he-IL', 'Hindi' => 'hi-IN', 'Hungarian' => 'hu', 'Icelandic' => 'is-IS', 'Indonesian' => 'id-ID', 'Italian' => 'it', 'Japanese' => 'ja-JP', 'Korean' => 'ko-KR', 'Malay' => 'ms-MY', 'Norwegian' => 'nb-NO', 'Polish' => 'pl-PL', 'Portuguese' => 'pt', 'Portuguese (Brazil)' => 'pt-BR', 'Romanian' => 'ro-RO', 'Russian' => 'ru-RU', 'Slovenian' => 'sl', 'Spanish' => 'es', 'Swahili' => 'sw', 'Swedish' => 'sv-SE', 'Turkish' => 'tr-TR', 'Vietnamese' => 'vi' ); static $plugin_allowed_html = array( 'a' => array( 'href' => true, 'rel' => true, 'name' => true, 'target' => true, ), 'b' => array(), 'br' => array(), 'button' => array( 'class' => true, 'disabled' => true, 'name' => true, 'type' => true, 'value' => true, ), 'div' => array( 'class' => true, 'data-*' => true, 'style' => true ), 'em' => array(), 'i' => array(), 'input' => array( 'id' => true, 'name' => true, 'placeholder' => true, 'type' => true, 'value' => true, ), 'label' => array( 'for' => true, ), 'option' => array( 'value' => true, 'selected' => true ), 'select' => array( 'name' => true, 'class' => true ), 'textarea' => array( 'id' => true, 'name' => true, 'placeholder' => true ), ); // in init below after translations loaded static $supported_lengths = array(); static $supported_voices = array(); static $debugLogDir = null; static $debugLogUrl = null; static $debugLog = null; static function this_plugin_init() { global $wpdb; register_activation_hook(__FILE__, array(__CLASS__, 'activation_hook')); add_action('admin_init', array(__CLASS__, 'on_post_forms')); add_action('admin_menu', array(__CLASS__, 'admin_menu_action')); add_action('admin_footer', array(__CLASS__, 'admin_footer_action')); add_filter('plugin_action_links_' . plugin_basename(__FILE__), array(__CLASS__, 'plugin_action_links_filter')); add_action('init', array(__CLASS__, 'init_action')); //add_action('admin_enqueue_scripts', array(__CLASS__, 'admin_enqueue_scripts_action'), 10, 1); add_action('wp_ajax_aiwrc_ajax_submission', array(__CLASS__, 'aiwrc_ajax_submission_action')); add_action('enqueue_block_editor_assets', array(__CLASS__, 'example_enqueue_editor_assets_action')); // these will be used only by a developer by setting self::$testing = true some lines above $upload_dir = wp_upload_dir(); self::$debugLogDir = trailingslashit($upload_dir['basedir']); self::$debugLog = self::$debugLogDir . 'ai-writer-contents.txt'; self::$debugLogUrl = trailingslashit($upload_dir['baseurl']) . 'ai-writer-contents.txt'; } static function init_action() { //global $pagenow; //die($pagenow); load_plugin_textdomain( 'aiwrc', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); self::$supported_lengths = array( __('500 words', 'aiwrc') => '500', __('1000 words', 'aiwrc') => '1000', __('2000 words', 'aiwrc') => '2000' ); self::$supported_voices = array( __('Neutral', 'aiwrc') => 'neutral', __('Bold', 'aiwrc') => 'bold', __('Casual', 'aiwrc') => 'casual', __('Dramatic', 'aiwrc') => 'dramatic', __('Excited', 'aiwrc') => 'excited', __('Formal', 'aiwrc') => 'formal', __('Funny', 'aiwrc') => 'funny', __('Informal', 'aiwrc') => 'informal', __('Luxury', 'aiwrc') => 'luxury', __('Motivational', 'aiwrc') => 'motivational', __('Professional', 'aiwrc') => 'professional', __('Sarcastic', 'aiwrc') => 'sarcastic', __('Secretive', 'aiwrc') => 'secretive', __('Witty', 'aiwrc') => 'witty', ); } /** * this functions does nothing when self::$testing = false (always is in production) * a dev would set the var to true to enable the logging * @return void */ static function log() { if (!self::$testing) { return; } $args = func_get_args(); foreach ($args as $i => $arg) { if ('DELETE' === $arg) { wp_delete_file(self::$debugLog); continue; } // "pretty" print if array or object if (is_array($arg) || is_object($arg)) { $arg = print_r($arg, true); $arg = preg_replace("~\r?\n~", PHP_EOL, $arg); } elseif (is_bool($arg)) { $arg = $arg ? 'TRUE' : 'FALSE'; } elseif (is_null($arg)) { $arg = 'NULL'; } elseif (is_string($arg)) { if ('::' == substr($arg, 0, 2)) { self::log('--------------------------------------------------------------------------------'); } } // prepend a line of separation if first argument begins with :: //!devtest file_put_contents(self::$debugLog, $arg . PHP_EOL, FILE_APPEND); } } static function activation_hook() { } static function options() { $opts = get_option(self::$options_name); if (!is_array($opts)) { $opts = array(); } $opts = array_merge(array( 'user_email' => '', 'user_id' => '', 'token' => '', ), $opts); return $opts; } static function admin_menu_action() { $parent_slug = self::$slug . '-page-settings'; add_menu_page(self::$name, self::$name, 'manage_options', $parent_slug, array(__CLASS__, 'menu_settings_callback')); $aiwriter_setup = add_submenu_page($parent_slug, __('Setup', 'aiwrc'), __('Setup', 'aiwrc'), 'manage_options', $parent_slug, array(__CLASS__, 'menu_settings_callback')); $aiwriter_page = add_submenu_page($parent_slug, __('Generate a post', 'aiwrc'), __('Generate a post', 'aiwrc'), 'manage_options', self::$slug . '-page-writer', array(__CLASS__, 'menu_writer_callback')); // selectively load js only for the above page add_action('load-' . $aiwriter_setup, array(__CLASS__, 'load_assets_selectively')); add_action('load-' . $aiwriter_page, array(__CLASS__, 'load_assets_selectively')); add_action('load-post.php', array(__CLASS__, 'load_assets_selectively')); add_action('load-post-new.php', array(__CLASS__, 'load_assets_selectively')); } static function load_assets_selectively() { self::$assets_context = true; add_action('admin_enqueue_scripts', function() { $ver = (string)time(); // self::$version; wp_enqueue_style(self::$slug . '-style', plugins_url('assets/css/style.css', __FILE__), array(), $ver); // https://developer.wordpress.org/reference/functions/wp_add_inline_script/ ?? wp_register_script(self::$slug . '-main', plugins_url('assets/js/main.js', __FILE__), array('jquery', 'jquery-ui-sortable'), $ver, false); // 'jquery' dep removed due to theme deregistering jquery wp_enqueue_script(self::$slug . '-main'); wp_localize_script(self::$slug . '-main', 'aiwrc_globals', array( 'ajaxurl' => admin_url('admin-ajax.php') )); }, 10); } static function example_enqueue_editor_assets_action() { $ver = (string)time(); wp_enqueue_script('aiwrc-editor-scripts', plugins_url('build/index.js', __FILE__), array('jquery'), $ver); } static function admin_footer_action() { if (!self::$assets_context) { return; } $opts = self::options(); $contents_logged_in = !empty($opts['token']); if ($contents_logged_in) { $html_ksesd = wp_kses( self::get_step1_html('gutenberg'), self::$plugin_allowed_html ); } ?>
%2$s', admin_url('admin.php?page=' . self::$slug . '-page-settings'), esc_html__('Setup', 'aiwrc')); return $links; } static function messages_echo() { // notices if (!empty(self::$notices)) { foreach (self::$notices as $notice) { ?>Token:
Hello!
We're excited that you're interested in enhancing your creative process with the Contents.ai plugin, designed to deliver SEO-optimized content. Before using the plugin, you need to create an account on Contents.ai. For full access to all the plugin's capabilities, consider opting for the Starter or Pro plan at https://www.contents.ai/pricing/. After selecting the plan, simply input your access key into the plugin, and it's all set for use.
Understanding how the plugin works: start by selecting a title, deciding on the length of the article, either in the standalone plugin or inside Gutenberg’s editor, and setting your preferred tone. In just minutes, you'll receive content that's not only well-written but also crafted with care. The plugin's ability to generate flexible outlines and its use of unique native-language data sets make it a groundbreaking tool for efficient and effective blogging.