false, 'error' => 'Usuario no autorizado.')); return; } if (!isset($_POST['text']) || !isset($_POST['title'])){ ai_post_generator_return_json( array('exito' => false, 'error' => 'Mensaje vacío') ); } if($_POST['type']=="publish"){ $type = "publish"; }elseif($_POST['type']=="draft"){ $type = "draft"; }else{ $type = "draft"; } $type = sanitize_text_field($type); $title = sanitize_text_field(wp_strip_all_tags($_POST['title'])); $url = trim(preg_replace('/[^a-z0-9-]+/', '-', ai_post_generator_stripAccents(strtolower($title))), '-'); $my_post = array( 'post_title' => $title, 'post_url' => $url, 'post_content' => wp_kses_post($_POST['text']), 'post_status' => $type, 'post_author' => 1 ); $id = wp_insert_post( $my_post ); ai_post_generator_return_json( array('exito' => true, 'url' => $url, 'id' => $id) ); } add_action('wp_ajax_ai_post_generator_data_Publish', 'ai_post_generator_data_Publish'); } if (!function_exists('ai_post_generator_enqueue_css_js')){ /** * Enqueues the CSS and JS * * @since 1.0.0 * @author Your Name * @return void */ function ai_post_generator_enqueue_css_js() { // Create version codes $my_css_ver = date('Ymd-Gis', filemtime( AI_POST_GENERATOR_PLUGIN_DIR . 'css/my-styles.css' )); $my_css_checkout = date('Ymd-Gis', filemtime( AI_POST_GENERATOR_PLUGIN_DIR . 'css/checkout.css' )); $my_css_bootstrap = date('Ymd-Gis', filemtime( AI_POST_GENERATOR_PLUGIN_DIR . 'css/bootstrap.min.css' )); $my_js_ver = date('ymd-Gis', filemtime( AI_POST_GENERATOR_PLUGIN_DIR . 'js/main.js' )); $my_js_checkout = date('ymd-Gis', filemtime( AI_POST_GENERATOR_PLUGIN_DIR . 'js/checkout.js' )); $my_js_bootstrap = date('ymd-Gis', filemtime( AI_POST_GENERATOR_PLUGIN_DIR . 'js/bootstrap.bundle.min.js' )); $my_js_checkout = date('ymd-Gis', filemtime('https://js.stripe.com/v3/')); $my_js_circle = date('ymd-Gis', filemtime( AI_POST_GENERATOR_PLUGIN_DIR . 'js/circle-progress.min.js' )); // Enqueue the stylesheet wp_enqueue_style( 'my-styles', trailingslashit( AI_POST_GENERATOR_PLUGIN_URL ) . "css/my-styles.css", null, $my_css_ver ); wp_enqueue_style( 'my-styles1', trailingslashit( AI_POST_GENERATOR_PLUGIN_URL ) . "css/checkout.css", null, $my_css_checkout ); wp_enqueue_style( 'my-styles2', trailingslashit( AI_POST_GENERATOR_PLUGIN_URL ) . "css/bootstrap.min.css", null, $my_css_bootstrap ); wp_enqueue_style( 'my-styles3', "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css", null, null ); // Enqueue the script wp_enqueue_script( 'my-functions1', trailingslashit("https://js.stripe.com/v3/"), null, $my_js_checkout, true ); wp_enqueue_script( 'my-functions2', trailingslashit( AI_POST_GENERATOR_PLUGIN_URL ) . "js/bootstrap.bundle.min.js", null, $my_js_bootstrap, true ); wp_enqueue_script( 'my-functions3', trailingslashit( AI_POST_GENERATOR_PLUGIN_URL ) . "js/circle-progress.min.js", null, $my_js_circle, true ); wp_enqueue_script( 'my-functions4', trailingslashit( AI_POST_GENERATOR_PLUGIN_URL ) . "js/main.js", null, $my_js_ver, true ); // Enqueue the script wp_enqueue_script( 'my-functions5', trailingslashit( AI_POST_GENERATOR_PLUGIN_URL ) . "js/checkout.js", null, $my_js_checkout, true ); } }