batch-process/class-cartflows-importer-beaver-builder.php000066600000011457152133015060017656 0ustar00get_import_data( $data ); // Update page builder data. update_post_meta( $post_id, '_fl_builder_data', $data ); update_post_meta( $post_id, '_fl_builder_draft', $data ); // Clear all cache. FLBuilderModel::delete_asset_cache_for_all_posts(); } else { wcf()->logger->import_log( '(✕) Not have "Beaver Builder" Data. Post meta _fl_builder_data is empty!' ); } } /** * Update post meta. * * @param array $data Page builder data. * @return mixed */ public function get_import_data( $data ) { if ( empty( $data ) ) { return array(); } foreach ( $data as $key => $el ) { // Import 'row' images. if ( 'row' === $el->type ) { $data[ $key ]->settings = self::import_row_images( $el->settings ); } // Import 'module' images. if ( 'module' === $el->type ) { $data[ $key ]->settings = self::import_module_images( $el->settings ); } // Import 'column' images. if ( 'column' === $el->type ) { $data[ $key ]->settings = self::import_column_images( $el->settings ); } } return $data; } /** * Import Module Images. * * @param object $settings Module settings object. * @return object */ public static function import_module_images( $settings ) { /** * 1) Set photos. */ $settings = self::import_photo( $settings ); /** * 2) Set `$settings->data` for Only type 'image-icon' * * @todo Remove the condition `'image-icon' === $settings->type` if `$settings->data` is used only for the Image Icon. */ if ( isset( $settings->data ) && isset( $settings->photo ) && ! empty( $settings->photo ) && 'image-icon' === $settings->type ) { $settings->data = FLBuilderPhoto::get_attachment_data( $settings->photo ); } /** * 3) Set `list item` module images */ if ( isset( $settings->add_list_item ) ) { foreach ( $settings->add_list_item as $key => $value ) { $settings->add_list_item[ $key ] = self::import_photo( $value ); } } return $settings; } /** * Import Column Images. * * @param object $settings Column settings object. * @return object */ public static function import_column_images( $settings ) { // 1) Set BG Images. $settings = self::import_bg_image( $settings ); return $settings; } /** * Import Row Images. * * @param object $settings Row settings object. * @return object */ public static function import_row_images( $settings ) { // 1) Set BG Images. $settings = self::import_bg_image( $settings ); return $settings; } /** * Helper: Import BG Images. * * @param object $settings Row settings object. * @return object */ public static function import_bg_image( $settings ) { if ( ( ! empty( $settings->bg_image ) && ! empty( $settings->bg_image_src ) ) ) { $image = array( 'url' => $settings->bg_image_src, 'id' => $settings->bg_image, ); $downloaded_image = CartFlows_Import_Image::get_instance()->import( $image ); $settings->bg_image_src = $downloaded_image['url']; $settings->bg_image = $downloaded_image['id']; } return $settings; } /** * Helper: Import Photo. * * @param object $settings Row settings object. * @return object */ public static function import_photo( $settings ) { if ( ! empty( $settings->photo ) && ! empty( $settings->photo_src ) ) { $image = array( 'url' => $settings->photo_src, 'id' => $settings->photo, ); $downloaded_image = CartFlows_Import_Image::get_instance()->import( $image ); $settings->photo_src = $downloaded_image['url']; $settings->photo = $downloaded_image['id']; } return $settings; } } /** * Initialize class object with 'get_instance()' method */ CartFlows_Importer_Beaver_Builder::get_instance(); endif; batch-process/helpers/class-wp-background-process.php000066600000025270152133015060017004 0ustar00cron_hook_identifier = $this->identifier . '_cron'; $this->cron_interval_identifier = $this->identifier . '_cron_interval'; add_action( $this->cron_hook_identifier, array( $this, 'handle_cron_healthcheck' ) ); add_filter( 'cron_schedules', array( $this, 'schedule_cron_healthcheck' ) ); } /** * Dispatch * * @return mixed dispatch event. */ public function dispatch() { // Schedule the cron healthcheck. $this->schedule_event(); // Perform remote post. return parent::dispatch(); } /** * Push to queue * * @param mixed $data Data. * * @return $this */ public function push_to_queue( $data ) { $this->data[] = $data; return $this; } /** * Save queue * * @return $this */ public function save() { $key = $this->generate_key(); if ( ! empty( $this->data ) ) { update_site_option( $key, $this->data ); } return $this; } /** * Update queue * * @param string $key Key. * @param array $data Data. * * @return $this */ public function update( $key, $data ) { if ( ! empty( $data ) ) { update_site_option( $key, $data ); } return $this; } /** * Delete queue * * @param string $key Key. * * @return $this */ public function delete( $key ) { delete_site_option( $key ); return $this; } /** * Generate key * * Generates a unique key based on microtime. Queue items are * given a unique key so that they can be merged upon save. * * @param int $length Length. * * @return string */ protected function generate_key( $length = 64 ) { $unique = md5( microtime() . rand() ); $prepend = $this->identifier . '_batch_'; return substr( $prepend . $unique, 0, $length ); } /** * Maybe process queue * * Checks whether data exists within the queue and that * the process is not already running. */ public function maybe_handle() { // Don't lock up other requests while processing. session_write_close(); if ( $this->is_process_running() ) { // Background process already running. wp_die(); } if ( $this->is_queue_empty() ) { // No data to process. wp_die(); } check_ajax_referer( $this->identifier, 'nonce' ); $this->handle(); wp_die(); } /** * Is queue empty * * @return bool */ protected function is_queue_empty() { global $wpdb; $table = $wpdb->options; $column = 'option_name'; if ( is_multisite() ) { $table = $wpdb->sitemeta; $column = 'meta_key'; } $key = $this->identifier . '_batch_%'; $count = $wpdb->get_var( $wpdb->prepare( " SELECT COUNT(*) FROM {$table} WHERE {$column} LIKE %s ", $key ) ); return ( $count > 0 ) ? false : true; } /** * Is process running * * Check whether the current process is already running * in a background process. */ protected function is_process_running() { if ( get_site_transient( $this->identifier . '_process_lock' ) ) { // Process already running. return true; } return false; } /** * Lock process * * Lock the process so that multiple instances can't run simultaneously. * Override if applicable, but the duration should be greater than that * defined in the time_exceeded() method. */ protected function lock_process() { $this->start_time = time(); // Set start time of current process. $lock_duration = ( property_exists( $this, 'queue_lock_time' ) ) ? $this->queue_lock_time : 60; // 1 minute $lock_duration = apply_filters( $this->identifier . '_queue_lock_time', $lock_duration ); set_site_transient( $this->identifier . '_process_lock', microtime(), $lock_duration ); } /** * Unlock process * * Unlock the process so that other instances can spawn. * * @return $this */ protected function unlock_process() { delete_site_transient( $this->identifier . '_process_lock' ); return $this; } /** * Get batch * * @return stdClass Return the first batch from the queue */ protected function get_batch() { global $wpdb; $table = $wpdb->options; $column = 'option_name'; $key_column = 'option_id'; $value_column = 'option_value'; if ( is_multisite() ) { $table = $wpdb->sitemeta; $column = 'meta_key'; $key_column = 'meta_id'; $value_column = 'meta_value'; } $key = $this->identifier . '_batch_%'; $query = $wpdb->get_row( $wpdb->prepare( " SELECT * FROM {$table} WHERE {$column} LIKE %s ORDER BY {$key_column} ASC LIMIT 1 ", $key ) ); $batch = new stdClass(); $batch->key = $query->$column; $batch->data = maybe_unserialize( $query->$value_column ); return $batch; } /** * Handle * * Pass each queue item to the task handler, while remaining * within server memory and time limit constraints. */ protected function handle() { $this->lock_process(); do { $batch = $this->get_batch(); foreach ( $batch->data as $key => $value ) { $task = $this->task( $value ); if ( false !== $task ) { $batch->data[ $key ] = $task; } else { unset( $batch->data[ $key ] ); } if ( $this->time_exceeded() || $this->memory_exceeded() ) { // Batch limits reached. break; } } // Update or delete current batch. if ( ! empty( $batch->data ) ) { $this->update( $batch->key, $batch->data ); } else { $this->delete( $batch->key ); } } while ( ! $this->time_exceeded() && ! $this->memory_exceeded() && ! $this->is_queue_empty() ); $this->unlock_process(); // Start next batch or complete process. if ( ! $this->is_queue_empty() ) { $this->dispatch(); } else { $this->complete(); } wp_die(); } /** * Memory exceeded * * Ensures the batch process never exceeds 90% * of the maximum WordPress memory. * * @return bool */ protected function memory_exceeded() { $memory_limit = $this->get_memory_limit() * 0.9; // 90% of max memory $current_memory = memory_get_usage( true ); $return = false; if ( $current_memory >= $memory_limit ) { $return = true; } return apply_filters( $this->identifier . '_memory_exceeded', $return ); } /** * Get memory limit * * @return int */ protected function get_memory_limit() { if ( function_exists( 'ini_get' ) ) { $memory_limit = ini_get( 'memory_limit' ); } else { // Sensible default. $memory_limit = '128M'; } if ( ! $memory_limit || -1 === $memory_limit ) { // Unlimited, set to 32GB. $memory_limit = '32000M'; } return intval( $memory_limit ) * 1024 * 1024; } /** * Time exceeded. * * Ensures the batch never exceeds a sensible time limit. * A timeout limit of 30s is common on shared hosting. * * @return bool */ protected function time_exceeded() { $finish = $this->start_time + apply_filters( $this->identifier . '_default_time_limit', 20 ); // 20 seconds $return = false; if ( time() >= $finish ) { $return = true; } return apply_filters( $this->identifier . '_time_exceeded', $return ); } /** * Complete. * * Override if applicable, but ensure that the below actions are * performed, or, call parent::complete(). */ protected function complete() { // Unschedule the cron healthcheck. $this->clear_scheduled_event(); } /** * Schedule cron healthcheck * * @access public * @param mixed $schedules Schedules. * @return mixed */ public function schedule_cron_healthcheck( $schedules ) { $interval = apply_filters( $this->identifier . '_cron_interval', 5 ); if ( property_exists( $this, 'cron_interval' ) ) { $interval = apply_filters( $this->identifier . '_cron_interval', $this->cron_interval_identifier ); } // Adds every 5 minutes to the existing schedules. $schedules[ $this->identifier . '_cron_interval' ] = array( 'interval' => MINUTE_IN_SECONDS * $interval, 'display' => sprintf( __( 'Every %d Minutes', 'cartflows' ), $interval ), ); return $schedules; } /** * Handle cron healthcheck * * Restart the background process if not already running * and data exists in the queue. */ public function handle_cron_healthcheck() { if ( $this->is_process_running() ) { // Background process already running. exit; } if ( $this->is_queue_empty() ) { // No data to process. $this->clear_scheduled_event(); exit; } $this->handle(); exit; } /** * Schedule event */ protected function schedule_event() { if ( ! wp_next_scheduled( $this->cron_hook_identifier ) ) { wp_schedule_event( time(), $this->cron_interval_identifier, $this->cron_hook_identifier ); } } /** * Clear scheduled event */ protected function clear_scheduled_event() { $timestamp = wp_next_scheduled( $this->cron_hook_identifier ); if ( $timestamp ) { wp_unschedule_event( $timestamp, $this->cron_hook_identifier ); } } /** * Cancel Process * * Stop processing queue items, clear cronjob and delete batch. */ public function cancel_process() { if ( ! $this->is_queue_empty() ) { $batch = $this->get_batch(); $this->delete( $batch->key ); wp_clear_scheduled_hook( $this->cron_hook_identifier ); } } /** * Task * * Override this method to perform any actions required on each * queue item. Return the modified item for further processing * in the next pass through. Or, return false to remove the * item from the queue. * * @param mixed $item Queue item to iterate over. * * @return mixed */ abstract protected function task( $item ); } } batch-process/helpers/class-wp-async-request.php000066600000005613152133015060016013 0ustar00identifier = $this->prefix . '_' . $this->action; add_action( 'wp_ajax_' . $this->identifier, array( $this, 'maybe_handle' ) ); add_action( 'wp_ajax_nopriv_' . $this->identifier, array( $this, 'maybe_handle' ) ); } /** * Set data used during the request * * @param array $data Data. * * @return $this */ public function data( $data ) { $this->data = $data; return $this; } /** * Dispatch the async request * * @return array|WP_Error */ public function dispatch() { $url = add_query_arg( $this->get_query_args(), $this->get_query_url() ); $args = $this->get_post_args(); return wp_remote_post( esc_url_raw( $url ), $args ); } /** * Get query args * * @return array */ protected function get_query_args() { if ( property_exists( $this, 'query_args' ) ) { return $this->query_args; } return array( 'action' => $this->identifier, 'nonce' => wp_create_nonce( $this->identifier ), ); } /** * Get query URL * * @return string */ protected function get_query_url() { if ( property_exists( $this, 'query_url' ) ) { return $this->query_url; } return admin_url( 'admin-ajax.php' ); } /** * Get post args * * @return array */ protected function get_post_args() { if ( property_exists( $this, 'post_args' ) ) { return $this->post_args; } return array( 'timeout' => 0.01, 'blocking' => false, 'body' => $this->data, 'cookies' => $_COOKIE, 'sslverify' => apply_filters( 'https_local_ssl_verify', false ), ); } /** * Maybe handle * * Check for correct nonce and pass to handler. */ public function maybe_handle() { // Don't lock up other requests while processing. session_write_close(); check_ajax_referer( $this->identifier, 'nonce' ); $this->handle(); wp_die(); } /** * Handle * * Override this method to perform any actions required * during the async request. */ abstract protected function handle(); } } batch-process/helpers/class-cartflows-importer-image.php000066600000012733152133015060017510 0ustar00 How to use? * * $image = array( * 'url' => '', * 'id' => '', * ); * * $downloaded_image = CartFlows_Import_Image::get_instance()->import( $image ); * * @package CartFlows * * @since 1.1.1 */ if ( ! class_exists( 'CartFlows_Import_Image' ) ) : /** * CartFlows Importer * * @since 1.1.1 */ class CartFlows_Import_Image { /** * Instance * * @since 1.1.1 * @var object Class object. * @access private */ private static $instance; /** * Images IDs * * @var array The Array of already image IDs. * @since 1.1.1 */ private $already_imported_ids = array(); /** * Initiator * * @since 1.1.1 * @return object initialized object of class. */ public static function get_instance() { if ( ! isset( self::$instance ) ) { self::$instance = new self; } return self::$instance; } /** * Constructor * * @since 1.1.1 */ public function __construct() { if ( ! function_exists( 'WP_Filesystem' ) ) { require_once ABSPATH . 'wp-admin/includes/file.php'; } WP_Filesystem(); } /** * Process Image Download * * @since 1.1.1 * @param array $attachments Attachment array. * @return array Attachment array. */ public function process( $attachments ) { $downloaded_images = array(); foreach ( $attachments as $key => $attachment ) { $downloaded_images[] = $this->import( $attachment ); } return $downloaded_images; } /** * Get Hash Image. * * @since 1.1.1 * @param string $attachment_url Attachment URL. * @return string Hash string. */ private function get_hash_image( $attachment_url ) { return sha1( $attachment_url ); } /** * Get Saved Image. * * @since 1.1.1 * @param string $attachment Attachment Data. * @return string Hash string. */ private function get_saved_image( $attachment ) { wcf()->logger->import_log( 'importer-image.php File' ); if ( apply_filters( 'cartflows_image_importer_skip_image', false, $attachment ) ) { wcf()->logger->import_log( 'Download (✕) Replace (✕) - ' . $attachment['url'] ); return $attachment; } global $wpdb; // Already imported? Then return! if ( isset( $this->already_imported_ids[ $attachment['id'] ] ) ) { wcf()->logger->import_log( 'Download (✓) Replace (✓) - ' . $attachment['url'] ); return $this->already_imported_ids[ $attachment['id'] ]; } // 1. Is already imported in Batch Import Process? $post_id = $wpdb->get_var( $wpdb->prepare( " SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = '_cartflows_image_hash' AND meta_value = %s ", $this->get_hash_image( $attachment['url'] ) ) ); // 2. Is image already imported though XML? if ( empty( $post_id ) ) { // Get file name without extension. // To check it exist in attachment. $filename = basename( $attachment['url'] ); wcf()->logger->import_log( 'File Basename - ' . $filename ); $post_id = $wpdb->get_var( $wpdb->prepare( " SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = '_wp_attached_file' AND meta_value LIKE %s ", '%/' . $filename . '%' ) ); wcf()->logger->import_log( 'Download (✓) Replace (✓) - ' . $attachment['url'] ); } if ( $post_id ) { $new_attachment = array( 'id' => $post_id, 'url' => wp_get_attachment_url( $post_id ), ); $this->already_imported_ids[ $attachment['id'] ] = $new_attachment; return $new_attachment; } return false; } /** * Import Image * * @since 1.1.1 * @param array $attachment Attachment array. * @return array Attachment array. */ public function import( $attachment ) { $saved_image = $this->get_saved_image( $attachment ); if ( $saved_image ) { return $saved_image; } $file_content = wp_remote_retrieve_body( wp_safe_remote_get( $attachment['url'], array( 'timeout' => '60', 'sslverify' => false) ) ); // Empty file content? if ( empty( $file_content ) ) { wcf()->logger->import_log( 'Download (✕) Replace (✕) - ' . $attachment['url'] ); wcf()->logger->import_log( 'Error: Failed wp_remote_retrieve_body().' ); return $attachment; } // Extract the file name and extension from the URL. $filename = basename( $attachment['url'] ); $upload = wp_upload_bits( $filename, null, $file_content ); $post = array( 'post_title' => $filename, 'guid' => $upload['url'], ); $info = wp_check_filetype( $upload['file'] ); if ( $info ) { $post['post_mime_type'] = $info['type']; } else { // For now just return the origin attachment. return $attachment; } $post_id = wp_insert_attachment( $post, $upload['file'] ); wp_update_attachment_metadata( $post_id, wp_generate_attachment_metadata( $post_id, $upload['file'] ) ); update_post_meta( $post_id, '_cartflows_image_hash', $this->get_hash_image( $attachment['url'] ) ); $new_attachment = array( 'id' => $post_id, 'url' => $upload['url'], ); wcf()->logger->import_log( 'Download (✓) Replace (✓) - ' . $attachment['url'] ); $this->already_imported_ids[ $attachment['id'] ] = $new_attachment; return $new_attachment; } } /** * Initialize class object with 'get_instance()' method */ CartFlows_Import_Image::get_instance(); endif;batch-process/class-cartflows-batch-process.php000066600000016322152133015060015660 0ustar00is_divi_enabled() ) ) { require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-divi.php'; require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-divi-batch.php'; self::$batch_instance_divi = new Cartflows_Importer_Divi_Batch(); } // Start image importing after site import complete. add_action( 'cartflows_after_template_import', array( $this, 'start_batch_process' ) ); add_action( 'cartflows_import_complete', array( $this, 'complete_batch_import' ) ); add_filter( 'upload_mimes', array( $this, 'custom_upload_mimes' ) ); add_filter( 'wp_prepare_attachment_for_js', array( $this, 'add_svg_image_support' ), 10, 3 ); } /** * Added .svg files as supported format in the uploader. * * @since 1.1.4 * * @param array $mimes Already supported mime types. */ public function custom_upload_mimes( $mimes ) { // Allow SVG files. $mimes['svg'] = 'image/svg+xml'; $mimes['svgz'] = 'image/svg+xml'; // Allow XML files. $mimes['xml'] = 'text/xml'; return $mimes; } /** * Add SVG image support * * @since 1.1.4 * * @param array $response Attachment response. * @param object $attachment Attachment object. * @param array $meta Attachment meta data. */ public function add_svg_image_support( $response, $attachment, $meta ) { if ( ! function_exists( 'simplexml_load_file' ) ) { return $response; } if ( ! empty( $response['sizes'] ) ) { return $response; } if ( 'image/svg+xml' !== $response['mime'] ) { return $response; } $svg_path = get_attached_file( $attachment->ID ); $dimensions = self::get_svg_dimensions( $svg_path ); $response['sizes'] = array( 'full' => array( 'url' => $response['url'], 'width' => $dimensions->width, 'height' => $dimensions->height, 'orientation' => $dimensions->width > $dimensions->height ? 'landscape' : 'portrait', ), ); return $response; } /** * Get SVG Dimensions * * @since 1.1.4. * * @param string $svg SVG file path. * @return array Return SVG file height & width for valid SVG file. */ public static function get_svg_dimensions( $svg ) { $svg = simplexml_load_file( $svg ); if ( false === $svg ) { $width = '0'; $height = '0'; } else { $attributes = $svg->attributes(); $width = (string) $attributes->width; $height = (string) $attributes->height; } return (object) array( 'width' => $width, 'height' => $height, ); } /** * Batch Process Complete. * * @return void */ public function complete_batch_import() { wcf()->logger->import_log( '(✓) BATCH Process Complete!' ); } /** * Start Image Import * * @param integer $post_id Post Id. * * @return void */ public function start_batch_process( $post_id = '' ) { $default_page_builder = Cartflows_Helper::get_common_setting( 'default_page_builder' ); wcf()->logger->import_log( '(✓) BATCH Started!' ); wcf()->logger->import_log( '(✓) Step ID ' . $post_id ); // Add "elementor" in import [queue]. if ( 'beaver-builder' === $default_page_builder && self::$batch_instance_bb ) { // Add to queue. self::$batch_instance_bb->push_to_queue( $post_id ); // Dispatch Queue. self::$batch_instance_bb->save()->dispatch(); wcf()->logger->import_log( '(✓) Dispatch "Beaver Builder" Request..' ); } elseif ( 'elementor' === $default_page_builder && self::$batch_instance_elementor ) { // Add to queue. self::$batch_instance_elementor->push_to_queue( $post_id ); // Dispatch Queue. self::$batch_instance_elementor->save()->dispatch(); wcf()->logger->import_log( '(✓) Dispatch "Elementor" Request..' ); } elseif ( 'divi' === $default_page_builder && self::$batch_instance_divi ) { // Add to queue. self::$batch_instance_divi->push_to_queue( $post_id ); // Dispatch Queue. self::$batch_instance_divi->save()->dispatch(); wcf()->logger->import_log( '(✓) Dispatch "Divi" Request..' ); } else { wcf()->logger->import_log( '(✕) Could not import image due to allow_url_fopen() is disabled!' ); } } } /** * Kicking this off by calling 'get_instance()' method */ CartFlows_Batch_Process::get_instance(); endif; batch-process/class-cartflows-importer-divi-batch.php000066600000002231152133015060016766 0ustar00import_single_post( $post_id ); return false; } /** * Complete * * Override if applicable, but ensure that the below actions are * performed, or, call parent::complete(). * * @since 1.1.1 */ protected function complete() { parent::complete(); do_action( 'cartflows_import_complete' ); } } endif; batch-process/class-cartflows-change-template-batch.php000066600000002546152133015060017243 0ustar00logger->log( '(✓) Step ID ' . $post_id ); if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { error_log( 'Processed:' . $post_id ); //phpcs:ignore } update_post_meta( $post_id, '_wp_page_template', 'cartflows-default' ); return false; } /** * Complete * * Override if applicable, but ensure that the below actions are * performed, or, call parent::complete(). */ protected function complete() { parent::complete(); if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { error_log( 'Process Complete' );//phpcs:ignore } } } endif; batch-process/class-cartflows-importer-beaver-builder-batch.php000066600000002313152133015060020724 0ustar00import_single_post( $post_id ); return false; } /** * Complete * * Override if applicable, but ensure that the below actions are * performed, or, call parent::complete(). * * @since 1.1.1 */ protected function complete() { parent::complete(); do_action( 'cartflows_import_complete' ); } } endif; batch-process/class-cartflows-importer-elementor.php000066600000003314152133015060016751 0ustar00logger->import_log( '(✕) ' . $data ); } $rest_content = add_magic_quotes( $rest_content ); $content = json_decode( $rest_content, true ); if ( ! is_array( $content ) ) { $data = __( 'Invalid content. Expected an array.', 'cartflows' ); wcf()->logger->import_log( '(✕) ' . $data ); wcf()->logger->import_log( $content ); } else { wcf()->logger->import_log( '(✓) Processing Request..' ); // Import the data. $content = $this->process_export_import_content( $content, 'on_import' ); // Update content. update_metadata( 'post', $post_id, '_elementor_data', $content ); wcf()->logger->import_log( '(✓) Process Complete' ); } } } batch-process/class-cartflows-importer-elementor-batch.php000066600000002430152133015060020026 0ustar00import_single_template( $post_id ); return false; } /** * Complete * * Override if applicable, but ensure that the below actions are * performed, or, call parent::complete(). * * @since 1.0.0 */ protected function complete() { parent::complete(); do_action( 'cartflows_import_complete' ); } } endif; batch-process/class-cartflows-importer-divi.php000066600000005033152133015060015712 0ustar00 tag and attributes. $allowedposttags['style'] = array(); } return $allowedposttags; } /** * Update post meta. * * @param integer $post_id Post ID. * @return void */ public function import_single_post( $post_id = 0 ) { // Allow the SVG tags in batch update process. add_filter( 'wp_kses_allowed_html', array( $this, 'allowed_tags_and_attributes' ), 10, 2 ); // Download and replace images. $content = get_post_meta( $post_id, 'divi_content', true ); if ( empty( $content ) ) { wcf()->logger->import_log( '(✕) Not have "Divi" Data. Post content is empty!' ); } else { wcf()->logger->import_log( '(✓) Processing Request..' ); // Update hotlink images. $content = CartFlows_Importer::get_instance()->get_content( $content ); // Update post content. wp_update_post( array( 'ID' => $post_id, 'post_content' => $content, ) ); // Delete temporary meta key. delete_post_meta( $post_id, 'divi_content' ); wcf()->logger->import_log( '(✓) Process Complete' ); } } } /** * Initialize class object with 'get_instance()' method */ CartFlows_Importer_Divi::get_instance(); endif; class-cartflows-admin.php000066600000044554152133015060011466 0ustar00Settings', 'Docs', ); if ( ! _is_cartflows_pro() ) { array_push( $mylinks, ' Go Pro ' ); } return array_merge( $links, $mylinks ); } /** * Initialises the Plugin Name. * * @since 1.0.0 * @return void */ public static function initialise_plugin() { $name = 'Cartflows'; $short_name = 'Cflows'; define( 'CARTFLOWS_PLUGIN_NAME', $name ); define( 'CARTFLOWS_PLUGIN_SHORT_NAME', $short_name ); } /** * Renders the admin settings menu. * * @since 1.0.0 * @return void */ public static function menu() { if ( ! current_user_can( 'manage_options' ) ) { return; } add_menu_page( 'CartFlows', 'CartFlows', 'manage_options', CARTFLOWS_SLUG, __CLASS__ . '::render', 'data:image/svg+xml;base64,' . base64_encode( file_get_contents( CARTFLOWS_DIR . 'assets/images/cartflows-icon.svg' ) ),//phpcs:ignore 39.7 ); } /** * Add submenu to admin menu. * * @since 1.0.0 */ public static function submenu() { $parent_slug = CARTFLOWS_SLUG; $page_title = __( 'Settings', 'cartflows' ); $menu_title = __( 'Settings', 'cartflows' ); $capability = 'manage_options'; $menu_slug = 'cartflows_settings'; $callback = __CLASS__ . '::render'; add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $callback ); } /** * Renders the admin settings. * * @since 1.0.0 * @return void */ public static function render() { $action = ( isset( $_GET['action'] ) ) ? sanitize_text_field( wp_unslash( $_GET['action'] ) ) : ''; //phpcs:ignore $action = ( ! empty( $action ) && '' != $action ) ? $action : 'general'; $action = str_replace( '_', '-', $action ); // Enable header icon filter below. $header_wrapper_class = apply_filters( 'cartflows_header_wrapper_class', array( $action ) ); include_once CARTFLOWS_DIR . 'includes/admin/cartflows-admin.php'; } /** * Renders the admin settings content. * * @since 1.0.0 * @return void */ public static function render_content() { $action = ( isset( $_GET['action'] ) ) ? sanitize_text_field( wp_unslash( $_GET['action'] ) ) : ''; //phpcs:ignore $action = ( ! empty( $action ) && '' != $action ) ? $action : 'general'; $action = str_replace( '_', '-', $action ); $action = 'general'; $header_wrapper_class = apply_filters( 'cartflows_header_wrapper_class', array( $action ) ); include_once CARTFLOWS_DIR . 'includes/admin/cartflows-general.php'; } /** * Save Global Setting options. * * @since 1.0.0 */ public static function save_common_settings() { if ( isset( $_POST['cartflows-common-settings-nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['cartflows-common-settings-nonce'] ) ), 'cartflows-common-settings' ) ) { $url = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : ''; $new_settings = array(); if ( isset( $_POST['_cartflows_common'] ) ) { // Loop through the input and sanitize each of the values. $new_settings = self::sanitize_form_inputs( wp_unslash( $_POST['_cartflows_common'] ) ); //phpcs:ignore } Cartflows_Helper::update_admin_settings_option( '_cartflows_common', $new_settings, false ); $query = array( 'message' => 'saved', ); $redirect_to = add_query_arg( $query, $url ); wp_safe_redirect( $redirect_to ); exit; } // End if statement. } /** * Save Debug Setting options. * * @since 1.1.14 */ public static function save_debug_settings() { if ( isset( $_POST['cartflows-debug-settings-nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['cartflows-debug-settings-nonce'] ) ), 'cartflows-debug-settings' ) ) { $url = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : ''; $new_settings = array(); if ( isset( $_POST['_cartflows_debug_data'] ) ) { $new_settings = self::sanitize_form_inputs( wp_unslash( $_POST['_cartflows_debug_data'] ) ); //phpcs:ignore } Cartflows_Helper::update_admin_settings_option( '_cartflows_debug_data', $new_settings, false ); $query = array( 'message' => 'saved', ); $redirect_to = add_query_arg( $query, $url ); wp_safe_redirect( $redirect_to ); exit; } } /** * Save permalink Setting options. * * @since 1.1.14 */ public static function save_permalink_settings() { if ( isset( $_POST['cartflows-permalink-settings-nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['cartflows-permalink-settings-nonce'] ) ), 'cartflows-permalink-settings' ) ) { $url = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : ''; $new_settings = array(); if ( isset( $_POST['reset'] ) ) { $_POST['_cartflows_permalink'] = array( 'permalink' => CARTFLOWS_STEP_POST_TYPE, 'permalink_flow_base' => CARTFLOWS_FLOW_POST_TYPE, 'permalink_structure' => '', ); } if ( isset( $_POST['_cartflows_permalink'] ) ) { $cartflows_permalink_settings = self::sanitize_form_inputs( wp_unslash( $_POST['_cartflows_permalink'] ) ); //phpcs:ignore if ( empty( $cartflows_permalink_settings['permalink'] ) ) { $new_settings['permalink'] = CARTFLOWS_STEP_POST_TYPE; } else { $new_settings['permalink'] = $cartflows_permalink_settings['permalink']; } if ( empty( $cartflows_permalink_settings['permalink_flow_base'] ) ) { $new_settings['permalink_flow_base'] = CARTFLOWS_FLOW_POST_TYPE; } else { $new_settings['permalink_flow_base'] = $cartflows_permalink_settings['permalink_flow_base']; } $new_settings['permalink_structure'] = $cartflows_permalink_settings['permalink_structure']; } Cartflows_Helper::update_admin_settings_option( '_cartflows_permalink', $new_settings, false ); $query = array( 'message' => 'saved', ); $redirect_to = add_query_arg( $query, $url ); update_option( 'cartflows_permalink_saved', true ); wp_safe_redirect( $redirect_to ); exit; } } /** * Save google analytics Setting options. * * @since 1.1.14 */ public static function save_google_analytics_settings() { if ( isset( $_POST['cartflows-google-analytics-settings-nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['cartflows-google-analytics-settings-nonce'] ) ), 'cartflows-google-analytics-settings' ) ) { $url = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : ''; $new_settings = array(); if ( isset( $_POST['_cartflows_google_analytics'] ) ) { $new_settings = self::sanitize_form_inputs( $_POST['_cartflows_google_analytics'] ); //phpcs:ignore } Cartflows_Helper::update_admin_settings_option( '_cartflows_google_analytics', $new_settings, true ); $query = array( 'message' => 'saved', ); $redirect_to = add_query_arg( $query, $url ); wp_safe_redirect( $redirect_to ); exit; } } /** * Loop through the input and sanitize each of the values. * * @param array $input_settings input settings. * @return array */ public static function sanitize_form_inputs( $input_settings = array() ) { $new_settings = array(); foreach ( $input_settings as $key => $val ) { if ( is_array( $val ) ) { foreach ( $val as $k => $v ) { $new_settings[ $key ][ $k ] = ( isset( $val[ $k ] ) ) ? sanitize_text_field( $v ) : ''; } } else { $new_settings[ $key ] = ( isset( $input_settings[ $key ] ) ) ? sanitize_text_field( $val ) : ''; } } return $new_settings; } /** * Check is cartflows admin. * * @since 1.0.0 * @return boolean */ public static function is_global_admin() { $current_screen = get_current_screen(); if ( is_object( $current_screen ) && isset( $current_screen->post_type ) && ( CARTFLOWS_FLOW_POST_TYPE === $current_screen->post_type || CARTFLOWS_STEP_POST_TYPE === $current_screen->post_type ) ) { return true; } return false; } /** * Check is flow admin. * * @since 1.0.0 * @return boolean */ public static function is_flow_edit_admin() { $current_screen = get_current_screen(); if ( is_object( $current_screen ) && isset( $current_screen->post_type ) && ( CARTFLOWS_FLOW_POST_TYPE === $current_screen->post_type ) && isset( $current_screen->base ) && ( 'post' === $current_screen->base ) ) { return true; } return false; } /** * Global Admin Scripts. * * @since 1.0.0 */ public static function global_admin_scripts() { $installed_plugins = get_plugins(); $is_wc_installed = isset( $installed_plugins['woocommerce/woocommerce.php'] ) ? true : false; $edit_test_mode = filter_input( INPUT_GET, 'edit_test_mode', FILTER_SANITIZE_STRING ); $edit_test_mode = 'yes' === $edit_test_mode ? true : false; $localize = array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'ajax_nonce' => wp_create_nonce( 'cartflows-nonce' ), 'wc_status' => array( 'installed' => $is_wc_installed, 'active' => wcf()->is_woo_active, ), 'wc_activating_message' => __( 'Installing and activating..', 'cartflows' ), 'wc_install_error' => __( 'There was an error with the installation of plugin.', 'cartflows' ), 'wcf_edit_test_mode' => $edit_test_mode, ); wp_localize_script( 'jquery', 'cartflows_admin', apply_filters( 'cartflows_admin_js_localize', $localize ) ); if ( self::is_global_admin() ) { // Styles. wp_enqueue_style( 'cartflows-global-admin', CARTFLOWS_URL . 'admin/assets/css/global-admin.css', array(), CARTFLOWS_VER ); wp_style_add_data( 'cartflows-global-admin', 'rtl', 'replace' ); wp_enqueue_script( 'wcf-global-admin', CARTFLOWS_URL . 'admin/assets/js/global-admin.js', array( 'jquery' ), CARTFLOWS_VER, true ); do_action( 'cartflows_global_admin_scripts' ); } } /** * Global Admin Data. * * @since 1.0.0 */ public static function global_admin_data() { $current_screen = get_current_screen(); if ( ! $current_screen ) { return; } if ( 'edit-' . CARTFLOWS_FLOW_POST_TYPE != $current_screen->id ) { return; } $default_page_builder = Cartflows_Helper::get_common_setting( 'default_page_builder' ); ?> wp_create_nonce( 'cartflows-widget-nonce' ), ); wp_localize_script( 'cartflows-admin-settings', 'cartflows', apply_filters( 'cartflows_js_localize', $localize ) ); do_action( 'cartflows_admin_settings_after_enqueue_scripts' ); } /** * Save All admin settings here */ public static function save_settings() { // Only admins can save settings. if ( ! current_user_can( 'manage_options' ) ) { return; } self::save_common_settings(); self::save_debug_settings(); self::save_permalink_settings(); self::save_google_analytics_settings(); self::save_facebook_settings(); // Let extensions hook into saving. do_action( 'cartflows_admin_settings_save' ); } /** * Get and return page URL * * @param string $menu_slug Menu name. * @since 1.0.0 * @return string page url */ public static function get_page_url( $menu_slug ) { $parent_page = self::$default_menu_position; if ( strpos( $parent_page, '?' ) !== false ) { $query_var = '&page=' . self::$plugin_slug; } else { $query_var = '?page=' . self::$plugin_slug; } $parent_page_url = admin_url( $parent_page . $query_var ); $url = $parent_page_url . '&action=' . $menu_slug; return esc_url( $url ); } /** * Admin body classes. * * Body classes to be added to tag in admin page * * @param String $classes body classes returned from the filter. * @return String body classes to be added to tag in admin page */ public static function add_admin_body_class( $classes ) { $classes .= ' cartflows-' . CARTFLOWS_VER; return $classes; } /** * Save Global Setting options. * * @since 1.0.0 */ public static function save_facebook_settings() { if ( isset( $_POST['cartflows-facebook-settings-nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['cartflows-facebook-settings-nonce'] ) ), 'cartflows-facebook-settings' ) ) { $url = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : ''; $new_settings = array(); if ( isset( $_POST['_cartflows_facebook'] ) ) { $new_settings = self::sanitize_form_inputs( wp_unslash( $_POST['_cartflows_facebook'] ) ); //phpcs:ignore } Cartflows_Helper::update_admin_settings_option( '_cartflows_facebook', $new_settings, false ); $query = array( 'message' => 'saved', ); $redirect_to = add_query_arg( $query, $url ); wp_safe_redirect( $redirect_to ); exit; } } } Cartflows_Admin::init(); class-cartflows-utils.php000066600000020355152133015060011527 0ustar00get_step_post_type() === $this->current_post_type( $post_type ) ) { return true; } return false; } /** * Check if post type is of flow. * * @param string $post_type post type. * @return bool */ public function is_flow_post_type( $post_type = '' ) { if ( $this->get_flow_post_type() === $this->current_post_type( $post_type ) ) { return true; } return false; } /** * Get post type of step. * * @return string */ public function get_step_post_type() { return CARTFLOWS_STEP_POST_TYPE; } /** * Get post type of flow. * * @return string */ public function get_flow_post_type() { return CARTFLOWS_FLOW_POST_TYPE; } /** * Get flow id * * @return int */ public function get_flow_id() { global $post; return get_post_meta( $post->ID, 'wcf-flow-id', true ); } /** * Get flow id by step * * @param int $step_id step ID. * @return int */ public function get_flow_id_from_step_id( $step_id ) { return get_post_meta( $step_id, 'wcf-flow-id', true ); } /** * Get flow steps by id * * @param int $flow_id flow ID. * @return int */ public function get_flow_steps( $flow_id ) { $steps = get_post_meta( $flow_id, 'wcf-steps', true ); if ( is_array( $steps ) && ! empty( $steps ) ) { return $steps; } return false; } /** * Get template type of step * * @param int $step_id step ID. * @return int */ public function get_step_type( $step_id ) { return get_post_meta( $step_id, 'wcf-step-type', true ); } /** * Get next id for step * * @param int $flow_id flow ID. * @param int $step_id step ID. * @return bool */ public function get_next_step_id( $flow_id, $step_id ) { $steps = $this->get_flow_steps( $flow_id ); $step_id = intval( $step_id ); if ( ! $steps ) { return false; } foreach ( $steps as $i => $step ) { if ( intval( $step['id'] ) === $step_id ) { $next_i = $i + 1; if ( isset( $steps[ $next_i ] ) ) { $navigation = $steps[ $next_i ]; return intval( $navigation['id'] ); } break; } } return false; } /** * Get next id for step * * @param int $order_id order ID. * @return int */ public function get_flow_id_from_order( $order_id ) { $flow_id = get_post_meta( $order_id, '_wcf_flow_id', true ); return intval( $flow_id ); } /** * Get checkout id for order * * @param int $order_id order ID. * @return int */ public function get_checkout_id_from_order( $order_id ) { $checkout_id = get_post_meta( $order_id, '_wcf_checkout_id', true ); return intval( $checkout_id ); } /** * We are using this function mostly in ajax on checkout page * * @return bool */ public function get_checkout_id_from_post_data() { if ( isset( $_POST['_wcf_checkout_id'] ) ) { //phpcs:ignore $checkout_id = filter_var( wp_unslash( $_POST['_wcf_checkout_id'] ), FILTER_SANITIZE_NUMBER_INT ); //phpcs:ignore return intval( $checkout_id ); } return false; } /** * We are using this function mostly in ajax on checkout page * * @return bool */ public function get_flow_id_from_post_data() { if ( isset( $_POST['_wcf_flow_id'] ) ) { //phpcs:ignore $flow_id = filter_var( wp_unslash( $_POST['_wcf_flow_id'] ), FILTER_SANITIZE_NUMBER_INT ); //phpcs:ignore return intval( $flow_id ); } return false; } /** * Get optin id for order * * @param int $order_id order ID. * @return int */ public function get_optin_id_from_order( $order_id ) { $optin_id = get_post_meta( $order_id, '_wcf_optin_id', true ); return intval( $optin_id ); } /** * We are using this function mostly in ajax on checkout page * * @return bool */ public function get_optin_id_from_post_data() { if ( isset( $_POST['_wcf_optin_id'] ) ) { //phpcs:ignore $optin_id = filter_var( wp_unslash( $_POST['_wcf_optin_id'] ), FILTER_SANITIZE_NUMBER_INT ); //phpcs:ignore return intval( $optin_id ); } return false; } /** * Check for thank you page * * @param int $step_id step ID. * @return bool */ public function check_is_thankyou_page( $step_id ) { $step_type = $this->get_step_type( $step_id ); if ( 'thankyou' === $step_type ) { return true; } return false; } /** * Check for offer page * * @param int $step_id step ID. * @return bool */ public function check_is_offer_page( $step_id ) { $step_type = $this->get_step_type( $step_id ); if ( 'upsell' === $step_type || 'downsell' === $step_type ) { return true; } return false; } /** * Check if loaded page requires woo. * * @return bool */ public function check_is_woo_required_page() { global $post; $step_id = $post->ID; $woo_not_required_type = array( 'landing' ); $step_type = $this->get_step_type( $step_id ); return ( ! in_array( $step_type, $woo_not_required_type, true ) ); } /** * Define constant for cache * * @return void */ public function do_not_cache() { wcf_maybe_define_constant( 'DONOTCACHEPAGE', true ); wcf_maybe_define_constant( 'DONOTCACHEOBJECT', true ); wcf_maybe_define_constant( 'DONOTCACHEDB', true ); nocache_headers(); } /** * Get linking url * * @param array $args query args. * @return string */ public function get_linking_url( $args = array() ) { $url = get_home_url(); $url = add_query_arg( $args, $url ); return $url; } /** * Get assets urls * * @return array * @since 1.1.6 */ public function get_assets_path() { $rtl = ''; if ( is_rtl() ) { $rtl = '-rtl'; } $file_prefix = ''; $dir_name = ''; $is_min = apply_filters( 'cartflows_load_min_assets', false ); if ( $is_min ) { $file_prefix = '.min'; $dir_name = 'min-'; } $js_gen_path = CARTFLOWS_URL . 'assets/' . $dir_name . 'js/'; $css_gen_path = CARTFLOWS_URL . 'assets/' . $dir_name . 'css/'; return array( 'css' => $css_gen_path, 'js' => $js_gen_path, 'file_prefix' => $file_prefix, 'rtl' => $rtl, ); } /** * Get assets css url * * @param string $file file name. * @return string * @since 1.1.6 */ public function get_css_url( $file ) { $assets_vars = wcf()->assets_vars; $url = $assets_vars['css'] . $file . $assets_vars['rtl'] . $assets_vars['file_prefix'] . '.css'; return $url; } /** * Get assets js url * * @param string $file file name. * @return string * @since 1.1.6 */ public function get_js_url( $file ) { $assets_vars = wcf()->assets_vars; $url = $assets_vars['js'] . $file . $assets_vars['file_prefix'] . '.js'; return $url; } } /** * Get a specific property of an array without needing to check if that property exists. * * Provide a default value if you want to return a specific value if the property is not set. * * @param array $array Array from which the property's value should be retrieved. * @param string $prop Name of the property to be retrieved. * @param string $default Optional. Value that should be returned if the property is not set or empty. Defaults to null. * * @return null|string|mixed The value */ function wcf_get_prop( $array, $prop, $default = null ) { if ( ! is_array( $array ) && ! ( is_object( $array ) && $array instanceof ArrayAccess ) ) { return $default; } if ( isset( $array[ $prop ] ) ) { $value = $array[ $prop ]; } else { $value = ''; } return empty( $value ) && null !== $default ? $default : $value; } class-cartflows-learndash-compatibility.php000066600000006557152133015060015207 0ustar00' ) ) { $template = learndash_get_course_meta_setting( get_the_id(), 'wcf_course_template' ); } else { $template = get_course_meta_setting( get_the_id(), 'wcf_course_template' ); } if ( 'none' !== $template && $template ) { $link = get_permalink( $template ); wp_safe_redirect( $link ); } } /** * Add settings inside learndash settings. * * @param array $fields fields. * @return mixed */ public function cartflows_course_setting_fields( $fields ) { global $post; $all_posts = array( 'none' => __( 'None', 'cartflows' ), ); $landing_steps = get_posts( array( 'posts_per_page' => -1, 'post_type' => CARTFLOWS_STEP_POST_TYPE, 'post_status' => 'publish', 'orderby' => 'ID', 'order' => 'DESC', 'meta_query' => array( //phpcs:ignore array( 'key' => 'wcf-step-type', 'value' => array( 'landing', 'checkout', 'optin' ), 'compare' => 'IN', ), ), ) ); foreach ( $landing_steps as $landing_step ) { $all_posts[ $landing_step->ID ] = get_the_title( $landing_step->ID ) . ' ( #' . $landing_step->ID . ')'; } $selected = get_post_meta( get_the_ID(), 'wcf_course_template', true ); $description = sprintf( /* translators: 1: anchor start, 2: anchor close */ __( 'Non-enrolled students will redirect to the selected CartFlows template. If you have not created any Flow already, add new Flow from %1$shere%2$s.', 'cartflows' ), '', '' ); $fields['sfwd-courses']['fields']['wcf_course_template'] = array( 'name' => __( 'Select CartFlows Template for this Course', 'cartflows' ), 'type' => 'select', 'initial_options' => $all_posts, 'default' => 'none', 'help_text' => $description, 'show_in_rest' => true, 'rest_args' => array( 'schema' => array( 'type' => 'string', ), ), ); return $fields; } } /** * Kicking this off by calling 'get_instance()' method */ Cartflows_Learndash_Compatibility::get_instance(); class-cartflows-frontend.php000066600000041045152133015060012205 0ustar00logger->log( 'Start-' . __CLASS__ . '::' . __FUNCTION__ ); wcf()->logger->log( 'Only for thank you page' ); if ( wcf()->flow->is_thankyou_page_exists( $order ) ) { if ( _is_wcf_doing_checkout_ajax() ) { $checkout_id = wcf()->utils->get_checkout_id_from_post_data(); if ( ! $checkout_id ) { $checkout_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() ); } } else { $checkout_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() ); } wcf()->logger->log( 'Checkout ID : ' . $checkout_id ); if ( $checkout_id ) { $thankyou_step_id = wcf()->flow->get_thankyou_page_id( $order ); if ( $thankyou_step_id ) { $order_recieve_url = get_permalink( $thankyou_step_id ); $order_recieve_url = add_query_arg( array( 'wcf-key' => $order->get_order_key(), 'wcf-order' => $order->get_id(), ), $order_recieve_url ); } } } wcf()->logger->log( 'End-' . __CLASS__ . '::' . __FUNCTION__ ); Cartflows_Helper::send_fb_response_if_enabled( $order->get_id() ); Cartflows_Tracking::send_ga_data_if_enabled( $order->get_id() ); return $order_recieve_url; } /** * Cancel and redirect to checkout * * @param string $return_url url. * @since 1.0.0 */ public function redirect_to_checkout_on_cancel( $return_url ) { if ( _is_wcf_doing_checkout_ajax() ) { $checkout_id = wcf()->utils->get_checkout_id_from_post_data(); if ( ! $checkout_id ) { $checkout_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() ); } } else { $checkout_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() ); } if ( $checkout_id ) { $return_url = add_query_arg( array( 'cancel_order' => 'true', '_wpnonce' => wp_create_nonce( 'woocommerce-cancel_order' ), ), get_permalink( $checkout_id ) ); } return $return_url; } /** * Remove theme styles. * * @since 1.0.0 */ public function remove_theme_styles() { if ( Cartflows_Compatibility::get_instance()->is_compatibility_theme_enabled() ) { return; } $page_template = get_post_meta( _get_wcf_step_id(), '_wp_page_template', true ); $page_template = apply_filters( 'cartflows_page_template', $page_template ); if ( 'default' === $page_template ) { return; } // get all styles data. global $wp_styles; global $wp_scripts; $get_stylesheet = 'themes/' . get_stylesheet() . '/'; $get_template = 'themes/' . get_template() . '/'; $remove_styles = apply_filters( 'cartflows_remove_theme_styles', true ); if ( $remove_styles ) { // loop over all of the registered scripts.. foreach ( $wp_styles->registered as $handle => $data ) { if ( strpos( $data->src, $get_template ) !== false || strpos( $data->src, $get_stylesheet ) !== false ) { // remove it. wp_deregister_style( $handle ); wp_dequeue_style( $handle ); } } } $remove_scripts = apply_filters( 'cartflows_remove_theme_scripts', true ); if ( $remove_scripts ) { // loop over all of the registered scripts. foreach ( $wp_scripts->registered as $handle => $data ) { if ( strpos( $data->src, $get_template ) !== false || strpos( $data->src, $get_stylesheet ) !== false ) { // remove it. wp_deregister_script( $handle ); wp_dequeue_script( $handle ); } } } } /** * Update main order data in transient. * * @param array $woo_styles new styles array. * @since 1.0.0 * @return array. */ public function woo_default_css( $woo_styles ) { $woo_styles = array( 'woocommerce-layout' => array( 'src' => plugins_url( 'assets/css/woocommerce-layout.css', WC_PLUGIN_FILE ), 'deps' => '', 'version' => WC_VERSION, 'media' => 'all', 'has_rtl' => true, ), 'woocommerce-smallscreen' => array( 'src' => plugins_url( 'assets/css/woocommerce-smallscreen.css', WC_PLUGIN_FILE ), 'deps' => 'woocommerce-layout', 'version' => WC_VERSION, 'media' => 'only screen and (max-width: ' . apply_filters( 'woocommerce_style_smallscreen_breakpoint', '768px' ) . ')', 'has_rtl' => true, ), 'woocommerce-general' => array( 'src' => plugins_url( 'assets/css/woocommerce.css', WC_PLUGIN_FILE ), 'deps' => '', 'version' => WC_VERSION, 'media' => 'all', 'has_rtl' => true, ), ); return $woo_styles; } /** * Init Actions. * * @since 1.0.0 */ public function init_actions() { $this->set_flow_session(); } /** * Set flow session. * * @since 1.0.0 */ public function set_flow_session() { if ( wcf()->utils->is_step_post_type() ) { global $wp; add_action( 'wp_head', array( $this, 'noindex_flow' ) ); wcf()->utils->do_not_cache(); if ( _is_wcf_thankyou_type() ) { /* Set key to support pixel */ if ( isset( $_GET['wcf-key'] ) ) { //phpcs:ignore $wcf_key = sanitize_text_field( wp_unslash( $_GET['wcf-key'] ) ); //phpcs:ignore $_GET['key'] = $wcf_key; $_REQUEST['key'] = $wcf_key; } if ( isset( $_GET['wcf-order'] ) ) { //phpcs:ignore $wcf_order = intval( wp_unslash( $_GET['wcf-order'] ) ); //phpcs:ignore $_GET['order'] = $wcf_order; $_REQUEST['order'] = $wcf_order; $_GET['order-received'] = $wcf_order; $_REQUEST['order-received'] = $wcf_order; $wp->set_query_var( 'order-received', $wcf_order ); } } } } /** * Add noindex, nofollow. * * @since 1.0.0 */ public function noindex_flow() { $common = Cartflows_Helper::get_common_settings(); if ( 'enable' === $common['disallow_indexing'] ) { echo ''; } } /** * WP Actions. * * @since 1.0.0 */ public function wp_actions() { if ( wcf()->utils->is_step_post_type() ) { if ( ! wcf()->is_woo_active && wcf()->utils->check_is_woo_required_page() ) { wp_die( ' This page requires WooCommerce plugin installed and activated!', 'WooCommerce Required' ); } /* CSS Compatibility for All theme */ add_filter( 'woocommerce_enqueue_styles', array( $this, 'woo_default_css' ), 9999 ); add_action( 'wp_enqueue_scripts', array( $this, 'remove_theme_styles' ), 9999 ); add_action( 'wp_enqueue_scripts', array( $this, 'global_flow_scripts' ), 20 ); /* Load woo templates from plugin */ add_filter( 'woocommerce_locate_template', array( $this, 'override_woo_template' ), 20, 3 ); /* Add version class to body in frontend. */ add_filter( 'body_class', array( $this, 'add_cartflows_lite_version_to_body' ) ); /* Custom Script Option */ add_action( 'wp_head', array( $this, 'custom_script_option' ) ); /* Remove the action applied by the Flatsome theme */ if ( Cartflows_Compatibility::get_instance()->is_flatsome_enabled() ) { $this->remove_flatsome_action(); } } } /** * Function for facebook pixel. */ public function facebook_pixel_init() { $facebook_settings = Cartflows_Helper::get_facebook_settings(); if ( 'enable' === $facebook_settings['facebook_pixel_tracking'] ) { $facebook_id = $facebook_settings['facebook_pixel_id']; echo ''; $fb_script = " "; $fb_page_view = ""; if ( 'enable' === $facebook_settings['facebook_pixel_tracking_for_site'] && ! wcf()->utils->is_step_post_type() ) { echo $fb_script; echo $fb_page_view; } else { echo $fb_script; } echo ''; } } /** * Debug Data Setting Actions. * * @since 1.1.14 */ public function debug_data_setting_actions() { add_filter( 'cartflows_load_min_assets', array( $this, 'allow_load_minify' ) ); } /** * Get/Set the allow minify option. * * @since 1.1.14 */ public function allow_load_minify() { $debug_data = Cartflows_Helper::get_debug_settings(); $allow_minified = $debug_data['allow_minified_files']; $allow_minify = false; if ( 'enable' === $allow_minified ) { $allow_minify = true; } return $allow_minify; } /** * Global flow scripts. * * @since 1.0.0 */ public function global_flow_scripts() { global $post; $flow = get_post_meta( $post->ID, 'wcf-flow-id', true ); $current_step = $post->ID; $next_step_link = ''; $compatibility = Cartflows_Compatibility::get_instance(); if ( _is_wcf_landing_type() ) { $next_step_id = wcf()->utils->get_next_step_id( $flow, $current_step ); $next_step_link = get_permalink( $next_step_id ); } $page_template = get_post_meta( _get_wcf_step_id(), '_wp_page_template', true ); $fb_active = Cartflows_Helper::get_facebook_settings(); $wcf_ga_active = Cartflows_Helper::get_google_analytics_settings(); $params = array(); $ga_param = array(); if ( 'enable' === $fb_active['facebook_pixel_tracking'] && Cartflows_Loader::get_instance()->is_woo_active ) { $params = Cartflows_Helper::prepare_cart_data_fb_response(); } if ( 'enable' === $wcf_ga_active['enable_google_analytics'] ) { $ga_param = Cartflows_Tracking::get_ga_items_list(); } $localize = array( 'ajax_url' => admin_url( 'admin-ajax.php', 'relative' ), 'is_pb_preview' => $compatibility->is_page_builder_preview(), 'current_theme' => $compatibility->get_current_theme(), 'current_flow' => $flow, 'current_step' => $current_step, 'next_step' => $next_step_link, 'page_template' => $page_template, 'is_checkout_page' => _is_wcf_checkout_type(), 'params' => $params, 'fb_active' => $fb_active, 'wcf_ga_active' => $wcf_ga_active, 'ga_param' => $ga_param, ); wp_localize_script( 'jquery', 'cartflows', apply_filters( 'global_cartflows_js_localize', $localize ) ); if ( 'default' !== $page_template ) { wp_enqueue_style( 'wcf-normalize-frontend-global', wcf()->utils->get_css_url( 'cartflows-normalize' ), array(), CARTFLOWS_VER ); } wp_enqueue_style( 'wcf-frontend-global', wcf()->utils->get_css_url( 'frontend' ), array(), CARTFLOWS_VER ); wp_enqueue_script( 'wcf-frontend-global', wcf()->utils->get_js_url( 'frontend' ), array( 'jquery', 'jquery-cookie' ), CARTFLOWS_VER, false ); } /** * Custom Script in head. * * @since 1.0.0 */ public function custom_script_option() { /* Add custom script to header in frontend. */ $script = $this->get_custom_script(); if ( '' !== $script ) { if ( false === strpos( $script, ''; } echo ''; echo $script; echo ''; } } /** * Override woo templates. * * @param string $template new Template full path. * @param string $template_name Template name. * @param string $template_path Template Path. * @since 1.1.5 * @return string. */ public function override_woo_template( $template, $template_name, $template_path ) { global $woocommerce; $_template = $template; $plugin_path = CARTFLOWS_DIR . 'woocommerce/template/'; if ( file_exists( $plugin_path . $template_name ) ) { $template = $plugin_path . $template_name; } if ( ! $template ) { $template = $_template; } return $template; } /** * Remove the action applied by the Flatsome theme. * * @since 1.1.5 * @return void. */ public function remove_flatsome_action() { // Remove action where flatsome dequeued the woocommerce's default styles. remove_action( 'wp_enqueue_scripts', 'flatsome_woocommerce_scripts_styles', 98 ); } /** * Add version class to body in frontend. * * @since 1.1.5 * @param array $classes classes. * @return array $classes classes. */ public function add_cartflows_lite_version_to_body( $classes ) { $classes[] = 'cartflows-' . CARTFLOWS_VER; return $classes; } /** * Get custom script data. * * @since 1.0.0 */ public function get_custom_script() { global $post; $script = get_post_meta( $post->ID, 'wcf-custom-script', true ); return $script; } /** * Set appropriate filter sctions. * * @since 1.1.14 */ public function setup_optin_checkout_filter() { if ( _is_wcf_doing_optin_ajax() ) { /* Modify the optin order received url to go next step */ remove_filter( 'woocommerce_get_checkout_order_received_url', array( $this, 'redirect_to_thankyou_page' ), 10, 2 ); add_filter( 'woocommerce_get_checkout_order_received_url', array( $this, 'redirect_optin_to_next_step' ), 10, 2 ); } } /** * Redirect to thank page if upsell not exists * * @param string $order_recieve_url url. * @param object $order order object. * @since 1.0.0 */ public function redirect_optin_to_next_step( $order_recieve_url, $order ) { /* Only for optin page */ wcf()->logger->log( 'Start-' . __CLASS__ . '::' . __FUNCTION__ ); wcf()->logger->log( 'Only for optin page' ); if ( _is_wcf_doing_optin_ajax() ) { $optin_id = wcf()->utils->get_optin_id_from_post_data(); if ( ! $optin_id ) { $optin_id = wcf()->utils->get_optin_id_from_order( $order->get_id() ); } } else { $optin_id = wcf()->utils->get_optin_id_from_order( $order->get_id() ); } wcf()->logger->log( 'Optin ID : ' . $optin_id ); if ( $optin_id ) { $next_step_id = wcf()->flow->get_next_step_id( $order ); if ( $next_step_id ) { $order_recieve_url = get_permalink( $next_step_id ); $query_param = array( 'wcf-key' => $order->get_order_key(), 'wcf-order' => $order->get_id(), ); if ( 'yes' === wcf()->options->get_optin_meta_value( $optin_id, 'wcf-optin-pass-fields' ) ) { $fields_string = wcf()->options->get_optin_meta_value( $optin_id, 'wcf-optin-pass-specific-fields' ); $fields = array_map( 'trim', explode( ',', $fields_string ) ); if ( is_array( $fields ) ) { $order_id = $order->get_id(); foreach ( $fields as $in => $key ) { switch ( $key ) { case 'first_name': $query_param[ $key ] = $order->get_billing_first_name(); break; case 'last_name': $query_param[ $key ] = $order->get_billing_last_name(); break; case 'email': $query_param[ $key ] = $order->get_billing_email(); break; default: $query_param[ $key ] = get_post_meta( $order_id, '_billing_' . $key, true ); break; } } } } $order_recieve_url = add_query_arg( $query_param, $order_recieve_url ); } } wcf()->logger->log( 'End-' . __CLASS__ . '::' . __FUNCTION__ ); return $order_recieve_url; } } /** * Prepare if class 'Cartflows_Frontend' exist. * Kicking this off by calling 'get_instance()' method */ Cartflows_Frontend::get_instance(); class-cartflows-cloning.php000066600000030203152133015060012011 0ustar00ID; /** * If post data exists, create the post duplicate */ if ( isset( $post ) && null !== $post ) { /** * New post data array */ $args = array( 'comment_status' => $post->comment_status, 'ping_status' => $post->ping_status, 'post_author' => $new_post_author, 'post_content' => $post->post_content, 'post_excerpt' => $post->post_excerpt, 'post_name' => $post->post_name, 'post_parent' => $post->post_parent, 'post_password' => $post->post_password, 'post_status' => $post->post_status, 'post_title' => $post->post_title . ' Clone', 'post_type' => $post->post_type, 'to_ping' => $post->to_ping, 'menu_order' => $post->menu_order, ); /** * Insert the post */ $new_flow_id = wp_insert_post( $args ); /** * Get all current post terms ad set them to the new post */ // returns array of taxonomy names for post type, ex array("category", "post_tag");. $taxonomies = get_object_taxonomies( $post->post_type ); foreach ( $taxonomies as $taxonomy ) { $post_terms = wp_get_object_terms( $post_id, $taxonomy, array( 'fields' => 'slugs' ) ); wp_set_object_terms( $new_flow_id, $post_terms, $taxonomy, false ); } /** * Duplicate all post meta just in two SQL queries */ // @codingStandardsIgnoreStart $post_meta_infos = $wpdb->get_results( "SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=$post_id" ); // @codingStandardsIgnoreEnd if ( ! empty( $post_meta_infos ) ) { $sql_query = "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES "; $sql_query_sel = array(); foreach ( $post_meta_infos as $meta_info ) { $meta_key = $meta_info->meta_key; if ( '_wp_old_slug' === $meta_key ) { continue; } $meta_value = addslashes( $meta_info->meta_value ); $sql_query_sel[] = "($new_flow_id, '$meta_key', '$meta_value')"; } $sql_query .= implode( ',', $sql_query_sel ); // @codingStandardsIgnoreStart $wpdb->query( $sql_query ); // @codingStandardsIgnoreEnd } /* Steps Cloning */ $flow_steps = get_post_meta( $post_id, 'wcf-steps', true ); $new_flow_steps = array(); /* Set Steps Empty */ update_post_meta( $new_flow_id, 'wcf-steps', $new_flow_steps ); if ( is_array( $flow_steps ) && ! empty( $flow_steps ) ) { foreach ( $flow_steps as $index => $step_data ) { $step_id = $step_data['id']; $step_type = get_post_meta( $step_id, 'wcf-step-type', true ); $step_object = get_post( $step_id ); /** * New step post data array */ $step_args = array( 'comment_status' => $step_object->comment_status, 'ping_status' => $step_object->ping_status, 'post_author' => $new_post_author, 'post_content' => $step_object->post_content, 'post_excerpt' => $step_object->post_excerpt, 'post_name' => $step_object->post_name, 'post_parent' => $step_object->post_parent, 'post_password' => $step_object->post_password, 'post_status' => $step_object->post_status, 'post_title' => $step_object->post_title, 'post_type' => $step_object->post_type, 'to_ping' => $step_object->to_ping, 'menu_order' => $step_object->menu_order, ); /** * Insert the post */ $new_step_id = wp_insert_post( $step_args ); /** * Duplicate all step meta */ // @codingStandardsIgnoreStart $post_meta_infos = $wpdb->get_results( "SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=$step_id" ); // @codingStandardsIgnoreEnd if ( ! empty( $post_meta_infos ) ) { $sql_query = "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES "; $sql_query_sel = array(); foreach ( $post_meta_infos as $meta_info ) { $meta_key = $meta_info->meta_key; if ( '_wp_old_slug' === $meta_key ) { continue; } $meta_value = addslashes( $meta_info->meta_value ); $sql_query_sel[] = "($new_step_id, '$meta_key', '$meta_value')"; } $sql_query .= implode( ',', $sql_query_sel ); // @codingStandardsIgnoreStart $wpdb->query( $sql_query ); // @codingStandardsIgnoreEnd } // insert post meta. update_post_meta( $new_step_id, 'wcf-flow-id', $new_flow_id ); update_post_meta( $new_step_id, 'wcf-step-type', $step_type ); wp_set_object_terms( $new_step_id, $step_type, CARTFLOWS_TAXONOMY_STEP_TYPE ); wp_set_object_terms( $new_step_id, 'flow-' . $new_flow_id, CARTFLOWS_TAXONOMY_STEP_FLOW ); /* Add New Flow Steps */ $new_flow_steps[] = array( 'id' => $new_step_id, 'title' => $step_object->post_title, 'type' => $step_type, ); } } /* Update New Flow Step Post Meta */ update_post_meta( $new_flow_id, 'wcf-steps', $new_flow_steps ); /* Clear Page Builder Cache */ $this->clear_cache(); /** * Redirect to the new flow edit screen */ wp_safe_redirect( admin_url( 'post.php?action=edit&post=' . $new_flow_id ) ); exit; } else { wp_die( 'Post creation failed, could not find original post: ' . $post_id ); } } /** * Clone step with its meta. */ public function clone_step() { global $wpdb; if ( ! ( isset( $_GET['post'] ) || isset( $_POST['post'] ) || ( isset( $_REQUEST['action'] ) && 'cartflows_clone_step' === $_REQUEST['action'] ) ) ) { wp_die( 'No post to duplicate has been supplied!' ); } /* * Nonce verification */ if ( ! isset( $_GET['step_clone_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['step_clone_nonce'] ) ), 'step_clone' ) ) { return; } /** * Get the original post id */ $post_id = ( isset( $_GET['post'] ) ? absint( $_GET['post'] ) : absint( $_POST['post'] ) ); /** * And all the original post data then */ $post = get_post( $post_id ); /** * Assign current user to be the new post author */ $current_user = wp_get_current_user(); $new_post_author = $current_user->ID; /** * If post data exists, create the post duplicate */ if ( isset( $post ) && null !== $post ) { /** * New post data array */ $args = array( 'comment_status' => $post->comment_status, 'ping_status' => $post->ping_status, 'post_author' => $new_post_author, 'post_content' => $post->post_content, 'post_excerpt' => $post->post_excerpt, 'post_name' => $post->post_name, 'post_parent' => $post->post_parent, 'post_password' => $post->post_password, 'post_status' => $post->post_status, 'post_title' => $post->post_title . ' Clone', 'post_type' => $post->post_type, 'to_ping' => $post->to_ping, 'menu_order' => $post->menu_order, ); /** * Insert the post */ $new_step_id = wp_insert_post( $args ); /** * Get all current post terms ad set them to the new post */ // returns array of taxonomy names for post type, ex array("category", "post_tag");. $taxonomies = get_object_taxonomies( $post->post_type ); foreach ( $taxonomies as $taxonomy ) { $post_terms = wp_get_object_terms( $post_id, $taxonomy, array( 'fields' => 'slugs' ) ); wp_set_object_terms( $new_step_id, $post_terms, $taxonomy, false ); } /** * Duplicate all post meta just in two SQL queries */ // @codingStandardsIgnoreStart $post_meta_infos = $wpdb->get_results( "SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=$post_id" ); // @codingStandardsIgnoreEnd if ( ! empty( $post_meta_infos ) ) { $sql_query = "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES "; $sql_query_sel = array(); foreach ( $post_meta_infos as $meta_info ) { $meta_key = $meta_info->meta_key; if ( '_wp_old_slug' === $meta_key ) { continue; } $meta_value = addslashes( $meta_info->meta_value ); $sql_query_sel[] = "($new_step_id, '$meta_key', '$meta_value')"; } $sql_query .= implode( ',', $sql_query_sel ); // @codingStandardsIgnoreStart $wpdb->query( $sql_query ); // @codingStandardsIgnoreEnd } $flow_id = get_post_meta( $post_id, 'wcf-flow-id', true ); $flow_steps = get_post_meta( $flow_id, 'wcf-steps', true ); $step_type = get_post_meta( $post_id, 'wcf-step-type', true ); if ( ! is_array( $flow_steps ) ) { $flow_steps = array(); } $flow_steps[] = array( 'id' => $new_step_id, 'title' => $post->post_title, 'type' => $step_type, ); update_post_meta( $flow_id, 'wcf-steps', $flow_steps ); /* Clear Page Builder Cache */ $this->clear_cache(); /** * Redirect to the new flow edit screen */ $redirect_url = add_query_arg( 'highlight-step-id', $new_step_id, get_edit_post_link( $flow_id, 'default' ) ); wp_safe_redirect( $redirect_url ); exit; } else { wp_die( 'Post creation failed, could not find original post: ' . $post_id ); } } /** * Add the clone link to action list for flows row actions * * @param array $actions Actions array. * @param object $post Post object. * * @return array */ public function clone_link( $actions, $post ) { if ( current_user_can( 'edit_posts' ) && isset( $post ) && CARTFLOWS_FLOW_POST_TYPE === $post->post_type ) { if ( isset( $actions['duplicate'] ) ) { // Duplicate page plugin remove. unset( $actions['duplicate'] ); } if ( isset( $actions['edit_as_new_draft'] ) ) { // Duplicate post plugin remove. unset( $actions['edit_as_new_draft'] ); } $actions['clone'] = '' . __( 'Clone', 'cartflows' ) . ''; if ( ! _is_cartflows_pro() ) { $flow_posts = get_posts( array( 'posts_per_page' => 4, 'post_type' => CARTFLOWS_FLOW_POST_TYPE, 'post_status' => array( 'publish', 'pending', 'draft', 'future', 'private', 'inherit', 'trash' ), ) ); if ( is_array( $flow_posts ) ) { $flow_count = count( $flow_posts ); if ( $flow_count > 3 || 3 === $flow_count ) { unset( $actions['clone'] ); } } } } return $actions; } /** * Clear Page Builder Cache */ public function clear_cache() { // Clear 'Elementor' file cache. if ( class_exists( '\Elementor\Plugin' ) ) { Elementor\Plugin::$instance->files_manager->clear_cache(); } } } /** * Kicking this off by calling 'get_instance()' method */ Cartflows_Cloning::get_instance(); class-cartflows-admin-fields.php000066600000016442152133015060012725 0ustar00'; $output .= '' . $title . ''; $output .= ''; if ( ! empty( $description ) ) { $output .= '
'; $output .= '

' . $description . '

'; $output .= '
'; } return $output; } /** * Text Field * * @param array $args Args. * @return string */ public static function text_field( $args ) { $id = $args['id']; $name = $args['name']; $title = $args['title']; $value = $args['value']; $description = isset( $args['description'] ) ? $args['description'] : ''; $placeholder = isset( $args['placeholder'] ) ? $args['placeholder'] : ''; $output = '
'; $output .= ''; $output .= ''; $output .= '
'; if ( ! empty( $description ) ) { $output .= '
'; $output .= '

'; $output .= $description; $output .= '

'; $output .= '
'; } return $output; } /** * URL Field * * @param array $args Args. * @return string */ public static function url_field( $args ) { $id = $args['id']; $name = $args['name']; $title = $args['title']; $value = $args['value']; $output = '
'; $output .= ''; $output .= ''; $output .= '
'; return $output; } /** * Checkbox Field * * @param array $args Args. * @return string */ public static function checkobox_field( $args ) { $id = $args['id']; $name = $args['name']; $title = $args['title']; $value = $args['value']; $output = '
'; $output .= ''; $output .= '
'; return $output; } /** * Radio Field * * @param array $args Args. * @return string */ public static function radio_field( $args ) { $name = $args['name']; $id = $args['id']; $options = $args['options']; $value = $args['value']; $output = ''; foreach ( $options as $type => $data ) { $output .= '
'; $output .= ''; $output .= '
'; $output .= '

'; if ( empty( $type ) ) { $output .= $data['description']; } else { $output .= get_site_url() . $data['description']; } $output .= '

'; $output .= '
'; $output .= '
'; } return $output; } /** * Select Field * * @since 1.1.4 * * @param array $args Args. * @return string */ public static function select_field( $args ) { $id = $args['id']; $name = $args['name']; $title = $args['title']; $description = $args['description']; $value = $args['value']; $options = $args['options']; $output = '
'; $output .= '
'; $output .= $title; $output .= '
'; $output .= '
'; $output .= ''; $output .= '
'; $output .= '
'; $output .= '

'; $output .= $description; $output .= '

'; $output .= '
'; $output .= '
'; return $output; } /** * Checkout Selection Field * * @param array $args Args. * @return string */ public static function flow_checkout_selection_field( $args ) { $id = $args['id']; $name = $args['name']; $title = $args['title']; $value = $args['value']; $checkout_steps = get_posts( array( 'posts_per_page' => -1, 'post_type' => CARTFLOWS_STEP_POST_TYPE, 'post_status' => 'publish', 'orderby' => 'ID', 'order' => 'ASC', 'tax_query' => array( //phpcs:ignore array( 'taxonomy' => CARTFLOWS_TAXONOMY_STEP_TYPE, 'field' => 'slug', 'terms' => 'checkout', ), ), ) ); $output = '
'; $output .= '
'; $output .= ''; $output .= '
'; $output .= '
'; $output .= ''; $output .= '
'; if ( '' !== $value ) { $output .= ''; } $output .= '
'; /* translators: %s: link */ $output .= '

' . sprintf( __( 'Be sure not to add any product in above selected Global Checkout step. Please read information about how to set up Global Checkout %1$shere%2$s.', 'cartflows' ), '', '' ) . '

'; $output .= '
'; $output .= '
'; return $output; } } fields/typography/class-cartflows-font-families.php000066600000016701152133015060016600 0ustar00 array( 'fallback' => 'Verdana, Arial, sans-serif', 'variants' => array( '300', '400', '700', ), ), 'Verdana' => array( 'fallback' => 'Helvetica, Arial, sans-serif', 'variants' => array( '300', '400', '700', ), ), 'Arial' => array( 'fallback' => 'Helvetica, Verdana, sans-serif', 'variants' => array( '300', '400', '700', ), ), 'Times' => array( 'fallback' => 'Georgia, serif', 'variants' => array( '300', '400', '700', ), ), 'Georgia' => array( 'fallback' => 'Times, serif', 'variants' => array( '300', '400', '700', ), ), 'Courier' => array( 'fallback' => 'monospace', 'variants' => array( '300', '400', '700', ), ), ); } return apply_filters( 'cartflows_system_fonts', self::$system_fonts ); } /** * Custom Fonts * * @since 1.0.0 * * @return Array All the custom fonts in CartFlows */ public static function get_custom_fonts() { $custom_fonts = array(); return apply_filters( 'cartflows_custom_fonts', $custom_fonts ); } /** * Google Fonts used in CartFlows. * Array is generated from the google-fonts.json file. * * @since 1.0.0 * * @return Array Array of Google Fonts. */ public static function get_google_fonts() { if ( empty( self::$google_fonts ) ) { $google_fonts_file = CARTFLOWS_DIR . 'classes/fields/typography/google-fonts.json'; if ( ! file_exists( $google_fonts_file ) ) { return array(); } global $wp_filesystem; if ( empty( $wp_filesystem ) ) { require_once ABSPATH . '/wp-admin/includes/file.php'; WP_Filesystem(); } $file_contants = $wp_filesystem->get_contents( $google_fonts_file ); $google_fonts_json = json_decode( $file_contants, 1 ); if ( is_array( $google_fonts_json ) || is_object( $google_fonts_json ) ) { foreach ( $google_fonts_json as $key => $font ) { $name = key( $font ); foreach ( $font[ $name ] as $font_key => $single_font ) { if ( 'variants' === $font_key ) { foreach ( $single_font as $variant_key => $variant ) { if ( 'regular' == $variant ) { $font[ $name ][ $font_key ][ $variant_key ] = '400'; } } } self::$google_fonts[ $name ] = array_values( $font[ $name ] ); } } } } return apply_filters( 'cartflows_google_fonts', self::$google_fonts ); } /** * Render Fonts * * @param array $post_id post ID. * @return void */ public static function render_fonts( $post_id ) { $google_font_url = get_post_meta( $post_id, 'wcf-field-google-font-url', true ); // @todo Avoid the URL generator from the JS and remove the below static URL check condition. if ( empty( $google_font_url ) || '//fonts.googleapis.com/css?family=' == $google_font_url ) { return; } wp_enqueue_style( 'cartflows-google-fonts', esc_url( $google_font_url ), array(), CARTFLOWS_VER, 'all' ); } /** * Get string between * * @param string $string Input string. * @param string $start First string. * @param string $end Last string. * @return string string. */ public static function get_string_between( $string, $start, $end ) { $string = ' ' . $string; $ini = strpos( $string, $start ); if ( 0 == $ini ) { return ''; } $ini += strlen( $start ); $len = strpos( $string, $end, $ini ) - $ini; return substr( $string, $ini, $len ); } /** * Google Font URL * Combine multiple google font in one URL * * @link https://shellcreeper.com/?p=1476 * @param array $fonts Google Fonts array. * @param array $subsets Font's Subsets array. * * @return string */ public static function google_fonts_url( $fonts, $subsets = array() ) { /* URL */ $base_url = '//fonts.googleapis.com/css'; $font_args = array(); $family = array(); $fonts = apply_filters( 'cartflows_google_fonts', $fonts ); /* Format Each Font Family in Array */ foreach ( $fonts as $font_name => $font_weight ) { $font_name = str_replace( ' ', '+', $font_name ); if ( ! empty( $font_weight ) ) { if ( is_array( $font_weight ) ) { $font_weight = implode( ',', $font_weight ); } $font_family = explode( ',', $font_name ); $font_family = str_replace( "'", '', wcf_get_prop( $font_family, 0 ) ); $family[] = trim( $font_family . ':' . urlencode( trim( $font_weight ) ) );//phpcs:ignore } else { $family[] = trim( $font_name ); } } /* Only return URL if font family defined. */ if ( ! empty( $family ) ) { /* Make Font Family a String */ $family = implode( '|', $family ); /* Add font family in args */ $font_args['family'] = $family; /* Add font subsets in args */ if ( ! empty( $subsets ) ) { /* format subsets to string */ if ( is_array( $subsets ) ) { $subsets = implode( ',', $subsets ); } $font_args['subset'] = urlencode( trim( $subsets ) );//phpcs:ignore } return add_query_arg( $font_args, $base_url ); } return ''; } /** * Generate Google Font URL from the post meta. * * @param integer $post_id Post ID. * @return string Google URL if post meta is set. */ public function generate_google_url( $post_id ) { $font_weight = array(); $fields = get_post_meta( $post_id ); foreach ( $fields as $key => $value ) { if ( false !== strpos( $key, 'font-family' ) ) { $font_family = ! empty( $value[0] ) ? self::get_string_between( $value[0], '\'', '\'' ) : ''; $font_list[ $font_family ] = array(); } } $google_fonts = array(); $font_subset = array(); $system_fonts = self::get_system_fonts(); $get_google_fonts = self::get_google_fonts(); $variants = array( 'variants' => array( 400 ) ); foreach ( $font_list as $name => $font ) { if ( ! empty( $name ) && ! isset( $system_fonts[ $name ] ) ) { if ( isset( $get_google_fonts[ $name ] ) ) { $variants = $get_google_fonts[ $name ][0]; } // Add font variants. $google_fonts[ $name ] = $variants; // Add Subset. $subset = apply_filters( 'cartflows_font_subset', '', $name ); if ( ! empty( $subset ) ) { $font_subset[] = $subset; } } } return self::google_fonts_url( $google_fonts, $font_subset ); } } endif; fields/typography/google-fonts.json000066600000543474152133015060013537 0ustar00[ { "ABeeZee": { "variants": [ "regular", "italic" ], "category": "sans-serif" } }, { "Abel": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Abhaya Libre": { "variants": [ "regular", "500", "600", "700", "800" ], "category": "serif" } }, { "Abril Fatface": { "variants": [ "regular" ], "category": "display" } }, { "Aclonica": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Acme": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Actor": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Adamina": { "variants": [ "regular" ], "category": "serif" } }, { "Advent Pro": { "variants": [ "100", "200", "300", "regular", "500", "600", "700" ], "category": "sans-serif" } }, { "Aguafina Script": { "variants": [ "regular" ], "category": "handwriting" } }, { "Akronim": { "variants": [ "regular" ], "category": "display" } }, { "Aladin": { "variants": [ "regular" ], "category": "handwriting" } }, { "Aldrich": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Alef": { "variants": [ "regular", "700" ], "category": "sans-serif" } }, { "Alegreya": { "variants": [ "regular", "italic", "500", "500italic", "700", "700italic", "800", "800italic", "900", "900italic" ], "category": "serif" } }, { "Alegreya SC": { "variants": [ "regular", "italic", "500", "500italic", "700", "700italic", "800", "800italic", "900", "900italic" ], "category": "serif" } }, { "Alegreya Sans": { "variants": [ "100", "100italic", "300", "300italic", "regular", "italic", "500", "500italic", "700", "700italic", "800", "800italic", "900", "900italic" ], "category": "sans-serif" } }, { "Alegreya Sans SC": { "variants": [ "100", "100italic", "300", "300italic", "regular", "italic", "500", "500italic", "700", "700italic", "800", "800italic", "900", "900italic" ], "category": "sans-serif" } }, { "Alex Brush": { "variants": [ "regular" ], "category": "handwriting" } }, { "Alfa Slab One": { "variants": [ "regular" ], "category": "display" } }, { "Alice": { "variants": [ "regular" ], "category": "serif" } }, { "Alike": { "variants": [ "regular" ], "category": "serif" } }, { "Alike Angular": { "variants": [ "regular" ], "category": "serif" } }, { "Allan": { "variants": [ "regular", "700" ], "category": "display" } }, { "Allerta": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Allerta Stencil": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Allura": { "variants": [ "regular" ], "category": "handwriting" } }, { "Almendra": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "serif" } }, { "Almendra Display": { "variants": [ "regular" ], "category": "display" } }, { "Almendra SC": { "variants": [ "regular" ], "category": "serif" } }, { "Amarante": { "variants": [ "regular" ], "category": "display" } }, { "Amaranth": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "sans-serif" } }, { "Amatic SC": { "variants": [ "regular", "700" ], "category": "handwriting" } }, { "Amethysta": { "variants": [ "regular" ], "category": "serif" } }, { "Amiko": { "variants": [ "regular", "600", "700" ], "category": "sans-serif" } }, { "Amiri": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "serif" } }, { "Amita": { "variants": [ "regular", "700" ], "category": "handwriting" } }, { "Anaheim": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Andada": { "variants": [ "regular" ], "category": "serif" } }, { "Andika": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Angkor": { "variants": [ "regular" ], "category": "display" } }, { "Annie Use Your Telescope": { "variants": [ "regular" ], "category": "handwriting" } }, { "Anonymous Pro": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "monospace" } }, { "Antic": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Antic Didone": { "variants": [ "regular" ], "category": "serif" } }, { "Antic Slab": { "variants": [ "regular" ], "category": "serif" } }, { "Anton": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Arapey": { "variants": [ "regular", "italic" ], "category": "serif" } }, { "Arbutus": { "variants": [ "regular" ], "category": "display" } }, { "Arbutus Slab": { "variants": [ "regular" ], "category": "serif" } }, { "Architects Daughter": { "variants": [ "regular" ], "category": "handwriting" } }, { "Archivo": { "variants": [ "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic" ], "category": "sans-serif" } }, { "Archivo Black": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Archivo Narrow": { "variants": [ "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic" ], "category": "sans-serif" } }, { "Aref Ruqaa": { "variants": [ "regular", "700" ], "category": "serif" } }, { "Arima Madurai": { "variants": [ "100", "200", "300", "regular", "500", "700", "800", "900" ], "category": "display" } }, { "Arimo": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "sans-serif" } }, { "Arizonia": { "variants": [ "regular" ], "category": "handwriting" } }, { "Armata": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Arsenal": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "sans-serif" } }, { "Artifika": { "variants": [ "regular" ], "category": "serif" } }, { "Arvo": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "serif" } }, { "Arya": { "variants": [ "regular", "700" ], "category": "sans-serif" } }, { "Asap": { "variants": [ "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic" ], "category": "sans-serif" } }, { "Asap Condensed": { "variants": [ "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic" ], "category": "sans-serif" } }, { "Asar": { "variants": [ "regular" ], "category": "serif" } }, { "Asset": { "variants": [ "regular" ], "category": "display" } }, { "Assistant": { "variants": [ "200", "300", "regular", "600", "700", "800" ], "category": "sans-serif" } }, { "Astloch": { "variants": [ "regular", "700" ], "category": "display" } }, { "Asul": { "variants": [ "regular", "700" ], "category": "sans-serif" } }, { "Athiti": { "variants": [ "200", "300", "regular", "500", "600", "700" ], "category": "sans-serif" } }, { "Atma": { "variants": [ "300", "regular", "500", "600", "700" ], "category": "display" } }, { "Atomic Age": { "variants": [ "regular" ], "category": "display" } }, { "Aubrey": { "variants": [ "regular" ], "category": "display" } }, { "Audiowide": { "variants": [ "regular" ], "category": "display" } }, { "Autour One": { "variants": [ "regular" ], "category": "display" } }, { "Average": { "variants": [ "regular" ], "category": "serif" } }, { "Average Sans": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Averia Gruesa Libre": { "variants": [ "regular" ], "category": "display" } }, { "Averia Libre": { "variants": [ "300", "300italic", "regular", "italic", "700", "700italic" ], "category": "display" } }, { "Averia Sans Libre": { "variants": [ "300", "300italic", "regular", "italic", "700", "700italic" ], "category": "display" } }, { "Averia Serif Libre": { "variants": [ "300", "300italic", "regular", "italic", "700", "700italic" ], "category": "display" } }, { "Bad Script": { "variants": [ "regular" ], "category": "handwriting" } }, { "Bahiana": { "variants": [ "regular" ], "category": "display" } }, { "Bai Jamjuree": { "variants": [ "200", "200italic", "300", "300italic", "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic" ], "category": "sans-serif" } }, { "Baloo": { "variants": [ "regular" ], "category": "display" } }, { "Baloo Bhai": { "variants": [ "regular" ], "category": "display" } }, { "Baloo Bhaijaan": { "variants": [ "regular" ], "category": "display" } }, { "Baloo Bhaina": { "variants": [ "regular" ], "category": "display" } }, { "Baloo Chettan": { "variants": [ "regular" ], "category": "display" } }, { "Baloo Da": { "variants": [ "regular" ], "category": "display" } }, { "Baloo Paaji": { "variants": [ "regular" ], "category": "display" } }, { "Baloo Tamma": { "variants": [ "regular" ], "category": "display" } }, { "Baloo Tammudu": { "variants": [ "regular" ], "category": "display" } }, { "Baloo Thambi": { "variants": [ "regular" ], "category": "display" } }, { "Balthazar": { "variants": [ "regular" ], "category": "serif" } }, { "Bangers": { "variants": [ "regular" ], "category": "display" } }, { "Barlow": { "variants": [ "100", "100italic", "200", "200italic", "300", "300italic", "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic", "800", "800italic", "900", "900italic" ], "category": "sans-serif" } }, { "Barlow Condensed": { "variants": [ "100", "100italic", "200", "200italic", "300", "300italic", "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic", "800", "800italic", "900", "900italic" ], "category": "sans-serif" } }, { "Barlow Semi Condensed": { "variants": [ "100", "100italic", "200", "200italic", "300", "300italic", "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic", "800", "800italic", "900", "900italic" ], "category": "sans-serif" } }, { "Barrio": { "variants": [ "regular" ], "category": "display" } }, { "Basic": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Battambang": { "variants": [ "regular", "700" ], "category": "display" } }, { "Baumans": { "variants": [ "regular" ], "category": "display" } }, { "Bayon": { "variants": [ "regular" ], "category": "display" } }, { "Belgrano": { "variants": [ "regular" ], "category": "serif" } }, { "Bellefair": { "variants": [ "regular" ], "category": "serif" } }, { "Belleza": { "variants": [ "regular" ], "category": "sans-serif" } }, { "BenchNine": { "variants": [ "300", "regular", "700" ], "category": "sans-serif" } }, { "Bentham": { "variants": [ "regular" ], "category": "serif" } }, { "Berkshire Swash": { "variants": [ "regular" ], "category": "handwriting" } }, { "Bevan": { "variants": [ "regular" ], "category": "display" } }, { "Bigelow Rules": { "variants": [ "regular" ], "category": "display" } }, { "Bigshot One": { "variants": [ "regular" ], "category": "display" } }, { "Bilbo": { "variants": [ "regular" ], "category": "handwriting" } }, { "Bilbo Swash Caps": { "variants": [ "regular" ], "category": "handwriting" } }, { "BioRhyme": { "variants": [ "200", "300", "regular", "700", "800" ], "category": "serif" } }, { "BioRhyme Expanded": { "variants": [ "200", "300", "regular", "700", "800" ], "category": "serif" } }, { "Biryani": { "variants": [ "200", "300", "regular", "600", "700", "800", "900" ], "category": "sans-serif" } }, { "Bitter": { "variants": [ "regular", "italic", "700" ], "category": "serif" } }, { "Black And White Picture": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Black Han Sans": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Black Ops One": { "variants": [ "regular" ], "category": "display" } }, { "Bokor": { "variants": [ "regular" ], "category": "display" } }, { "Bonbon": { "variants": [ "regular" ], "category": "handwriting" } }, { "Boogaloo": { "variants": [ "regular" ], "category": "display" } }, { "Bowlby One": { "variants": [ "regular" ], "category": "display" } }, { "Bowlby One SC": { "variants": [ "regular" ], "category": "display" } }, { "Brawler": { "variants": [ "regular" ], "category": "serif" } }, { "Bree Serif": { "variants": [ "regular" ], "category": "serif" } }, { "Bubblegum Sans": { "variants": [ "regular" ], "category": "display" } }, { "Bubbler One": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Buda": { "variants": [ "300" ], "category": "display" } }, { "Buenard": { "variants": [ "regular", "700" ], "category": "serif" } }, { "Bungee": { "variants": [ "regular" ], "category": "display" } }, { "Bungee Hairline": { "variants": [ "regular" ], "category": "display" } }, { "Bungee Inline": { "variants": [ "regular" ], "category": "display" } }, { "Bungee Outline": { "variants": [ "regular" ], "category": "display" } }, { "Bungee Shade": { "variants": [ "regular" ], "category": "display" } }, { "Butcherman": { "variants": [ "regular" ], "category": "display" } }, { "Butterfly Kids": { "variants": [ "regular" ], "category": "handwriting" } }, { "Cabin": { "variants": [ "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic" ], "category": "sans-serif" } }, { "Cabin Condensed": { "variants": [ "regular", "500", "600", "700" ], "category": "sans-serif" } }, { "Cabin Sketch": { "variants": [ "regular", "700" ], "category": "display" } }, { "Caesar Dressing": { "variants": [ "regular" ], "category": "display" } }, { "Cagliostro": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Cairo": { "variants": [ "200", "300", "regular", "600", "700", "900" ], "category": "sans-serif" } }, { "Calligraffitti": { "variants": [ "regular" ], "category": "handwriting" } }, { "Cambay": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "sans-serif" } }, { "Cambo": { "variants": [ "regular" ], "category": "serif" } }, { "Candal": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Cantarell": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "sans-serif" } }, { "Cantata One": { "variants": [ "regular" ], "category": "serif" } }, { "Cantora One": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Capriola": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Cardo": { "variants": [ "regular", "italic", "700" ], "category": "serif" } }, { "Carme": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Carrois Gothic": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Carrois Gothic SC": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Carter One": { "variants": [ "regular" ], "category": "display" } }, { "Catamaran": { "variants": [ "100", "200", "300", "regular", "500", "600", "700", "800", "900" ], "category": "sans-serif" } }, { "Caudex": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "serif" } }, { "Caveat": { "variants": [ "regular", "700" ], "category": "handwriting" } }, { "Caveat Brush": { "variants": [ "regular" ], "category": "handwriting" } }, { "Cedarville Cursive": { "variants": [ "regular" ], "category": "handwriting" } }, { "Ceviche One": { "variants": [ "regular" ], "category": "display" } }, { "Chakra Petch": { "variants": [ "300", "300italic", "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic" ], "category": "sans-serif" } }, { "Changa": { "variants": [ "200", "300", "regular", "500", "600", "700", "800" ], "category": "sans-serif" } }, { "Changa One": { "variants": [ "regular", "italic" ], "category": "display" } }, { "Chango": { "variants": [ "regular" ], "category": "display" } }, { "Charmonman": { "variants": [ "regular", "700" ], "category": "handwriting" } }, { "Chathura": { "variants": [ "100", "300", "regular", "700", "800" ], "category": "sans-serif" } }, { "Chau Philomene One": { "variants": [ "regular", "italic" ], "category": "sans-serif" } }, { "Chela One": { "variants": [ "regular" ], "category": "display" } }, { "Chelsea Market": { "variants": [ "regular" ], "category": "display" } }, { "Chenla": { "variants": [ "regular" ], "category": "display" } }, { "Cherry Cream Soda": { "variants": [ "regular" ], "category": "display" } }, { "Cherry Swash": { "variants": [ "regular", "700" ], "category": "display" } }, { "Chewy": { "variants": [ "regular" ], "category": "display" } }, { "Chicle": { "variants": [ "regular" ], "category": "display" } }, { "Chivo": { "variants": [ "300", "300italic", "regular", "italic", "700", "700italic", "900", "900italic" ], "category": "sans-serif" } }, { "Chonburi": { "variants": [ "regular" ], "category": "display" } }, { "Cinzel": { "variants": [ "regular", "700", "900" ], "category": "serif" } }, { "Cinzel Decorative": { "variants": [ "regular", "700", "900" ], "category": "display" } }, { "Clicker Script": { "variants": [ "regular" ], "category": "handwriting" } }, { "Coda": { "variants": [ "regular", "800" ], "category": "display" } }, { "Coda Caption": { "variants": [ "800" ], "category": "sans-serif" } }, { "Codystar": { "variants": [ "300", "regular" ], "category": "display" } }, { "Coiny": { "variants": [ "regular" ], "category": "display" } }, { "Combo": { "variants": [ "regular" ], "category": "display" } }, { "Comfortaa": { "variants": [ "300", "regular", "700" ], "category": "display" } }, { "Coming Soon": { "variants": [ "regular" ], "category": "handwriting" } }, { "Concert One": { "variants": [ "regular" ], "category": "display" } }, { "Condiment": { "variants": [ "regular" ], "category": "handwriting" } }, { "Content": { "variants": [ "regular", "700" ], "category": "display" } }, { "Contrail One": { "variants": [ "regular" ], "category": "display" } }, { "Convergence": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Cookie": { "variants": [ "regular" ], "category": "handwriting" } }, { "Copse": { "variants": [ "regular" ], "category": "serif" } }, { "Corben": { "variants": [ "regular", "700" ], "category": "display" } }, { "Cormorant": { "variants": [ "300", "300italic", "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic" ], "category": "serif" } }, { "Cormorant Garamond": { "variants": [ "300", "300italic", "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic" ], "category": "serif" } }, { "Cormorant Infant": { "variants": [ "300", "300italic", "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic" ], "category": "serif" } }, { "Cormorant SC": { "variants": [ "300", "regular", "500", "600", "700" ], "category": "serif" } }, { "Cormorant Unicase": { "variants": [ "300", "regular", "500", "600", "700" ], "category": "serif" } }, { "Cormorant Upright": { "variants": [ "300", "regular", "500", "600", "700" ], "category": "serif" } }, { "Courgette": { "variants": [ "regular" ], "category": "handwriting" } }, { "Cousine": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "monospace" } }, { "Coustard": { "variants": [ "regular", "900" ], "category": "serif" } }, { "Covered By Your Grace": { "variants": [ "regular" ], "category": "handwriting" } }, { "Crafty Girls": { "variants": [ "regular" ], "category": "handwriting" } }, { "Creepster": { "variants": [ "regular" ], "category": "display" } }, { "Crete Round": { "variants": [ "regular", "italic" ], "category": "serif" } }, { "Crimson Text": { "variants": [ "regular", "italic", "600", "600italic", "700", "700italic" ], "category": "serif" } }, { "Croissant One": { "variants": [ "regular" ], "category": "display" } }, { "Crushed": { "variants": [ "regular" ], "category": "display" } }, { "Cuprum": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "sans-serif" } }, { "Cute Font": { "variants": [ "regular" ], "category": "display" } }, { "Cutive": { "variants": [ "regular" ], "category": "serif" } }, { "Cutive Mono": { "variants": [ "regular" ], "category": "monospace" } }, { "Damion": { "variants": [ "regular" ], "category": "handwriting" } }, { "Dancing Script": { "variants": [ "regular", "700" ], "category": "handwriting" } }, { "Dangrek": { "variants": [ "regular" ], "category": "display" } }, { "David Libre": { "variants": [ "regular", "500", "700" ], "category": "serif" } }, { "Dawning of a New Day": { "variants": [ "regular" ], "category": "handwriting" } }, { "Days One": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Dekko": { "variants": [ "regular" ], "category": "handwriting" } }, { "Delius": { "variants": [ "regular" ], "category": "handwriting" } }, { "Delius Swash Caps": { "variants": [ "regular" ], "category": "handwriting" } }, { "Delius Unicase": { "variants": [ "regular", "700" ], "category": "handwriting" } }, { "Della Respira": { "variants": [ "regular" ], "category": "serif" } }, { "Denk One": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Devonshire": { "variants": [ "regular" ], "category": "handwriting" } }, { "Dhurjati": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Didact Gothic": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Diplomata": { "variants": [ "regular" ], "category": "display" } }, { "Diplomata SC": { "variants": [ "regular" ], "category": "display" } }, { "Do Hyeon": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Dokdo": { "variants": [ "regular" ], "category": "handwriting" } }, { "Domine": { "variants": [ "regular", "700" ], "category": "serif" } }, { "Donegal One": { "variants": [ "regular" ], "category": "serif" } }, { "Doppio One": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Dorsa": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Dosis": { "variants": [ "200", "300", "regular", "500", "600", "700", "800" ], "category": "sans-serif" } }, { "Dr Sugiyama": { "variants": [ "regular" ], "category": "handwriting" } }, { "Duru Sans": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Dynalight": { "variants": [ "regular" ], "category": "display" } }, { "EB Garamond": { "variants": [ "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic", "800", "800italic" ], "category": "serif" } }, { "Eagle Lake": { "variants": [ "regular" ], "category": "handwriting" } }, { "East Sea Dokdo": { "variants": [ "regular" ], "category": "handwriting" } }, { "Eater": { "variants": [ "regular" ], "category": "display" } }, { "Economica": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "sans-serif" } }, { "Eczar": { "variants": [ "regular", "500", "600", "700", "800" ], "category": "serif" } }, { "El Messiri": { "variants": [ "regular", "500", "600", "700" ], "category": "sans-serif" } }, { "Electrolize": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Elsie": { "variants": [ "regular", "900" ], "category": "display" } }, { "Elsie Swash Caps": { "variants": [ "regular", "900" ], "category": "display" } }, { "Emblema One": { "variants": [ "regular" ], "category": "display" } }, { "Emilys Candy": { "variants": [ "regular" ], "category": "display" } }, { "Encode Sans": { "variants": [ "100", "200", "300", "regular", "500", "600", "700", "800", "900" ], "category": "sans-serif" } }, { "Encode Sans Condensed": { "variants": [ "100", "200", "300", "regular", "500", "600", "700", "800", "900" ], "category": "sans-serif" } }, { "Encode Sans Expanded": { "variants": [ "100", "200", "300", "regular", "500", "600", "700", "800", "900" ], "category": "sans-serif" } }, { "Encode Sans Semi Condensed": { "variants": [ "100", "200", "300", "regular", "500", "600", "700", "800", "900" ], "category": "sans-serif" } }, { "Encode Sans Semi Expanded": { "variants": [ "100", "200", "300", "regular", "500", "600", "700", "800", "900" ], "category": "sans-serif" } }, { "Engagement": { "variants": [ "regular" ], "category": "handwriting" } }, { "Englebert": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Enriqueta": { "variants": [ "regular", "700" ], "category": "serif" } }, { "Erica One": { "variants": [ "regular" ], "category": "display" } }, { "Esteban": { "variants": [ "regular" ], "category": "serif" } }, { "Euphoria Script": { "variants": [ "regular" ], "category": "handwriting" } }, { "Ewert": { "variants": [ "regular" ], "category": "display" } }, { "Exo": { "variants": [ "100", "100italic", "200", "200italic", "300", "300italic", "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic", "800", "800italic", "900", "900italic" ], "category": "sans-serif" } }, { "Exo 2": { "variants": [ "100", "100italic", "200", "200italic", "300", "300italic", "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic", "800", "800italic", "900", "900italic" ], "category": "sans-serif" } }, { "Expletus Sans": { "variants": [ "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic" ], "category": "display" } }, { "Fahkwang": { "variants": [ "200", "200italic", "300", "300italic", "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic" ], "category": "sans-serif" } }, { "Fanwood Text": { "variants": [ "regular", "italic" ], "category": "serif" } }, { "Farsan": { "variants": [ "regular" ], "category": "display" } }, { "Fascinate": { "variants": [ "regular" ], "category": "display" } }, { "Fascinate Inline": { "variants": [ "regular" ], "category": "display" } }, { "Faster One": { "variants": [ "regular" ], "category": "display" } }, { "Fasthand": { "variants": [ "regular" ], "category": "serif" } }, { "Fauna One": { "variants": [ "regular" ], "category": "serif" } }, { "Faustina": { "variants": [ "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic" ], "category": "serif" } }, { "Federant": { "variants": [ "regular" ], "category": "display" } }, { "Federo": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Felipa": { "variants": [ "regular" ], "category": "handwriting" } }, { "Fenix": { "variants": [ "regular" ], "category": "serif" } }, { "Finger Paint": { "variants": [ "regular" ], "category": "display" } }, { "Fira Mono": { "variants": [ "regular", "500", "700" ], "category": "monospace" } }, { "Fira Sans": { "variants": [ "100", "100italic", "200", "200italic", "300", "300italic", "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic", "800", "800italic", "900", "900italic" ], "category": "sans-serif" } }, { "Fira Sans Condensed": { "variants": [ "100", "100italic", "200", "200italic", "300", "300italic", "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic", "800", "800italic", "900", "900italic" ], "category": "sans-serif" } }, { "Fira Sans Extra Condensed": { "variants": [ "100", "100italic", "200", "200italic", "300", "300italic", "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic", "800", "800italic", "900", "900italic" ], "category": "sans-serif" } }, { "Fjalla One": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Fjord One": { "variants": [ "regular" ], "category": "serif" } }, { "Flamenco": { "variants": [ "300", "regular" ], "category": "display" } }, { "Flavors": { "variants": [ "regular" ], "category": "display" } }, { "Fondamento": { "variants": [ "regular", "italic" ], "category": "handwriting" } }, { "Fontdiner Swanky": { "variants": [ "regular" ], "category": "display" } }, { "Forum": { "variants": [ "regular" ], "category": "display" } }, { "Francois One": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Frank Ruhl Libre": { "variants": [ "300", "regular", "500", "700", "900" ], "category": "serif" } }, { "Freckle Face": { "variants": [ "regular" ], "category": "display" } }, { "Fredericka the Great": { "variants": [ "regular" ], "category": "display" } }, { "Fredoka One": { "variants": [ "regular" ], "category": "display" } }, { "Freehand": { "variants": [ "regular" ], "category": "display" } }, { "Fresca": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Frijole": { "variants": [ "regular" ], "category": "display" } }, { "Fruktur": { "variants": [ "regular" ], "category": "display" } }, { "Fugaz One": { "variants": [ "regular" ], "category": "display" } }, { "GFS Didot": { "variants": [ "regular" ], "category": "serif" } }, { "GFS Neohellenic": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "sans-serif" } }, { "Gabriela": { "variants": [ "regular" ], "category": "serif" } }, { "Gaegu": { "variants": [ "300", "regular", "700" ], "category": "handwriting" } }, { "Gafata": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Galada": { "variants": [ "regular" ], "category": "display" } }, { "Galdeano": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Galindo": { "variants": [ "regular" ], "category": "display" } }, { "Gamja Flower": { "variants": [ "regular" ], "category": "handwriting" } }, { "Gentium Basic": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "serif" } }, { "Gentium Book Basic": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "serif" } }, { "Geo": { "variants": [ "regular", "italic" ], "category": "sans-serif" } }, { "Geostar": { "variants": [ "regular" ], "category": "display" } }, { "Geostar Fill": { "variants": [ "regular" ], "category": "display" } }, { "Germania One": { "variants": [ "regular" ], "category": "display" } }, { "Gidugu": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Gilda Display": { "variants": [ "regular" ], "category": "serif" } }, { "Give You Glory": { "variants": [ "regular" ], "category": "handwriting" } }, { "Glass Antiqua": { "variants": [ "regular" ], "category": "display" } }, { "Glegoo": { "variants": [ "regular", "700" ], "category": "serif" } }, { "Gloria Hallelujah": { "variants": [ "regular" ], "category": "handwriting" } }, { "Goblin One": { "variants": [ "regular" ], "category": "display" } }, { "Gochi Hand": { "variants": [ "regular" ], "category": "handwriting" } }, { "Gorditas": { "variants": [ "regular", "700" ], "category": "display" } }, { "Gothic A1": { "variants": [ "100", "200", "300", "regular", "500", "600", "700", "800", "900" ], "category": "sans-serif" } }, { "Goudy Bookletter 1911": { "variants": [ "regular" ], "category": "serif" } }, { "Graduate": { "variants": [ "regular" ], "category": "display" } }, { "Grand Hotel": { "variants": [ "regular" ], "category": "handwriting" } }, { "Gravitas One": { "variants": [ "regular" ], "category": "display" } }, { "Great Vibes": { "variants": [ "regular" ], "category": "handwriting" } }, { "Griffy": { "variants": [ "regular" ], "category": "display" } }, { "Gruppo": { "variants": [ "regular" ], "category": "display" } }, { "Gudea": { "variants": [ "regular", "italic", "700" ], "category": "sans-serif" } }, { "Gugi": { "variants": [ "regular" ], "category": "display" } }, { "Gurajada": { "variants": [ "regular" ], "category": "serif" } }, { "Habibi": { "variants": [ "regular" ], "category": "serif" } }, { "Halant": { "variants": [ "300", "regular", "500", "600", "700" ], "category": "serif" } }, { "Hammersmith One": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Hanalei": { "variants": [ "regular" ], "category": "display" } }, { "Hanalei Fill": { "variants": [ "regular" ], "category": "display" } }, { "Handlee": { "variants": [ "regular" ], "category": "handwriting" } }, { "Hanuman": { "variants": [ "regular", "700" ], "category": "serif" } }, { "Happy Monkey": { "variants": [ "regular" ], "category": "display" } }, { "Harmattan": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Headland One": { "variants": [ "regular" ], "category": "serif" } }, { "Heebo": { "variants": [ "100", "300", "regular", "500", "700", "800", "900" ], "category": "sans-serif" } }, { "Henny Penny": { "variants": [ "regular" ], "category": "display" } }, { "Herr Von Muellerhoff": { "variants": [ "regular" ], "category": "handwriting" } }, { "Hi Melody": { "variants": [ "regular" ], "category": "handwriting" } }, { "Hind": { "variants": [ "300", "regular", "500", "600", "700" ], "category": "sans-serif" } }, { "Hind Guntur": { "variants": [ "300", "regular", "500", "600", "700" ], "category": "sans-serif" } }, { "Hind Madurai": { "variants": [ "300", "regular", "500", "600", "700" ], "category": "sans-serif" } }, { "Hind Siliguri": { "variants": [ "300", "regular", "500", "600", "700" ], "category": "sans-serif" } }, { "Hind Vadodara": { "variants": [ "300", "regular", "500", "600", "700" ], "category": "sans-serif" } }, { "Holtwood One SC": { "variants": [ "regular" ], "category": "serif" } }, { "Homemade Apple": { "variants": [ "regular" ], "category": "handwriting" } }, { "Homenaje": { "variants": [ "regular" ], "category": "sans-serif" } }, { "IBM Plex Mono": { "variants": [ "100", "100italic", "200", "200italic", "300", "300italic", "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic" ], "category": "monospace" } }, { "IBM Plex Sans": { "variants": [ "100", "100italic", "200", "200italic", "300", "300italic", "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic" ], "category": "sans-serif" } }, { "IBM Plex Sans Condensed": { "variants": [ "100", "100italic", "200", "200italic", "300", "300italic", "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic" ], "category": "sans-serif" } }, { "IBM Plex Serif": { "variants": [ "100", "100italic", "200", "200italic", "300", "300italic", "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic" ], "category": "serif" } }, { "IM Fell DW Pica": { "variants": [ "regular", "italic" ], "category": "serif" } }, { "IM Fell DW Pica SC": { "variants": [ "regular" ], "category": "serif" } }, { "IM Fell Double Pica": { "variants": [ "regular", "italic" ], "category": "serif" } }, { "IM Fell Double Pica SC": { "variants": [ "regular" ], "category": "serif" } }, { "IM Fell English": { "variants": [ "regular", "italic" ], "category": "serif" } }, { "IM Fell English SC": { "variants": [ "regular" ], "category": "serif" } }, { "IM Fell French Canon": { "variants": [ "regular", "italic" ], "category": "serif" } }, { "IM Fell French Canon SC": { "variants": [ "regular" ], "category": "serif" } }, { "IM Fell Great Primer": { "variants": [ "regular", "italic" ], "category": "serif" } }, { "IM Fell Great Primer SC": { "variants": [ "regular" ], "category": "serif" } }, { "Iceberg": { "variants": [ "regular" ], "category": "display" } }, { "Iceland": { "variants": [ "regular" ], "category": "display" } }, { "Imprima": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Inconsolata": { "variants": [ "regular", "700" ], "category": "monospace" } }, { "Inder": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Indie Flower": { "variants": [ "regular" ], "category": "handwriting" } }, { "Inika": { "variants": [ "regular", "700" ], "category": "serif" } }, { "Inknut Antiqua": { "variants": [ "300", "regular", "500", "600", "700", "800", "900" ], "category": "serif" } }, { "Irish Grover": { "variants": [ "regular" ], "category": "display" } }, { "Istok Web": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "sans-serif" } }, { "Italiana": { "variants": [ "regular" ], "category": "serif" } }, { "Italianno": { "variants": [ "regular" ], "category": "handwriting" } }, { "Itim": { "variants": [ "regular" ], "category": "handwriting" } }, { "Jacques Francois": { "variants": [ "regular" ], "category": "serif" } }, { "Jacques Francois Shadow": { "variants": [ "regular" ], "category": "display" } }, { "Jaldi": { "variants": [ "regular", "700" ], "category": "sans-serif" } }, { "Jim Nightshade": { "variants": [ "regular" ], "category": "handwriting" } }, { "Jockey One": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Jolly Lodger": { "variants": [ "regular" ], "category": "display" } }, { "Jomhuria": { "variants": [ "regular" ], "category": "display" } }, { "Josefin Sans": { "variants": [ "100", "100italic", "300", "300italic", "regular", "italic", "600", "600italic", "700", "700italic" ], "category": "sans-serif" } }, { "Josefin Slab": { "variants": [ "100", "100italic", "300", "300italic", "regular", "italic", "600", "600italic", "700", "700italic" ], "category": "serif" } }, { "Joti One": { "variants": [ "regular" ], "category": "display" } }, { "Jua": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Judson": { "variants": [ "regular", "italic", "700" ], "category": "serif" } }, { "Julee": { "variants": [ "regular" ], "category": "handwriting" } }, { "Julius Sans One": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Junge": { "variants": [ "regular" ], "category": "serif" } }, { "Jura": { "variants": [ "300", "regular", "500", "600", "700" ], "category": "sans-serif" } }, { "Just Another Hand": { "variants": [ "regular" ], "category": "handwriting" } }, { "Just Me Again Down Here": { "variants": [ "regular" ], "category": "handwriting" } }, { "K2D": { "variants": [ "100", "100italic", "200", "200italic", "300", "300italic", "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic", "800", "800italic" ], "category": "sans-serif" } }, { "Kadwa": { "variants": [ "regular", "700" ], "category": "serif" } }, { "Kalam": { "variants": [ "300", "regular", "700" ], "category": "handwriting" } }, { "Kameron": { "variants": [ "regular", "700" ], "category": "serif" } }, { "Kanit": { "variants": [ "100", "100italic", "200", "200italic", "300", "300italic", "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic", "800", "800italic", "900", "900italic" ], "category": "sans-serif" } }, { "Kantumruy": { "variants": [ "300", "regular", "700" ], "category": "sans-serif" } }, { "Karla": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "sans-serif" } }, { "Karma": { "variants": [ "300", "regular", "500", "600", "700" ], "category": "serif" } }, { "Katibeh": { "variants": [ "regular" ], "category": "display" } }, { "Kaushan Script": { "variants": [ "regular" ], "category": "handwriting" } }, { "Kavivanar": { "variants": [ "regular" ], "category": "handwriting" } }, { "Kavoon": { "variants": [ "regular" ], "category": "display" } }, { "Kdam Thmor": { "variants": [ "regular" ], "category": "display" } }, { "Keania One": { "variants": [ "regular" ], "category": "display" } }, { "Kelly Slab": { "variants": [ "regular" ], "category": "display" } }, { "Kenia": { "variants": [ "regular" ], "category": "display" } }, { "Khand": { "variants": [ "300", "regular", "500", "600", "700" ], "category": "sans-serif" } }, { "Khmer": { "variants": [ "regular" ], "category": "display" } }, { "Khula": { "variants": [ "300", "regular", "600", "700", "800" ], "category": "sans-serif" } }, { "Kirang Haerang": { "variants": [ "regular" ], "category": "display" } }, { "Kite One": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Knewave": { "variants": [ "regular" ], "category": "display" } }, { "KoHo": { "variants": [ "200", "200italic", "300", "300italic", "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic" ], "category": "sans-serif" } }, { "Kodchasan": { "variants": [ "200", "200italic", "300", "300italic", "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic" ], "category": "sans-serif" } }, { "Kosugi": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Kosugi Maru": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Kotta One": { "variants": [ "regular" ], "category": "serif" } }, { "Koulen": { "variants": [ "regular" ], "category": "display" } }, { "Kranky": { "variants": [ "regular" ], "category": "display" } }, { "Kreon": { "variants": [ "300", "regular", "700" ], "category": "serif" } }, { "Kristi": { "variants": [ "regular" ], "category": "handwriting" } }, { "Krona One": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Krub": { "variants": [ "200", "200italic", "300", "300italic", "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic" ], "category": "sans-serif" } }, { "Kumar One": { "variants": [ "regular" ], "category": "display" } }, { "Kumar One Outline": { "variants": [ "regular" ], "category": "display" } }, { "Kurale": { "variants": [ "regular" ], "category": "serif" } }, { "La Belle Aurore": { "variants": [ "regular" ], "category": "handwriting" } }, { "Laila": { "variants": [ "300", "regular", "500", "600", "700" ], "category": "serif" } }, { "Lakki Reddy": { "variants": [ "regular" ], "category": "handwriting" } }, { "Lalezar": { "variants": [ "regular" ], "category": "display" } }, { "Lancelot": { "variants": [ "regular" ], "category": "display" } }, { "Lateef": { "variants": [ "regular" ], "category": "handwriting" } }, { "Lato": { "variants": [ "100", "100italic", "300", "300italic", "regular", "italic", "700", "700italic", "900", "900italic" ], "category": "sans-serif" } }, { "League Script": { "variants": [ "regular" ], "category": "handwriting" } }, { "Leckerli One": { "variants": [ "regular" ], "category": "handwriting" } }, { "Ledger": { "variants": [ "regular" ], "category": "serif" } }, { "Lekton": { "variants": [ "regular", "italic", "700" ], "category": "sans-serif" } }, { "Lemon": { "variants": [ "regular" ], "category": "display" } }, { "Lemonada": { "variants": [ "300", "regular", "600", "700" ], "category": "display" } }, { "Libre Barcode 128": { "variants": [ "regular" ], "category": "display" } }, { "Libre Barcode 128 Text": { "variants": [ "regular" ], "category": "display" } }, { "Libre Barcode 39": { "variants": [ "regular" ], "category": "display" } }, { "Libre Barcode 39 Extended": { "variants": [ "regular" ], "category": "display" } }, { "Libre Barcode 39 Extended Text": { "variants": [ "regular" ], "category": "display" } }, { "Libre Barcode 39 Text": { "variants": [ "regular" ], "category": "display" } }, { "Libre Baskerville": { "variants": [ "regular", "italic", "700" ], "category": "serif" } }, { "Libre Franklin": { "variants": [ "100", "100italic", "200", "200italic", "300", "300italic", "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic", "800", "800italic", "900", "900italic" ], "category": "sans-serif" } }, { "Life Savers": { "variants": [ "regular", "700" ], "category": "display" } }, { "Lilita One": { "variants": [ "regular" ], "category": "display" } }, { "Lily Script One": { "variants": [ "regular" ], "category": "display" } }, { "Limelight": { "variants": [ "regular" ], "category": "display" } }, { "Linden Hill": { "variants": [ "regular", "italic" ], "category": "serif" } }, { "Lobster": { "variants": [ "regular" ], "category": "display" } }, { "Lobster Two": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "display" } }, { "Londrina Outline": { "variants": [ "regular" ], "category": "display" } }, { "Londrina Shadow": { "variants": [ "regular" ], "category": "display" } }, { "Londrina Sketch": { "variants": [ "regular" ], "category": "display" } }, { "Londrina Solid": { "variants": [ "100", "300", "regular", "900" ], "category": "display" } }, { "Lora": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "serif" } }, { "Love Ya Like A Sister": { "variants": [ "regular" ], "category": "display" } }, { "Loved by the King": { "variants": [ "regular" ], "category": "handwriting" } }, { "Lovers Quarrel": { "variants": [ "regular" ], "category": "handwriting" } }, { "Luckiest Guy": { "variants": [ "regular" ], "category": "display" } }, { "Lusitana": { "variants": [ "regular", "700" ], "category": "serif" } }, { "Lustria": { "variants": [ "regular" ], "category": "serif" } }, { "M PLUS 1p": { "variants": [ "100", "300", "regular", "500", "700", "800", "900" ], "category": "sans-serif" } }, { "M PLUS Rounded 1c": { "variants": [ "100", "300", "regular", "500", "700", "800", "900" ], "category": "sans-serif" } }, { "Macondo": { "variants": [ "regular" ], "category": "display" } }, { "Macondo Swash Caps": { "variants": [ "regular" ], "category": "display" } }, { "Mada": { "variants": [ "200", "300", "regular", "500", "600", "700", "900" ], "category": "sans-serif" } }, { "Magra": { "variants": [ "regular", "700" ], "category": "sans-serif" } }, { "Maiden Orange": { "variants": [ "regular" ], "category": "display" } }, { "Maitree": { "variants": [ "200", "300", "regular", "500", "600", "700" ], "category": "serif" } }, { "Mako": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Mali": { "variants": [ "200", "200italic", "300", "300italic", "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic" ], "category": "handwriting" } }, { "Mallanna": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Mandali": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Manuale": { "variants": [ "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic" ], "category": "serif" } }, { "Marcellus": { "variants": [ "regular" ], "category": "serif" } }, { "Marcellus SC": { "variants": [ "regular" ], "category": "serif" } }, { "Marck Script": { "variants": [ "regular" ], "category": "handwriting" } }, { "Margarine": { "variants": [ "regular" ], "category": "display" } }, { "Markazi Text": { "variants": [ "regular", "500", "600", "700" ], "category": "serif" } }, { "Marko One": { "variants": [ "regular" ], "category": "serif" } }, { "Marmelad": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Martel": { "variants": [ "200", "300", "regular", "600", "700", "800", "900" ], "category": "serif" } }, { "Martel Sans": { "variants": [ "200", "300", "regular", "600", "700", "800", "900" ], "category": "sans-serif" } }, { "Marvel": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "sans-serif" } }, { "Mate": { "variants": [ "regular", "italic" ], "category": "serif" } }, { "Mate SC": { "variants": [ "regular" ], "category": "serif" } }, { "Maven Pro": { "variants": [ "regular", "500", "700", "900" ], "category": "sans-serif" } }, { "McLaren": { "variants": [ "regular" ], "category": "display" } }, { "Meddon": { "variants": [ "regular" ], "category": "handwriting" } }, { "MedievalSharp": { "variants": [ "regular" ], "category": "display" } }, { "Medula One": { "variants": [ "regular" ], "category": "display" } }, { "Meera Inimai": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Megrim": { "variants": [ "regular" ], "category": "display" } }, { "Meie Script": { "variants": [ "regular" ], "category": "handwriting" } }, { "Merienda": { "variants": [ "regular", "700" ], "category": "handwriting" } }, { "Merienda One": { "variants": [ "regular" ], "category": "handwriting" } }, { "Merriweather": { "variants": [ "300", "300italic", "regular", "italic", "700", "700italic", "900", "900italic" ], "category": "serif" } }, { "Merriweather Sans": { "variants": [ "300", "300italic", "regular", "italic", "700", "700italic", "800", "800italic" ], "category": "sans-serif" } }, { "Metal": { "variants": [ "regular" ], "category": "display" } }, { "Metal Mania": { "variants": [ "regular" ], "category": "display" } }, { "Metamorphous": { "variants": [ "regular" ], "category": "display" } }, { "Metrophobic": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Michroma": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Milonga": { "variants": [ "regular" ], "category": "display" } }, { "Miltonian": { "variants": [ "regular" ], "category": "display" } }, { "Miltonian Tattoo": { "variants": [ "regular" ], "category": "display" } }, { "Mina": { "variants": [ "regular", "700" ], "category": "sans-serif" } }, { "Miniver": { "variants": [ "regular" ], "category": "display" } }, { "Miriam Libre": { "variants": [ "regular", "700" ], "category": "sans-serif" } }, { "Mirza": { "variants": [ "regular", "500", "600", "700" ], "category": "display" } }, { "Miss Fajardose": { "variants": [ "regular" ], "category": "handwriting" } }, { "Mitr": { "variants": [ "200", "300", "regular", "500", "600", "700" ], "category": "sans-serif" } }, { "Modak": { "variants": [ "regular" ], "category": "display" } }, { "Modern Antiqua": { "variants": [ "regular" ], "category": "display" } }, { "Mogra": { "variants": [ "regular" ], "category": "display" } }, { "Molengo": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Molle": { "variants": [ "italic" ], "category": "handwriting" } }, { "Monda": { "variants": [ "regular", "700" ], "category": "sans-serif" } }, { "Monofett": { "variants": [ "regular" ], "category": "display" } }, { "Monoton": { "variants": [ "regular" ], "category": "display" } }, { "Monsieur La Doulaise": { "variants": [ "regular" ], "category": "handwriting" } }, { "Montaga": { "variants": [ "regular" ], "category": "serif" } }, { "Montez": { "variants": [ "regular" ], "category": "handwriting" } }, { "Montserrat": { "variants": [ "100", "100italic", "200", "200italic", "300", "300italic", "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic", "800", "800italic", "900", "900italic" ], "category": "sans-serif" } }, { "Montserrat Alternates": { "variants": [ "100", "100italic", "200", "200italic", "300", "300italic", "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic", "800", "800italic", "900", "900italic" ], "category": "sans-serif" } }, { "Montserrat Subrayada": { "variants": [ "regular", "700" ], "category": "sans-serif" } }, { "Moul": { "variants": [ "regular" ], "category": "display" } }, { "Moulpali": { "variants": [ "regular" ], "category": "display" } }, { "Mountains of Christmas": { "variants": [ "regular", "700" ], "category": "display" } }, { "Mouse Memoirs": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Mr Bedfort": { "variants": [ "regular" ], "category": "handwriting" } }, { "Mr Dafoe": { "variants": [ "regular" ], "category": "handwriting" } }, { "Mr De Haviland": { "variants": [ "regular" ], "category": "handwriting" } }, { "Mrs Saint Delafield": { "variants": [ "regular" ], "category": "handwriting" } }, { "Mrs Sheppards": { "variants": [ "regular" ], "category": "handwriting" } }, { "Mukta": { "variants": [ "200", "300", "regular", "500", "600", "700", "800" ], "category": "sans-serif" } }, { "Mukta Mahee": { "variants": [ "200", "300", "regular", "500", "600", "700", "800" ], "category": "sans-serif" } }, { "Mukta Malar": { "variants": [ "200", "300", "regular", "500", "600", "700", "800" ], "category": "sans-serif" } }, { "Mukta Vaani": { "variants": [ "200", "300", "regular", "500", "600", "700", "800" ], "category": "sans-serif" } }, { "Muli": { "variants": [ "200", "200italic", "300", "300italic", "regular", "italic", "600", "600italic", "700", "700italic", "800", "800italic", "900", "900italic" ], "category": "sans-serif" } }, { "Mystery Quest": { "variants": [ "regular" ], "category": "display" } }, { "NTR": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Nanum Brush Script": { "variants": [ "regular" ], "category": "handwriting" } }, { "Nanum Gothic": { "variants": [ "regular", "700", "800" ], "category": "sans-serif" } }, { "Nanum Gothic Coding": { "variants": [ "regular", "700" ], "category": "monospace" } }, { "Nanum Myeongjo": { "variants": [ "regular", "700", "800" ], "category": "serif" } }, { "Nanum Pen Script": { "variants": [ "regular" ], "category": "handwriting" } }, { "Neucha": { "variants": [ "regular" ], "category": "handwriting" } }, { "Neuton": { "variants": [ "200", "300", "regular", "italic", "700", "800" ], "category": "serif" } }, { "New Rocker": { "variants": [ "regular" ], "category": "display" } }, { "News Cycle": { "variants": [ "regular", "700" ], "category": "sans-serif" } }, { "Niconne": { "variants": [ "regular" ], "category": "handwriting" } }, { "Niramit": { "variants": [ "200", "200italic", "300", "300italic", "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic" ], "category": "sans-serif" } }, { "Nixie One": { "variants": [ "regular" ], "category": "display" } }, { "Nobile": { "variants": [ "regular", "italic", "500", "500italic", "700", "700italic" ], "category": "sans-serif" } }, { "Nokora": { "variants": [ "regular", "700" ], "category": "serif" } }, { "Norican": { "variants": [ "regular" ], "category": "handwriting" } }, { "Nosifer": { "variants": [ "regular" ], "category": "display" } }, { "Notable": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Nothing You Could Do": { "variants": [ "regular" ], "category": "handwriting" } }, { "Noticia Text": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "serif" } }, { "Noto Sans": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "sans-serif" } }, { "Noto Sans JP": { "variants": [ "100", "300", "regular", "500", "700", "900" ], "category": "sans-serif" } }, { "Noto Sans KR": { "variants": [ "100", "300", "regular", "500", "700", "900" ], "category": "sans-serif" } }, { "Noto Serif": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "serif" } }, { "Noto Serif JP": { "variants": [ "200", "300", "regular", "500", "600", "700", "900" ], "category": "sans-serif" } }, { "Noto Serif KR": { "variants": [ "200", "300", "regular", "500", "600", "700", "900" ], "category": "sans-serif" } }, { "Nova Cut": { "variants": [ "regular" ], "category": "display" } }, { "Nova Flat": { "variants": [ "regular" ], "category": "display" } }, { "Nova Mono": { "variants": [ "regular" ], "category": "monospace" } }, { "Nova Oval": { "variants": [ "regular" ], "category": "display" } }, { "Nova Round": { "variants": [ "regular" ], "category": "display" } }, { "Nova Script": { "variants": [ "regular" ], "category": "display" } }, { "Nova Slim": { "variants": [ "regular" ], "category": "display" } }, { "Nova Square": { "variants": [ "regular" ], "category": "display" } }, { "Numans": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Nunito": { "variants": [ "200", "200italic", "300", "300italic", "regular", "italic", "600", "600italic", "700", "700italic", "800", "800italic", "900", "900italic" ], "category": "sans-serif" } }, { "Nunito Sans": { "variants": [ "200", "200italic", "300", "300italic", "regular", "italic", "600", "600italic", "700", "700italic", "800", "800italic", "900", "900italic" ], "category": "sans-serif" } }, { "Odor Mean Chey": { "variants": [ "regular" ], "category": "display" } }, { "Offside": { "variants": [ "regular" ], "category": "display" } }, { "Old Standard TT": { "variants": [ "regular", "italic", "700" ], "category": "serif" } }, { "Oldenburg": { "variants": [ "regular" ], "category": "display" } }, { "Oleo Script": { "variants": [ "regular", "700" ], "category": "display" } }, { "Oleo Script Swash Caps": { "variants": [ "regular", "700" ], "category": "display" } }, { "Open Sans": { "variants": [ "300", "300italic", "regular", "italic", "600", "600italic", "700", "700italic", "800", "800italic" ], "category": "sans-serif" } }, { "Open Sans Condensed": { "variants": [ "300", "300italic", "700" ], "category": "sans-serif" } }, { "Oranienbaum": { "variants": [ "regular" ], "category": "serif" } }, { "Orbitron": { "variants": [ "regular", "500", "700", "900" ], "category": "sans-serif" } }, { "Oregano": { "variants": [ "regular", "italic" ], "category": "display" } }, { "Orienta": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Original Surfer": { "variants": [ "regular" ], "category": "display" } }, { "Oswald": { "variants": [ "200", "300", "regular", "500", "600", "700" ], "category": "sans-serif" } }, { "Over the Rainbow": { "variants": [ "regular" ], "category": "handwriting" } }, { "Overlock": { "variants": [ "regular", "italic", "700", "700italic", "900", "900italic" ], "category": "display" } }, { "Overlock SC": { "variants": [ "regular" ], "category": "display" } }, { "Overpass": { "variants": [ "100", "100italic", "200", "200italic", "300", "300italic", "regular", "italic", "600", "600italic", "700", "700italic", "800", "800italic", "900", "900italic" ], "category": "sans-serif" } }, { "Overpass Mono": { "variants": [ "300", "regular", "600", "700" ], "category": "monospace" } }, { "Ovo": { "variants": [ "regular" ], "category": "serif" } }, { "Oxygen": { "variants": [ "300", "regular", "700" ], "category": "sans-serif" } }, { "Oxygen Mono": { "variants": [ "regular" ], "category": "monospace" } }, { "PT Mono": { "variants": [ "regular" ], "category": "monospace" } }, { "PT Sans": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "sans-serif" } }, { "PT Sans Caption": { "variants": [ "regular", "700" ], "category": "sans-serif" } }, { "PT Sans Narrow": { "variants": [ "regular", "700" ], "category": "sans-serif" } }, { "PT Serif": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "serif" } }, { "PT Serif Caption": { "variants": [ "regular", "italic" ], "category": "serif" } }, { "Pacifico": { "variants": [ "regular" ], "category": "handwriting" } }, { "Padauk": { "variants": [ "regular", "700" ], "category": "sans-serif" } }, { "Palanquin": { "variants": [ "100", "200", "300", "regular", "500", "600", "700" ], "category": "sans-serif" } }, { "Palanquin Dark": { "variants": [ "regular", "500", "600", "700" ], "category": "sans-serif" } }, { "Pangolin": { "variants": [ "regular" ], "category": "handwriting" } }, { "Paprika": { "variants": [ "regular" ], "category": "display" } }, { "Parisienne": { "variants": [ "regular" ], "category": "handwriting" } }, { "Passero One": { "variants": [ "regular" ], "category": "display" } }, { "Passion One": { "variants": [ "regular", "700", "900" ], "category": "display" } }, { "Pathway Gothic One": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Patrick Hand": { "variants": [ "regular" ], "category": "handwriting" } }, { "Patrick Hand SC": { "variants": [ "regular" ], "category": "handwriting" } }, { "Pattaya": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Patua One": { "variants": [ "regular" ], "category": "display" } }, { "Pavanam": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Paytone One": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Peddana": { "variants": [ "regular" ], "category": "serif" } }, { "Peralta": { "variants": [ "regular" ], "category": "display" } }, { "Permanent Marker": { "variants": [ "regular" ], "category": "handwriting" } }, { "Petit Formal Script": { "variants": [ "regular" ], "category": "handwriting" } }, { "Petrona": { "variants": [ "regular" ], "category": "serif" } }, { "Philosopher": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "sans-serif" } }, { "Piedra": { "variants": [ "regular" ], "category": "display" } }, { "Pinyon Script": { "variants": [ "regular" ], "category": "handwriting" } }, { "Pirata One": { "variants": [ "regular" ], "category": "display" } }, { "Plaster": { "variants": [ "regular" ], "category": "display" } }, { "Play": { "variants": [ "regular", "700" ], "category": "sans-serif" } }, { "Playball": { "variants": [ "regular" ], "category": "display" } }, { "Playfair Display": { "variants": [ "regular", "italic", "700", "700italic", "900", "900italic" ], "category": "serif" } }, { "Playfair Display SC": { "variants": [ "regular", "italic", "700", "700italic", "900", "900italic" ], "category": "serif" } }, { "Podkova": { "variants": [ "regular", "500", "600", "700", "800" ], "category": "serif" } }, { "Poiret One": { "variants": [ "regular" ], "category": "display" } }, { "Poller One": { "variants": [ "regular" ], "category": "display" } }, { "Poly": { "variants": [ "regular", "italic" ], "category": "serif" } }, { "Pompiere": { "variants": [ "regular" ], "category": "display" } }, { "Pontano Sans": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Poor Story": { "variants": [ "regular" ], "category": "display" } }, { "Poppins": { "variants": [ "100", "100italic", "200", "200italic", "300", "300italic", "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic", "800", "800italic", "900", "900italic" ], "category": "sans-serif" } }, { "Port Lligat Sans": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Port Lligat Slab": { "variants": [ "regular" ], "category": "serif" } }, { "Pragati Narrow": { "variants": [ "regular", "700" ], "category": "sans-serif" } }, { "Prata": { "variants": [ "regular" ], "category": "serif" } }, { "Preahvihear": { "variants": [ "regular" ], "category": "display" } }, { "Press Start 2P": { "variants": [ "regular" ], "category": "display" } }, { "Pridi": { "variants": [ "200", "300", "regular", "500", "600", "700" ], "category": "serif" } }, { "Princess Sofia": { "variants": [ "regular" ], "category": "handwriting" } }, { "Prociono": { "variants": [ "regular" ], "category": "serif" } }, { "Prompt": { "variants": [ "100", "100italic", "200", "200italic", "300", "300italic", "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic", "800", "800italic", "900", "900italic" ], "category": "sans-serif" } }, { "Prosto One": { "variants": [ "regular" ], "category": "display" } }, { "Proza Libre": { "variants": [ "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic", "800", "800italic" ], "category": "sans-serif" } }, { "Puritan": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "sans-serif" } }, { "Purple Purse": { "variants": [ "regular" ], "category": "display" } }, { "Quando": { "variants": [ "regular" ], "category": "serif" } }, { "Quantico": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "sans-serif" } }, { "Quattrocento": { "variants": [ "regular", "700" ], "category": "serif" } }, { "Quattrocento Sans": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "sans-serif" } }, { "Questrial": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Quicksand": { "variants": [ "300", "regular", "500", "700" ], "category": "sans-serif" } }, { "Quintessential": { "variants": [ "regular" ], "category": "handwriting" } }, { "Qwigley": { "variants": [ "regular" ], "category": "handwriting" } }, { "Racing Sans One": { "variants": [ "regular" ], "category": "display" } }, { "Radley": { "variants": [ "regular", "italic" ], "category": "serif" } }, { "Rajdhani": { "variants": [ "300", "regular", "500", "600", "700" ], "category": "sans-serif" } }, { "Rakkas": { "variants": [ "regular" ], "category": "display" } }, { "Raleway": { "variants": [ "100", "100italic", "200", "200italic", "300", "300italic", "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic", "800", "800italic", "900", "900italic" ], "category": "sans-serif" } }, { "Raleway Dots": { "variants": [ "regular" ], "category": "display" } }, { "Ramabhadra": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Ramaraja": { "variants": [ "regular" ], "category": "serif" } }, { "Rambla": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "sans-serif" } }, { "Rammetto One": { "variants": [ "regular" ], "category": "display" } }, { "Ranchers": { "variants": [ "regular" ], "category": "display" } }, { "Rancho": { "variants": [ "regular" ], "category": "handwriting" } }, { "Ranga": { "variants": [ "regular", "700" ], "category": "display" } }, { "Rasa": { "variants": [ "300", "regular", "500", "600", "700" ], "category": "serif" } }, { "Rationale": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Ravi Prakash": { "variants": [ "regular" ], "category": "display" } }, { "Redressed": { "variants": [ "regular" ], "category": "handwriting" } }, { "Reem Kufi": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Reenie Beanie": { "variants": [ "regular" ], "category": "handwriting" } }, { "Revalia": { "variants": [ "regular" ], "category": "display" } }, { "Rhodium Libre": { "variants": [ "regular" ], "category": "serif" } }, { "Ribeye": { "variants": [ "regular" ], "category": "display" } }, { "Ribeye Marrow": { "variants": [ "regular" ], "category": "display" } }, { "Righteous": { "variants": [ "regular" ], "category": "display" } }, { "Risque": { "variants": [ "regular" ], "category": "display" } }, { "Roboto": { "variants": [ "100", "100italic", "300", "300italic", "regular", "italic", "500", "500italic", "700", "700italic", "900", "900italic" ], "category": "sans-serif" } }, { "Roboto Condensed": { "variants": [ "300", "300italic", "regular", "italic", "700", "700italic" ], "category": "sans-serif" } }, { "Roboto Mono": { "variants": [ "100", "100italic", "300", "300italic", "regular", "italic", "500", "500italic", "700", "700italic" ], "category": "monospace" } }, { "Roboto Slab": { "variants": [ "100", "300", "regular", "700" ], "category": "serif" } }, { "Rochester": { "variants": [ "regular" ], "category": "handwriting" } }, { "Rock Salt": { "variants": [ "regular" ], "category": "handwriting" } }, { "Rokkitt": { "variants": [ "100", "200", "300", "regular", "500", "600", "700", "800", "900" ], "category": "serif" } }, { "Romanesco": { "variants": [ "regular" ], "category": "handwriting" } }, { "Ropa Sans": { "variants": [ "regular", "italic" ], "category": "sans-serif" } }, { "Rosario": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "sans-serif" } }, { "Rosarivo": { "variants": [ "regular", "italic" ], "category": "serif" } }, { "Rouge Script": { "variants": [ "regular" ], "category": "handwriting" } }, { "Rozha One": { "variants": [ "regular" ], "category": "serif" } }, { "Rubik": { "variants": [ "300", "300italic", "regular", "italic", "500", "500italic", "700", "700italic", "900", "900italic" ], "category": "sans-serif" } }, { "Rubik Mono One": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Ruda": { "variants": [ "regular", "700", "900" ], "category": "sans-serif" } }, { "Rufina": { "variants": [ "regular", "700" ], "category": "serif" } }, { "Ruge Boogie": { "variants": [ "regular" ], "category": "handwriting" } }, { "Ruluko": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Rum Raisin": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Ruslan Display": { "variants": [ "regular" ], "category": "display" } }, { "Russo One": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Ruthie": { "variants": [ "regular" ], "category": "handwriting" } }, { "Rye": { "variants": [ "regular" ], "category": "display" } }, { "Sacramento": { "variants": [ "regular" ], "category": "handwriting" } }, { "Sahitya": { "variants": [ "regular", "700" ], "category": "serif" } }, { "Sail": { "variants": [ "regular" ], "category": "display" } }, { "Saira": { "variants": [ "100", "200", "300", "regular", "500", "600", "700", "800", "900" ], "category": "sans-serif" } }, { "Saira Condensed": { "variants": [ "100", "200", "300", "regular", "500", "600", "700", "800", "900" ], "category": "sans-serif" } }, { "Saira Extra Condensed": { "variants": [ "100", "200", "300", "regular", "500", "600", "700", "800", "900" ], "category": "sans-serif" } }, { "Saira Semi Condensed": { "variants": [ "100", "200", "300", "regular", "500", "600", "700", "800", "900" ], "category": "sans-serif" } }, { "Salsa": { "variants": [ "regular" ], "category": "display" } }, { "Sanchez": { "variants": [ "regular", "italic" ], "category": "serif" } }, { "Sancreek": { "variants": [ "regular" ], "category": "display" } }, { "Sansita": { "variants": [ "regular", "italic", "700", "700italic", "800", "800italic", "900", "900italic" ], "category": "sans-serif" } }, { "Sarala": { "variants": [ "regular", "700" ], "category": "sans-serif" } }, { "Sarina": { "variants": [ "regular" ], "category": "display" } }, { "Sarpanch": { "variants": [ "regular", "500", "600", "700", "800", "900" ], "category": "sans-serif" } }, { "Satisfy": { "variants": [ "regular" ], "category": "handwriting" } }, { "Sawarabi Gothic": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Sawarabi Mincho": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Scada": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "sans-serif" } }, { "Scheherazade": { "variants": [ "regular", "700" ], "category": "serif" } }, { "Schoolbell": { "variants": [ "regular" ], "category": "handwriting" } }, { "Scope One": { "variants": [ "regular" ], "category": "serif" } }, { "Seaweed Script": { "variants": [ "regular" ], "category": "display" } }, { "Secular One": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Sedgwick Ave": { "variants": [ "regular" ], "category": "handwriting" } }, { "Sedgwick Ave Display": { "variants": [ "regular" ], "category": "handwriting" } }, { "Sevillana": { "variants": [ "regular" ], "category": "display" } }, { "Seymour One": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Shadows Into Light": { "variants": [ "regular" ], "category": "handwriting" } }, { "Shadows Into Light Two": { "variants": [ "regular" ], "category": "handwriting" } }, { "Shanti": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Share": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "display" } }, { "Share Tech": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Share Tech Mono": { "variants": [ "regular" ], "category": "monospace" } }, { "Shojumaru": { "variants": [ "regular" ], "category": "display" } }, { "Short Stack": { "variants": [ "regular" ], "category": "handwriting" } }, { "Shrikhand": { "variants": [ "regular" ], "category": "display" } }, { "Siemreap": { "variants": [ "regular" ], "category": "display" } }, { "Sigmar One": { "variants": [ "regular" ], "category": "display" } }, { "Signika": { "variants": [ "300", "regular", "600", "700" ], "category": "sans-serif" } }, { "Signika Negative": { "variants": [ "300", "regular", "600", "700" ], "category": "sans-serif" } }, { "Simonetta": { "variants": [ "regular", "italic", "900", "900italic" ], "category": "display" } }, { "Sintony": { "variants": [ "regular", "700" ], "category": "sans-serif" } }, { "Sirin Stencil": { "variants": [ "regular" ], "category": "display" } }, { "Six Caps": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Skranji": { "variants": [ "regular", "700" ], "category": "display" } }, { "Slabo 13px": { "variants": [ "regular" ], "category": "serif" } }, { "Slabo 27px": { "variants": [ "regular" ], "category": "serif" } }, { "Slackey": { "variants": [ "regular" ], "category": "display" } }, { "Smokum": { "variants": [ "regular" ], "category": "display" } }, { "Smythe": { "variants": [ "regular" ], "category": "display" } }, { "Sniglet": { "variants": [ "regular", "800" ], "category": "display" } }, { "Snippet": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Snowburst One": { "variants": [ "regular" ], "category": "display" } }, { "Sofadi One": { "variants": [ "regular" ], "category": "display" } }, { "Sofia": { "variants": [ "regular" ], "category": "handwriting" } }, { "Song Myung": { "variants": [ "regular" ], "category": "serif" } }, { "Sonsie One": { "variants": [ "regular" ], "category": "display" } }, { "Sorts Mill Goudy": { "variants": [ "regular", "italic" ], "category": "serif" } }, { "Source Code Pro": { "variants": [ "200", "300", "regular", "500", "600", "700", "900" ], "category": "monospace" } }, { "Source Sans Pro": { "variants": [ "200", "200italic", "300", "300italic", "regular", "italic", "600", "600italic", "700", "700italic", "900", "900italic" ], "category": "sans-serif" } }, { "Source Serif Pro": { "variants": [ "regular", "600", "700" ], "category": "serif" } }, { "Space Mono": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "monospace" } }, { "Special Elite": { "variants": [ "regular" ], "category": "display" } }, { "Spectral": { "variants": [ "200", "200italic", "300", "300italic", "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic", "800", "800italic" ], "category": "serif" } }, { "Spectral SC": { "variants": [ "200", "200italic", "300", "300italic", "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic", "800", "800italic" ], "category": "serif" } }, { "Spicy Rice": { "variants": [ "regular" ], "category": "display" } }, { "Spinnaker": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Spirax": { "variants": [ "regular" ], "category": "display" } }, { "Squada One": { "variants": [ "regular" ], "category": "display" } }, { "Sree Krushnadevaraya": { "variants": [ "regular" ], "category": "serif" } }, { "Sriracha": { "variants": [ "regular" ], "category": "handwriting" } }, { "Srisakdi": { "variants": [ "regular", "700" ], "category": "display" } }, { "Stalemate": { "variants": [ "regular" ], "category": "handwriting" } }, { "Stalinist One": { "variants": [ "regular" ], "category": "display" } }, { "Stardos Stencil": { "variants": [ "regular", "700" ], "category": "display" } }, { "Stint Ultra Condensed": { "variants": [ "regular" ], "category": "display" } }, { "Stint Ultra Expanded": { "variants": [ "regular" ], "category": "display" } }, { "Stoke": { "variants": [ "300", "regular" ], "category": "serif" } }, { "Strait": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Stylish": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Sue Ellen Francisco": { "variants": [ "regular" ], "category": "handwriting" } }, { "Suez One": { "variants": [ "regular" ], "category": "serif" } }, { "Sumana": { "variants": [ "regular", "700" ], "category": "serif" } }, { "Sunflower": { "variants": [ "300", "500", "700" ], "category": "sans-serif" } }, { "Sunshiney": { "variants": [ "regular" ], "category": "handwriting" } }, { "Supermercado One": { "variants": [ "regular" ], "category": "display" } }, { "Sura": { "variants": [ "regular", "700" ], "category": "serif" } }, { "Suranna": { "variants": [ "regular" ], "category": "serif" } }, { "Suravaram": { "variants": [ "regular" ], "category": "serif" } }, { "Suwannaphum": { "variants": [ "regular" ], "category": "display" } }, { "Swanky and Moo Moo": { "variants": [ "regular" ], "category": "handwriting" } }, { "Syncopate": { "variants": [ "regular", "700" ], "category": "sans-serif" } }, { "Tajawal": { "variants": [ "200", "300", "regular", "500", "700", "800", "900" ], "category": "sans-serif" } }, { "Tangerine": { "variants": [ "regular", "700" ], "category": "handwriting" } }, { "Taprom": { "variants": [ "regular" ], "category": "display" } }, { "Tauri": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Taviraj": { "variants": [ "100", "100italic", "200", "200italic", "300", "300italic", "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic", "800", "800italic", "900", "900italic" ], "category": "serif" } }, { "Teko": { "variants": [ "300", "regular", "500", "600", "700" ], "category": "sans-serif" } }, { "Telex": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Tenali Ramakrishna": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Tenor Sans": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Text Me One": { "variants": [ "regular" ], "category": "sans-serif" } }, { "The Girl Next Door": { "variants": [ "regular" ], "category": "handwriting" } }, { "Tienne": { "variants": [ "regular", "700", "900" ], "category": "serif" } }, { "Tillana": { "variants": [ "regular", "500", "600", "700", "800" ], "category": "handwriting" } }, { "Timmana": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Tinos": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "serif" } }, { "Titan One": { "variants": [ "regular" ], "category": "display" } }, { "Titillium Web": { "variants": [ "200", "200italic", "300", "300italic", "regular", "italic", "600", "600italic", "700", "700italic", "900" ], "category": "sans-serif" } }, { "Trade Winds": { "variants": [ "regular" ], "category": "display" } }, { "Trirong": { "variants": [ "100", "100italic", "200", "200italic", "300", "300italic", "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic", "800", "800italic", "900", "900italic" ], "category": "serif" } }, { "Trocchi": { "variants": [ "regular" ], "category": "serif" } }, { "Trochut": { "variants": [ "regular", "italic", "700" ], "category": "display" } }, { "Trykker": { "variants": [ "regular" ], "category": "serif" } }, { "Tulpen One": { "variants": [ "regular" ], "category": "display" } }, { "Ubuntu": { "variants": [ "300", "300italic", "regular", "italic", "500", "500italic", "700", "700italic" ], "category": "sans-serif" } }, { "Ubuntu Condensed": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Ubuntu Mono": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "monospace" } }, { "Ultra": { "variants": [ "regular" ], "category": "serif" } }, { "Uncial Antiqua": { "variants": [ "regular" ], "category": "display" } }, { "Underdog": { "variants": [ "regular" ], "category": "display" } }, { "Unica One": { "variants": [ "regular" ], "category": "display" } }, { "UnifrakturCook": { "variants": [ "700" ], "category": "display" } }, { "UnifrakturMaguntia": { "variants": [ "regular" ], "category": "display" } }, { "Unkempt": { "variants": [ "regular", "700" ], "category": "display" } }, { "Unlock": { "variants": [ "regular" ], "category": "display" } }, { "Unna": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "serif" } }, { "VT323": { "variants": [ "regular" ], "category": "monospace" } }, { "Vampiro One": { "variants": [ "regular" ], "category": "display" } }, { "Varela": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Varela Round": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Vast Shadow": { "variants": [ "regular" ], "category": "display" } }, { "Vesper Libre": { "variants": [ "regular", "500", "700", "900" ], "category": "serif" } }, { "Vibur": { "variants": [ "regular" ], "category": "handwriting" } }, { "Vidaloka": { "variants": [ "regular" ], "category": "serif" } }, { "Viga": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Voces": { "variants": [ "regular" ], "category": "display" } }, { "Volkhov": { "variants": [ "regular", "italic", "700", "700italic" ], "category": "serif" } }, { "Vollkorn": { "variants": [ "regular", "italic", "600", "600italic", "700", "700italic", "900", "900italic" ], "category": "serif" } }, { "Vollkorn SC": { "variants": [ "regular", "600", "700", "900" ], "category": "serif" } }, { "Voltaire": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Waiting for the Sunrise": { "variants": [ "regular" ], "category": "handwriting" } }, { "Wallpoet": { "variants": [ "regular" ], "category": "display" } }, { "Walter Turncoat": { "variants": [ "regular" ], "category": "handwriting" } }, { "Warnes": { "variants": [ "regular" ], "category": "display" } }, { "Wellfleet": { "variants": [ "regular" ], "category": "display" } }, { "Wendy One": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Wire One": { "variants": [ "regular" ], "category": "sans-serif" } }, { "Work Sans": { "variants": [ "100", "200", "300", "regular", "500", "600", "700", "800", "900" ], "category": "sans-serif" } }, { "Yanone Kaffeesatz": { "variants": [ "200", "300", "regular", "700" ], "category": "sans-serif" } }, { "Yantramanav": { "variants": [ "100", "300", "regular", "500", "700", "900" ], "category": "sans-serif" } }, { "Yatra One": { "variants": [ "regular" ], "category": "display" } }, { "Yellowtail": { "variants": [ "regular" ], "category": "handwriting" } }, { "Yeon Sung": { "variants": [ "regular" ], "category": "display" } }, { "Yeseva One": { "variants": [ "regular" ], "category": "display" } }, { "Yesteryear": { "variants": [ "regular" ], "category": "handwriting" } }, { "Yrsa": { "variants": [ "300", "regular", "500", "600", "700" ], "category": "serif" } }, { "Zeyada": { "variants": [ "regular" ], "category": "handwriting" } }, { "Zilla Slab": { "variants": [ "300", "300italic", "regular", "italic", "500", "500italic", "600", "600italic", "700", "700italic" ], "category": "serif" } }, { "Zilla Slab Highlight": { "variants": [ "regular", "700" ], "category": "display" } } ]class-cartflows-update.php000066600000006074152133015060011653 0ustar00logger_files(); if ( version_compare( $saved_version, '1.1.22', '<' ) ) { update_option( 'wcf_setup_skipped', true ); } if ( version_compare( $saved_version, '1.2.0', '<' ) ) { $this->changed_wp_templates(); } // Update auto saved version number. update_option( 'cartflows-version', CARTFLOWS_VER ); do_action( 'cartflows_update_after' ); } /** * Loading logger files. * * @since 1.0.0 * @return void */ public function logger_files() { if ( ! defined( 'CARTFLOWS_LOG_DIR' ) ) { $upload_dir = wp_upload_dir( null, false ); define( 'CARTFLOWS_LOG_DIR', $upload_dir['basedir'] . '/cartflows-logs/' ); } wcf()->create_files(); } /** * Init * * @since 1.0.0 * @return void */ public function changed_wp_templates() { global $wpdb; $query_results = $wpdb->get_results( $wpdb->prepare( "SELECT {$wpdb->posts}.ID FROM {$wpdb->posts} LEFT JOIN {$wpdb->postmeta} ON ( {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id ) where {$wpdb->posts}.post_type = %s AND {$wpdb->postmeta}.meta_key = %s AND {$wpdb->postmeta}.meta_value != %s AND {$wpdb->postmeta}.meta_value != %s", 'cartflows_step', '_wp_page_template', 'cartflows-canvas', 'cartflows-default' ) ); // db call ok; no-cache ok. if ( is_array( $query_results ) && ! empty( $query_results ) ) { require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-change-template-batch.php'; wcf()->logger->log( '(✓) Update Templates BATCH Started!' ); $change_template_batch = new Cartflows_Change_Template_Batch(); foreach ( $query_results as $query_result ) { wcf()->logger->log( '(✓) POST ID ' . $query_result->ID ); $change_template_batch->push_to_queue( $query_result->ID ); } $change_template_batch->save()->dispatch(); } } } /** * Kicking this off by calling 'get_instance()' method */ Cartflows_Update::get_instance(); endif; class-cartflows-wizard.php000066600000057553152133015060011701 0ustar00 steps = array( 'basic-config' => array( 'name' => __( 'Welcome', 'cartflows' ), 'view' => array( $this, 'welcome_step' ), 'handler' => array( $this, 'welcome_step_save' ), ), 'page-builder' => array( 'name' => __( 'Page Builder', 'cartflows' ), 'view' => array( $this, 'page_builder_step' ), ), 'checkout' => array( 'name' => __( 'Checkout', 'cartflows' ), 'view' => array( $this, 'checkout_step' ), ), 'training' => array( 'name' => __( 'Training', 'cartflows' ), 'view' => array( $this, 'training_step' ), ), 'setup-ready' => array( 'name' => __( 'Ready!', 'cartflows' ), 'view' => array( $this, 'ready_step' ), 'handler' => '', ), ); $this->step = isset( $_GET['step'] ) ? sanitize_text_field( $_GET['step'] ) : current( array_keys( $this->steps ) ); //phpcs:ignore wp_enqueue_style( 'cartflows-setup', CARTFLOWS_URL . 'admin/assets/css/setup-wizard.css', array( 'dashicons' ), CARTFLOWS_VER ); wp_style_add_data( 'cartflows-setup', 'rtl', 'replace' ); wp_enqueue_script( 'cartflows-setup', CARTFLOWS_URL . 'admin/assets/js/setup-wizard.js', array( 'jquery', 'wp-util', 'updates' ), CARTFLOWS_VER, false ); wp_localize_script( 'cartflows-setup', 'cartflows_setup_vars', self::localize_vars() ); wp_enqueue_media(); if ( ! empty( $_POST['save_step'] ) && isset( $this->steps[ $this->step ]['handler'] ) ) { //phpcs:ignore call_user_func( $this->steps[ $this->step ]['handler'] ); } ob_start(); $this->setup_wizard_header(); $this->setup_wizard_steps(); $this->setup_wizard_content(); $this->setup_wizard_footer(); exit; } /** * Get current step slug */ public function get_current_step_slug() { $keys = array_keys( $this->steps ); return $keys[ array_search( $this->step, array_keys( $this->steps ), true ) ]; } /** * Get previous step link */ public function get_prev_step_link() { $keys = array_keys( $this->steps ); return add_query_arg( 'step', $keys[ array_search( $this->step, array_keys( $this->steps ), true ) - 1 ] ); } /** * Get next step link */ public function get_next_step_link() { $keys = array_keys( $this->steps ); return add_query_arg( 'step', $keys[ array_search( $this->step, array_keys( $this->steps ), true ) + 1 ] ); } /** * Get next step link */ public function get_next_step_plain_link() { $keys = array_keys( $this->steps ); $step_index = array_search( $this->step, $keys, true ); $step_index = ( count( $keys ) == $step_index + 1 ) ? $step_index : $step_index + 1; $step = $keys[ $step_index ]; return admin_url( 'index.php?page=cartflow-setup&step=' . $step ); } /** * Setup Wizard Header. */ public function setup_wizard_header() { set_current_screen(); ?> > <?php esc_html_e( 'CartFlows Setup', 'cartflows' ); ?>
steps; ?>
    $step ) : $classes = ''; $activated = false; if ( $step_key === $this->step ) { $classes = 'active'; $activated = true; } elseif ( array_search( $this->step, array_keys( $this->steps ), true ) > array_search( $step_key, array_keys( $this->steps ), true ) ) { $classes = 'done'; $activated = true; } ?>
'; call_user_func( $this->steps[ $this->step ]['view'] ); echo ''; } /** * Introduction step. */ public function welcome_step() { ?>

get_next_step_link(); wp_safe_redirect( esc_url_raw( $redirect_url ) ); exit; } /** * Locale settings */ public function page_builder_step() { ?>

__( 'Elementor', 'cartflows' ), 'value' => 'elementor', 'data' => array( 'slug' => 'elementor', 'init' => 'elementor/elementor.php', 'active' => is_plugin_active( 'elementor/elementor.php' ) ? 'yes' : 'no', 'install' => isset( $installed_plugins['elementor/elementor.php'] ) ? 'yes' : 'no', ), ), array( 'title' => __( 'Beaver Builder Plugin (Lite Version)', 'cartflows' ), 'value' => 'beaver-builder', 'data' => array( 'slug' => 'beaver-builder-lite-version', 'init' => 'beaver-builder-lite-version/fl-builder.php', 'active' => is_plugin_active( 'beaver-builder-lite-version/fl-builder.php' ) ? 'yes' : 'no', 'install' => isset( $installed_plugins['beaver-builder-lite-version/fl-builder.php'] ) ? 'yes' : 'no', ), ), array( 'title' => __( 'Divi', 'cartflows' ), 'value' => 'divi', 'data' => array( 'slug' => 'divi', 'init' => 'divi', 'active' => 'yes', 'install' => 'NA', ), ), array( 'title' => __( 'Other', 'cartflows' ), 'value' => 'other', 'data' => array( 'slug' => 'other', 'init' => false, 'active' => 'yes', 'install' => 'NA', ), ), ); ?>

true, 'woo-cart-abandonment-recovery/woo-cart-abandonment-recovery.php' => false, ); $activate = array( 'woocommerce/woocommerce.php' => false, 'woo-cart-abandonment-recovery/woo-cart-abandonment-recovery.php' => false, ); foreach ( $plugin_slug_arr as $slug => $do_silently ) { $activate[ $slug ] = activate_plugin( $slug, '', false, $do_silently ); } foreach ( $activate as $slug => $data ) { if ( is_wp_error( $data ) ) { wp_send_json_error( array( 'success' => false, 'message' => $data->get_error_message(), ) ); } } wp_send_json_success(); } /** * Save Locale Settings. */ public function page_builder_step_save() { if ( ! current_user_can( 'manage_options' ) ) { return; } check_ajax_referer( 'wcf-page-builder-step-save', 'security' ); $plugin_init = isset( $_POST['plugin_init'] ) ? sanitize_text_field( wp_unslash( $_POST['plugin_init'] ) ) : ''; $save_option = ( isset( $_POST['save_builder_option'] ) && 'true' == $_POST['save_builder_option'] ) ? true : false; $plugin_slug = filter_input( INPUT_POST, 'page_builder', FILTER_SANITIZE_STRING ); $do_sliently = true; if ( 'woo-cart-abandonment-recovery' === $plugin_slug ) { $do_sliently = false; } $activate = activate_plugin( $plugin_init, '', false, $do_sliently ); if ( $save_option ) { $this->save_page_builder_option(); } if ( is_wp_error( $activate ) ) { wp_send_json_error( array( 'success' => false, 'message' => $activate->get_error_message(), ) ); } wp_send_json_success( array( 'plugin' => $plugin_slug ) ); } /** * Save selected page builder in options database. */ public function save_page_builder_option() { if ( ! current_user_can( 'manage_options' ) ) { return; } $page_builder = isset( $_POST['page_builder'] ) ? sanitize_text_field( wp_unslash( $_POST['page_builder'] ) ) : ''; //phpcs:ignore $wcf_settings = get_option( '_cartflows_common', array() ); if ( false !== strpos( $page_builder, 'beaver-builder' ) ) { $page_builder = 'beaver-builder'; } $wcf_settings['default_page_builder'] = $page_builder; update_option( '_cartflows_common', $wcf_settings ); wp_send_json_success( array( 'plugin' => $page_builder ) ); } /** * Final step. */ public function ready_step() { // Set setup wizard status to complete. update_option( 'wcf_setup_complete', true ); ?>

  • Next step

    Create First Flow

    You're ready to add flows to your website.

define_constants(); // Activation hook. register_activation_hook( CARTFLOWS_FILE, array( $this, 'activation_reset' ) ); // deActivation hook. register_deactivation_hook( CARTFLOWS_FILE, array( $this, 'deactivation_reset' ) ); add_action( 'plugins_loaded', array( $this, 'load_plugin' ), 99 ); add_action( 'plugins_loaded', array( $this, 'load_cf_textdomain' ) ); } /** * Defines all constants * * @since 1.0.0 */ public function define_constants() { define( 'CARTFLOWS_BASE', plugin_basename( CARTFLOWS_FILE ) ); define( 'CARTFLOWS_DIR', plugin_dir_path( CARTFLOWS_FILE ) ); define( 'CARTFLOWS_URL', plugins_url( '/', CARTFLOWS_FILE ) ); define( 'CARTFLOWS_VER', '1.5.5' ); define( 'CARTFLOWS_SLUG', 'cartflows' ); define( 'CARTFLOWS_SETTINGS', 'cartflows_settings' ); define( 'CARTFLOWS_FLOW_POST_TYPE', 'cartflows_flow' ); define( 'CARTFLOWS_STEP_POST_TYPE', 'cartflows_step' ); if ( ! defined( 'CARTFLOWS_SERVER_URL' ) ) { define( 'CARTFLOWS_SERVER_URL', 'https://my.cartflows.com/' ); } define( 'CARTFLOWS_DOMAIN_URL', 'https://cartflows.com/' ); define( 'CARTFLOWS_TEMPLATES_URL', 'https://templates.cartflows.com/' ); define( 'CARTFLOWS_TAXONOMY_STEP_TYPE', 'cartflows_step_type' ); define( 'CARTFLOWS_TAXONOMY_STEP_FLOW', 'cartflows_step_flow' ); if ( ! defined( 'CARTFLOWS_TAXONOMY_STEP_PAGE_BUILDER' ) ) { define( 'CARTFLOWS_TAXONOMY_STEP_PAGE_BUILDER', 'cartflows_step_page_builder' ); } if ( ! defined( 'CARTFLOWS_TAXONOMY_FLOW_PAGE_BUILDER' ) ) { define( 'CARTFLOWS_TAXONOMY_FLOW_PAGE_BUILDER', 'cartflows_flow_page_builder' ); } if ( ! defined( 'CARTFLOWS_TAXONOMY_FLOW_CATEGORY' ) ) { define( 'CARTFLOWS_TAXONOMY_FLOW_CATEGORY', 'cartflows_flow_category' ); } if ( ! defined( 'CARTFLOWS_LOG_DIR' ) ) { $upload_dir = wp_upload_dir( null, false ); define( 'CARTFLOWS_LOG_DIR', $upload_dir['basedir'] . '/cartflows-logs/' ); } } /** * Loads plugin files. * * @since 1.0.0 * * @return void */ public function load_plugin() { $this->load_helper_files_components(); $this->load_core_files(); $this->load_core_components(); add_action( 'wp_loaded', array( $this, 'initialize' ) ); add_action( 'cartflows_pro_init', array( $this, 'after_cartflows_pro_init' ) ); if ( ! $this->is_woo_active ) { add_action( 'admin_notices', array( $this, 'fails_to_load' ) ); } /** * CartFlows Init. * * Fires when Cartflows is instantiated. * * @since 1.0.0 */ do_action( 'cartflows_init' ); } /** * After CartFlows Pro init. * * @since 1.1.19 * * @return void */ public function after_cartflows_pro_init() { if ( ! is_admin() ) { return; } if ( version_compare( CARTFLOWS_PRO_VER, '1.4.0', '<' ) ) { add_action( 'admin_notices', array( $this, 'required_cartflows_pro_notice' ) ); } } /** * Required CartFlows Pro Notice. * * @since 1.1.19 * * @return void */ public function required_cartflows_pro_notice() { $required_pro_version = '1.4.0'; $class = 'notice notice-warning'; /* translators: %s: html tags */ $message = sprintf( __( 'You are using an older version of %1$sCartFlows Pro%2$s. Please update %1$sCartFlows Pro%2$s plugin to version %1$s%3$s%2$s or higher.', 'cartflows' ), '', '', $required_pro_version ); printf( '

%2$s

', $class, $message ); } /** * Load Helper Files and Components. * * @since 1.0.0 * * @return void */ public function load_helper_files_components() { $this->is_woo_active = function_exists( 'WC' ); /* Public Utils */ include_once CARTFLOWS_DIR . 'classes/class-cartflows-utils.php'; /* Public Global Namespace Function */ include_once CARTFLOWS_DIR . 'classes/class-cartflows-functions.php'; /* Admin Helper */ include_once CARTFLOWS_DIR . 'classes/class-cartflows-helper.php'; /* Meta Default Values */ include_once CARTFLOWS_DIR . 'classes/class-cartflows-default-meta.php'; require_once CARTFLOWS_DIR . 'classes/class-cartflows-tracking.php'; $this->utils = Cartflows_Utils::get_instance(); $this->options = Cartflows_Default_Meta::get_instance(); $this->alldata = Cartflows_Tracking::get_instance(); } /** * Init hooked function. * * @since 1.0.0 * * @return void */ public function initialize() { $this->assets_vars = $this->utils->get_assets_path(); } /** * Load Core Files. * * @since 1.0.0 * * @return void */ public function load_core_files() { /* Update compatibility. */ require_once CARTFLOWS_DIR . 'classes/class-cartflows-update.php'; /* Page builder compatibilty class */ include_once CARTFLOWS_DIR . 'classes/class-cartflows-compatibility.php'; /* Theme support */ include_once CARTFLOWS_DIR . 'classes/class-cartflows-theme-support.php'; /* Admin Meta Fields*/ include_once CARTFLOWS_DIR . 'classes/fields/typography/class-cartflows-font-families.php'; include_once CARTFLOWS_DIR . 'classes/class-cartflows-meta-fields.php'; include_once CARTFLOWS_DIR . 'classes/class-cartflows-meta.php'; /* Cloning */ include_once CARTFLOWS_DIR . 'classes/class-cartflows-cloning.php'; /* Admin Settings */ include_once CARTFLOWS_DIR . 'classes/class-cartflows-admin.php'; /* Logger */ include_once CARTFLOWS_DIR . 'classes/logger/class-cartflows-log-handler-interface.php'; include_once CARTFLOWS_DIR . 'classes/logger/class-cartflows-log-handler.php'; include_once CARTFLOWS_DIR . 'classes/logger/class-cartflows-log-handler-file.php'; include_once CARTFLOWS_DIR . 'classes/logger/class-cartflows-log-levels.php'; include_once CARTFLOWS_DIR . 'classes/logger/class-cartflows-logger-interface.php'; include_once CARTFLOWS_DIR . 'classes/logger/class-cartflows-wc-logger.php'; /* Core Modules */ include_once CARTFLOWS_DIR . 'classes/class-cartflows-logger.php'; /* Frontend Global */ include_once CARTFLOWS_DIR . 'classes/class-cartflows-frontend.php'; require_once CARTFLOWS_DIR . 'classes/class-cartflows-flow-frontend.php'; /* Modules */ include_once CARTFLOWS_DIR . 'modules/flow/class-cartflows-flow.php'; include_once CARTFLOWS_DIR . 'modules/landing/class-cartflows-landing.php'; if ( $this->is_woo_active ) { include_once CARTFLOWS_DIR . 'modules/checkout/class-cartflows-checkout.php'; include_once CARTFLOWS_DIR . 'modules/thankyou/class-cartflows-thankyou.php'; include_once CARTFLOWS_DIR . 'modules/optin/class-cartflows-optin.php'; } include_once CARTFLOWS_DIR . 'classes/class-cartflows-api.php'; include_once CARTFLOWS_DIR . 'classes/class-cartflows-importer-core.php'; include_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-batch-process.php'; include_once CARTFLOWS_DIR . 'classes/class-cartflows-importer.php'; include_once CARTFLOWS_DIR . 'classes/class-cartflows-wizard.php'; include_once CARTFLOWS_DIR . 'classes/class-cartflows-metabox.php'; include_once CARTFLOWS_DIR . 'classes/deprecated/deprecated-hooks.php'; } /** * Load Core Components. * * @since 1.0.0 * * @return void */ public function load_core_components() { $this->meta = Cartflows_Meta_Fields::get_instance(); $this->logger = Cartflows_Logger::get_instance(); $this->flow = Cartflows_Flow_Frontend::get_instance(); } /** * Create files/directories. */ public function create_files() { // Install files and folders for uploading files and prevent hotlinking. $upload_dir = wp_upload_dir(); $files = array( array( 'base' => CARTFLOWS_LOG_DIR, 'file' => '.htaccess', 'content' => 'deny from all', ), array( 'base' => CARTFLOWS_LOG_DIR, 'file' => 'index.html', 'content' => '', ), ); foreach ( $files as $file ) { if ( wp_mkdir_p( $file['base'] ) && ! file_exists( trailingslashit( $file['base'] ) . $file['file'] ) ) { $file_handle = @fopen( trailingslashit( $file['base'] ) . $file['file'], 'w' ); // phpcs:ignore if ( $file_handle ) { fwrite( $file_handle, $file['content'] ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fwrite fclose( $file_handle ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fclose } } } } /** * Load CartFlows Pro Text Domain. * This will load the translation textdomain depending on the file priorities. * 1. Global Languages /wp-content/languages/cartflows/ folder * 2. Local dorectory /wp-content/plugins/cartflows/languages/ folder * * @since 1.0.3 * @return void */ public function load_cf_textdomain() { // Default languages directory for CartFlows Pro. $lang_dir = CARTFLOWS_DIR . 'languages/'; /** * Filters the languages directory path to use for CartFlows Pro. * * @param string $lang_dir The languages directory path. */ $lang_dir = apply_filters( 'cartflows_languages_directory', $lang_dir ); // Traditional WordPress plugin locale filter. global $wp_version; $get_locale = get_locale(); if ( $wp_version >= 4.7 ) { $get_locale = get_user_locale(); } /** * Language Locale for CartFlows Pro * * @var $get_locale The locale to use. * Uses get_user_locale()` in WordPress 4.7 or greater, * otherwise uses `get_locale()`. */ $locale = apply_filters( 'plugin_locale', $get_locale, 'cartflows' ); $mofile = sprintf( '%1$s-%2$s.mo', 'cartflows', $locale ); // Setup paths to current locale file. $mofile_local = $lang_dir . $mofile; $mofile_global = WP_LANG_DIR . '/plugins/' . $mofile; if ( file_exists( $mofile_global ) ) { // Look in global /wp-content/languages/cartflows/ folder. load_textdomain( 'cartflows', $mofile_global ); } elseif ( file_exists( $mofile_local ) ) { // Look in local /wp-content/plugins/cartflows/languages/ folder. load_textdomain( 'cartflows', $mofile_local ); } else { // Load the default language files. load_plugin_textdomain( 'cartflows', false, $lang_dir ); } } /** * Fires admin notice when Elementor is not installed and activated. * * @since 1.0.0 * * @return void */ public function fails_to_load() { $screen = get_current_screen(); if ( ! wcf()->utils->is_step_post_type() ) { return; } if ( ! wcf()->utils->check_is_woo_required_page() ) { return; } $skip_notice = false; wp_localize_script( 'wcf-global-admin', 'cartflows_woo', array( 'show_update_post' => $skip_notice ) ); $class = 'notice notice-warning'; /* translators: %s: html tags */ $message = sprintf( __( 'This %1$sCartFlows%2$s page requires %1$sWooCommerce%2$s plugin installed & activated.', 'cartflows' ), '', '' ); $plugin = 'woocommerce/woocommerce.php'; if ( _is_woo_installed() ) { if ( ! current_user_can( 'activate_plugins' ) ) { return; } $action_url = wp_nonce_url( 'plugins.php?action=activate&plugin=' . $plugin . '&plugin_status=all&paged=1&s', 'activate-plugin_' . $plugin ); $button_label = __( 'Activate WooCommerce', 'cartflows' ); } else { if ( ! current_user_can( 'install_plugins' ) ) { return; } $action_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=woocommerce' ), 'install-plugin_woocommerce' ); $button_label = __( 'Install WooCommerce', 'cartflows' ); } $button = '

' . $button_label . '

'; printf( '

%2$s

%3$s
', esc_attr( $class ), $message, $button ); } /** * Activation Reset */ public function activation_reset() { if ( ! defined( 'CARTFLOWS_LOG_DIR' ) ) { $upload_dir = wp_upload_dir( null, false ); define( 'CARTFLOWS_LOG_DIR', $upload_dir['basedir'] . '/cartflows-logs/' ); } $this->create_files(); include_once CARTFLOWS_DIR . 'classes/class-cartflows-helper.php'; include_once CARTFLOWS_DIR . 'classes/class-cartflows-functions.php'; include_once CARTFLOWS_DIR . 'modules/flow/classes/class-cartflows-flow-post-type.php'; include_once CARTFLOWS_DIR . 'modules/flow/classes/class-cartflows-step-post-type.php'; Cartflows_Flow_Post_Type::get_instance()->flow_post_type(); Cartflows_Step_Post_Type::get_instance()->step_post_type(); flush_rewrite_rules(); } /** * Deactivation Reset */ public function deactivation_reset() { } /** * Logger Class Instance */ public function logger() { return Cartflows_Logger::get_instance(); } } /** * Prepare if class 'Cartflows_Loader' exist. * Kicking this off by calling 'get_instance()' method */ Cartflows_Loader::get_instance(); } /** * Get global class. * * @return object */ function wcf() { return Cartflows_Loader::get_instance(); } if ( ! function_exists( '_is_woo_installed' ) ) { /** * Is woocommerce plugin installed. * * @since 1.0.0 * * @access public */ function _is_woo_installed() { $path = 'woocommerce/woocommerce.php'; $plugins = get_plugins(); return isset( $plugins[ $path ] ); } } class-cartflows-helper.php000066600000047031152133015060011646 0ustar00is_divi_theme_installed() ) { $theme_status = 'installed'; if ( false === Cartflows_Compatibility::get_instance()->is_divi_enabled() ) { $theme_status = 'deactivate'; $divi_status = 'activate'; } else { $divi_status = ''; } } } $plugins = array( 'elementor' => array( 'title' => 'Elementor', 'plugins' => array( array( 'slug' => 'elementor', // For download from wp.org. 'init' => 'elementor/elementor.php', 'status' => self::get_plugin_status( 'elementor/elementor.php' ), ), ), ), 'divi' => array( 'title' => 'Divi', 'theme-status' => $theme_status, 'plugin-status' => $divi_status, 'plugins' => array( array( 'slug' => 'divi-builder', // For download from wp.org. 'init' => 'divi-builder/divi-builder.php', 'status' => $divi_status, ), ), ), ); $plugins['beaver-builder'] = array( 'title' => 'Beaver Builder', 'plugins' => array(), ); // Check Pro Exist. if ( file_exists( WP_PLUGIN_DIR . '/bb-plugin/fl-builder.php' ) && ! is_plugin_active( 'beaver-builder-lite-version/fl-builder.php' ) ) { $plugins['beaver-builder']['plugins'][] = array( 'slug' => 'bb-plugin', 'init' => 'bb-plugin/fl-builder.php', 'status' => self::get_plugin_status( 'bb-plugin/fl-builder.php' ), ); } else { $plugins['beaver-builder']['plugins'][] = array( 'slug' => 'beaver-builder-lite-version', // For download from wp.org. 'init' => 'beaver-builder-lite-version/fl-builder.php', 'status' => self::get_plugin_status( 'beaver-builder-lite-version/fl-builder.php' ), ); } if ( file_exists( WP_PLUGIN_DIR . '/bb-ultimate-addon/bb-ultimate-addon.php' ) && ! is_plugin_active( 'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php' ) ) { $plugins['beaver-builder']['plugins'][] = array( 'slug' => 'bb-ultimate-addon', 'init' => 'bb-ultimate-addon/bb-ultimate-addon.php', 'status' => self::get_plugin_status( 'bb-ultimate-addon/bb-ultimate-addon.php' ), ); } else { $plugins['beaver-builder']['plugins'][] = array( 'slug' => 'ultimate-addons-for-beaver-builder-lite', // For download from wp.org. 'init' => 'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php', 'status' => self::get_plugin_status( 'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php' ), ); } return $plugins; } /** * Get plugin status * * @since 1.1.4 * * @param string $plugin_init_file Plguin init file. * @return mixed */ public static function get_plugin_status( $plugin_init_file ) { if ( null == self::$installed_plugins ) { self::$installed_plugins = get_plugins(); } if ( ! isset( self::$installed_plugins[ $plugin_init_file ] ) ) { return 'install'; } elseif ( ! is_plugin_active( $plugin_init_file ) ) { return 'activate'; } else { return; } } /** * Get zapier settings. * * @return array. */ public static function get_common_settings() { if ( null === self::$common ) { $common_default = apply_filters( 'cartflows_common_settings_default', array( 'disallow_indexing' => 'disable', 'global_checkout' => '', 'default_page_builder' => 'elementor', ) ); $common = self::get_admin_settings_option( '_cartflows_common', false, false ); $common = wp_parse_args( $common, $common_default ); if ( ! did_action( 'wp' ) ) { return $common; } else { self::$common = $common; } } return self::$common; } /** * Get debug settings data. * * @return array. */ public static function get_debug_settings() { if ( null === self::$debug_data ) { $debug_data_default = apply_filters( 'cartflows_debug_settings_default', array( 'allow_minified_files' => 'disable', ) ); $debug_data = self::get_admin_settings_option( '_cartflows_debug_data', false, false ); $debug_data = wp_parse_args( $debug_data, $debug_data_default ); if ( ! did_action( 'wp' ) ) { return $debug_data; } else { self::$debug_data = $debug_data; } } return self::$debug_data; } /** * Get debug settings data. * * @return array. */ public static function get_permalink_settings() { if ( null === self::$permalink_setting ) { $permalink_default = apply_filters( 'cartflows_permalink_settings_default', array( 'permalink' => CARTFLOWS_STEP_POST_TYPE, 'permalink_flow_base' => CARTFLOWS_FLOW_POST_TYPE, 'permalink_structure' => '', ) ); $permalink_data = self::get_admin_settings_option( '_cartflows_permalink', false, false ); $permalink_data = wp_parse_args( $permalink_data, $permalink_default ); if ( ! did_action( 'wp' ) ) { return $permalink_data; } else { self::$permalink_setting = $permalink_data; } } return self::$permalink_setting; } /** * Get debug settings data. * * @return array. */ public static function get_google_analytics_settings() { if ( null === self::$google_analytics_settings ) { $google_analytics_settings_default = apply_filters( 'cartflows_google_analytics_settings_default', array( 'enable_google_analytics' => 'disable', 'enable_google_analytics_for_site' => 'disable', 'google_analytics_id' => '', 'enable_begin_checkout' => 'disable', 'enable_add_to_cart' => 'disable', 'enable_add_payment_info' => 'disable', 'enable_purchase_event' => 'disable', ) ); $google_analytics_settings_data = self::get_admin_settings_option( '_cartflows_google_analytics', false, true ); $google_analytics_settings_data = wp_parse_args( $google_analytics_settings_data, $google_analytics_settings_default ); if ( ! did_action( 'wp' ) ) { return $google_analytics_settings_data; } else { self::$google_analytics_settings = $google_analytics_settings_data; } } return self::$google_analytics_settings = $google_analytics_settings_data; //phpcs:ignore } /** * Get Checkout field. * * @param string $key Field key. * @param int $post_id Post id. * @return array. */ public static function get_checkout_fields( $key, $post_id ) { $saved_fields = get_post_meta( $post_id, 'wcf_fields_' . $key, true ); if ( ! $saved_fields ) { $saved_fields = array(); } $fields = array_filter( $saved_fields ); if ( empty( $fields ) ) { if ( 'billing' === $key || 'shipping' === $key ) { $fields = WC()->countries->get_address_fields( WC()->countries->get_base_country(), $key . '_' ); update_post_meta( $post_id, 'wcf_fields_' . $key, $fields ); } } return $fields; } /** * Add Checkout field. * * @param string $type Field type. * @param string $field_key Field key. * @param array $field_data Field data. * @param int $post_id Post id. * @return boolean. */ public static function add_checkout_field( $type, $field_key, $field_data = array(), $post_id ) { $fields = self::get_checkout_fields( $type, $post_id ); $fields[ $field_key ] = $field_data; update_post_meta( $post_id, 'wcf_fields_' . $type, $fields ); return true; } /** * Get checkout fields settings. * * @param string $type Field type. * @param string $field_key Field key. * @param int $post_id Post id. * @return array. */ public static function delete_checkout_field( $type, $field_key, $post_id ) { $fields = self::get_checkout_fields( $type, $post_id ); if ( isset( $fields[ $field_key ] ) ) { unset( $fields[ $field_key ] ); } update_post_meta( $post_id, 'wcf_fields_' . $type, $fields ); return true; } /** * Get checkout fields settings. * * @return array. */ public static function get_checkout_fields_settings() { if ( null === self::$checkout_fields ) { $checkout_fields_default = array( 'enable_customization' => 'disable', 'enable_billing_fields' => 'disable', ); $billing_fields = self::get_checkout_fields( 'billing' ); if ( is_array( $billing_fields ) && ! empty( $billing_fields ) ) { foreach ( $billing_fields as $key => $value ) { $checkout_fields_default[ $key ] = 'enable'; } } $checkout_fields = self::get_admin_settings_option( '_wcf_checkout_fields', false, false ); self::$checkout_fields = wp_parse_args( $checkout_fields, $checkout_fields_default ); } return self::$checkout_fields; } /** * Get meta options * * @since 1.0.0 * @param int $post_id Product ID. * @param string $key Meta Key. * @param string $default Default value. * @return string Meta Value. */ public static function get_meta_option( $post_id, $key, $default = '' ) { $value = get_post_meta( $post_id, $key, true ); if ( ! $value ) { $value = $default; } return $value; } /** * Save meta option * * @since 1.0.0 * @param int $post_id Product ID. * @param array $args Arguments array. */ public static function save_meta_option( $post_id, $args = array() ) { if ( is_array( $args ) && ! empty( $args ) ) { foreach ( $args as $key => $value ) { update_post_meta( $post_id, $key, $value ); } } } /** * Check if Elementor page builder is installed * * @since 1.0.0 * * @access public */ public static function is_elementor_installed() { $path = 'elementor/elementor.php'; $plugins = get_plugins(); return isset( $plugins[ $path ] ); } /** * Check if Step has product assigned. * * @since 1.0.0 * @param int $step_id step ID. * * @access public */ public static function has_product_assigned( $step_id ) { $step_type = get_post_meta( $step_id, 'wcf-step-type', true ); if ( 'checkout' == $step_type ) { $product = get_post_meta( $step_id, 'wcf-checkout-products', true ); } else { $product = get_post_meta( $step_id, 'wcf-offer-product', true ); } if ( ! empty( $product ) ) { return true; } return false; } /** * Get attributes for cartflows wrap. * * @since 1.1.4 * * @access public */ public static function get_cartflows_container_atts() { $attributes = apply_filters( 'cartflows_container_atts', array() ); $atts_string = ''; foreach ( $attributes as $key => $value ) { if ( ! $value ) { continue; } if ( true === $value ) { $atts_string .= esc_html( $key ) . ' '; } else { $atts_string .= sprintf( '%s="%s" ', esc_html( $key ), esc_attr( $value ) ); } } return $atts_string; } /** * Get facebook pixel settings. * * @return facebook array. */ public static function get_facebook_settings() { if ( null === self::$facebook ) { $facebook_default = array( 'facebook_pixel_id' => '', 'facebook_pixel_add_to_cart' => 'enable', 'facebook_pixel_initiate_checkout' => 'enable', 'facebook_pixel_add_payment_info' => 'enable', 'facebook_pixel_purchase_complete' => 'enable', 'facebook_pixel_tracking' => 'disable', 'facebook_pixel_tracking_for_site' => 'disable', ); $facebook = self::get_admin_settings_option( '_cartflows_facebook', false, false ); $facebook = wp_parse_args( $facebook, $facebook_default ); self::$facebook = apply_filters( 'cartflows_facebook_settings_default', $facebook ); } return self::$facebook; } /** * Prepare response data for facebook. * * @param int $order_id order_id. * @param array $offer_data offer data. */ public static function send_fb_response_if_enabled( $order_id, $offer_data = array() ) { // Stop Execution if WooCommerce is not installed & don't set the cookie. if ( ! Cartflows_Loader::get_instance()->is_woo_active ) { return; } $fb_settings = self::get_facebook_settings(); if ( 'enable' === $fb_settings['facebook_pixel_tracking'] ) { setcookie( 'wcf_order_details', wp_json_encode( self::prepare_purchase_data_fb_response( $order_id, $offer_data ) ), strtotime( '+1 year' ), '/' ); } } /** * Prepare purchase response for facebook purcase event. * * @param integer $order_id order id. * @param array $offer_data offer data. * @return mixed */ public static function prepare_purchase_data_fb_response( $order_id, $offer_data = array() ) { $thankyou = array(); if ( ! Cartflows_Loader::get_instance()->is_woo_active ) { return $thankyou; } $thankyou['order_id'] = $order_id; $thankyou['content_type'] = 'product'; $thankyou['currency'] = wcf()->options->get_checkout_meta_value( $order_id, '_order_currency' ); $thankyou['userAgent'] = wcf()->options->get_checkout_meta_value( $order_id, '_customer_user_agent' ); $thankyou['plugin'] = 'CartFlows'; $order = wc_get_order( $order_id ); if ( empty( $offer_data ) ) { // Iterating through each WC_Order_Item_Product objects. foreach ( $order->get_items() as $item_key => $item ) { $product = $item->get_product(); // Get the WC_Product object. $thankyou['content_ids'][] = (string) $product->get_id(); } $thankyou['value'] = wcf()->options->get_checkout_meta_value( $order_id, '_order_total' ); } else { $thankyou['content_ids'][] = (string) $offer_data['id']; $thankyou['value'] = $offer_data['total']; } return $thankyou; } /** * Prepare cart data for fb response. * * @return array */ public static function prepare_cart_data_fb_response() { $params = array(); if ( ! Cartflows_Loader::get_instance()->is_woo_active ) { return $params; } $cart_total = WC()->cart->get_cart_contents_total(); $cart_items_count = WC()->cart->get_cart_contents_count(); $items = WC()->cart->get_cart(); $product_names = ''; $category_names = ''; $cart_contents = array(); foreach ( $items as $item => $value ) { $_product = wc_get_product( $value['product_id'] ); $params['content_ids'][] = (string) $_product->get_id(); $product_names = $product_names . ', ' . $_product->get_title(); $category_names = $category_names . ', ' . wp_strip_all_tags( wc_get_product_category_list( $_product->get_id() ) ); array_push( $cart_contents, array( 'id' => $_product->get_id(), 'name' => $_product->get_title(), 'quantity' => $value['quantity'], 'item_price' => $_product->get_price(), ) ); } $user = wp_get_current_user(); $roles = implode( ', ', $user->roles ); $params['content_name'] = substr( $product_names, 2 ); $params['categoey_name'] = substr( $category_names, 2 ); $params['user_roles'] = $roles; $params['plugin'] = 'CartFlows'; $params['contents'] = wp_json_encode( $cart_contents ); $params['content_type'] = 'product'; $params['value'] = $cart_total; $params['num_items'] = $cart_items_count; $params['currency'] = get_woocommerce_currency(); $params['language'] = get_bloginfo( 'language' ); $params['userAgent'] = wp_unslash( $_SERVER['HTTP_USER_AGENT'] ); //phpcs:ignore $params['product_catalog_id'] = ''; $params['domain'] = get_site_url(); return $params; } /** * Get the image url of size. * * @param int $post_id post id. * @param array $key key. * @param string $size image size. * * @return array */ public static function get_image_url( $post_id, $key, $size = false ) { $url = get_post_meta( $post_id, $key, true ); $img_obj = get_post_meta( $post_id, $key . '-obj', true ); if ( is_array( $img_obj ) && ! empty( $img_obj ) && false !== $size ) { $url = ! empty( $img_obj['url'][ $size ] ) ? $img_obj['url'][ $size ] : $url; } return $url; } } class-cartflows-logger.php000066600000010122152133015060011635 0ustar00 CARTFLOWS_SETTINGS, 'cartflows-error-log' => 1, ), admin_url( '/admin.php' ) ); echo ' Thank you for using CartFlows | View Logs '; } /** * Inint Logger. * * @since 1.0.0 */ public function init_wc_logger() { if ( class_exists( 'CartFlows_WC_Logger' ) ) { $this->logger = new CartFlows_WC_Logger(); } } /** * Write log * * @param string $message log message. * @param string $level type of log. * @since 1.0.0 */ public function log( $message, $level = 'info' ) { $enable_log = apply_filters( 'cartflows_enable_log', 'enable' ); if ( 'enable' === $enable_log && is_a( $this->logger, 'CartFlows_WC_Logger' ) && did_action( 'plugins_loaded' ) ) { $this->logger->log( $level, $message, array( 'source' => 'cartflows' ) ); } } /** * Write log * * @param string $message log message. * @param string $level type of log. * @since 1.0.0 */ public function import_log( $message, $level = 'info' ) { if ( defined( 'WP_DEBUG' ) && WP_DEBUG && is_a( $this->logger, 'CartFlows_WC_Logger' ) && did_action( 'plugins_loaded' ) ) { $this->logger->log( $level, $message, array( 'source' => 'cartflows-import' ) ); } } /** * Get all log files in the log directory. * * @return array */ public static function get_log_files() { $files = scandir( CARTFLOWS_LOG_DIR ); $result = array(); if ( ! empty( $files ) ) { foreach ( $files as $key => $value ) { if ( ! in_array( $value, array( '.', '..' ), true ) ) { if ( ! is_dir( $value ) && strstr( $value, '.log' ) ) { $result[ sanitize_title( $value ) ] = $value; } } } } return $result; } /** * Return the log file handle. * * @param string $filename Filename to get the handle for. * @return string */ public static function get_log_file_handle( $filename ) { return substr( $filename, 0, strlen( $filename ) > 48 ? strlen( $filename ) - 48 : strlen( $filename ) - 4 ); } /** * Show the log page contents for file log handler. */ public static function status_logs_file() { if ( ! empty( $_REQUEST['handle'] ) ) { if ( empty( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ), 'remove_log' ) ) { wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'cartflows' ) ); } wp_delete_file( CARTFLOWS_LOG_DIR . rtrim( $_REQUEST['handle'], '-log' ) . '.log' ); //phpcs:ignore echo "
Log deleted successfully!
"; } $logs = self::get_log_files(); if ( ! empty( $_REQUEST['log_file'] ) && isset( $logs[ sanitize_title( wp_unslash( $_REQUEST['log_file'] ) ) ] ) ) { $viewed_log = $logs[ sanitize_title( wp_unslash( $_REQUEST['log_file'] ) ) ]; } elseif ( ! empty( $logs ) ) { $viewed_log = current( $logs ); } $handle = ! empty( $viewed_log ) ? self::get_log_file_handle( $viewed_log ) : ''; include_once CARTFLOWS_DIR . 'includes/admin/cartflows-error-log.php'; } } /** * Kicking this off by calling 'get_instance()' method */ Cartflows_Logger::get_instance(); logger/class-cartflows-logger-interface.php000066600000007412152133015060015062 0ustar00' . esc_html( is_object( $handler ) ? get_class( $handler ) : $handler ) . '', 'Cartflows_Log_Handler_Interface' ), '3.0' ); } } } if ( null !== $threshold ) { $threshold = Cartflows_Log_Levels::get_level_severity( $threshold ); } elseif ( defined( 'WC_LOG_THRESHOLD' ) && Cartflows_Log_Levels::is_valid_level( WC_LOG_THRESHOLD ) ) { $threshold = Cartflows_Log_Levels::get_level_severity( WC_LOG_THRESHOLD ); } else { $threshold = null; } $this->handlers = $register_handlers; $this->threshold = $threshold; } /** * Determine whether to handle or ignore log. * * @param string $level emergency|alert|critical|error|warning|notice|info|debug. * @return bool True if the log should be handled. */ protected function should_handle( $level ) { if ( null === $this->threshold ) { return true; } return $this->threshold <= Cartflows_Log_Levels::get_level_severity( $level ); } /** * Add a log entry. * * This is not the preferred method for adding log messages. Please use log() or any one of * the level methods (debug(), info(), etc.). This method may be deprecated in the future. * * @param string $handle File handle. * @param string $message Message to log. * @param string $level Logging level. * @return bool */ public function add( $handle, $message, $level = Cartflows_Log_Levels::NOTICE ) { $message = apply_filters( 'cartflows_logger_add_message', $message, $handle ); $this->log( $level, $message, array( 'source' => $handle, '_legacy' => true, ) ); wc_do_deprecated_action( 'cartflows_log_add', array( $handle, $message ), '3.0', 'This action has been deprecated with no alternative.' ); return true; } /** * Add a log entry. * * @param string $level One of the following: * 'emergency': System is unusable. * 'alert': Action must be taken immediately. * 'critical': Critical conditions. * 'error': Error conditions. * 'warning': Warning conditions. * 'notice': Normal but significant condition. * 'info': Informational messages. * 'debug': Debug-level messages. * @param string $message Log message. * @param array $context Optional. Additional information for log handlers. */ public function log( $level, $message, $context = array() ) { if ( ! Cartflows_Log_Levels::is_valid_level( $level ) ) { /* translators: 1: Cartflows_WC_Logger::log 2: level */ wc_doing_it_wrong( __METHOD__, sprintf( __( '%1$s was called with an invalid level "%2$s".', 'cartflows' ), 'Cartflows_WC_Logger::log', $level ), '3.0' ); } if ( $this->should_handle( $level ) ) { $timestamp = time(); $message = apply_filters( 'cartflows_logger_log_message', $message, $level, $context ); foreach ( $this->handlers as $handler ) { $handler->handle( $timestamp, $level, $message, $context ); } } } /** * Adds an emergency level message. * * System is unusable. * * @see Cartflows_WC_Logger::log * * @param string $message Message to log. * @param array $context Log context. */ public function emergency( $message, $context = array() ) { $this->log( Cartflows_Log_Levels::EMERGENCY, $message, $context ); } /** * Adds an alert level message. * * Action must be taken immediately. * Example: Entire website down, database unavailable, etc. * * @see Cartflows_WC_Logger::log * * @param string $message Message to log. * @param array $context Log context. */ public function alert( $message, $context = array() ) { $this->log( Cartflows_Log_Levels::ALERT, $message, $context ); } /** * Adds a critical level message. * * Critical conditions. * Example: Application component unavailable, unexpected exception. * * @see Cartflows_WC_Logger::log * * @param string $message Message to log. * @param array $context Log context. */ public function critical( $message, $context = array() ) { $this->log( Cartflows_Log_Levels::CRITICAL, $message, $context ); } /** * Adds an error level message. * * Runtime errors that do not require immediate action but should typically be logged * and monitored. * * @see Cartflows_WC_Logger::log * * @param string $message Message to log. * @param array $context Log context. */ public function error( $message, $context = array() ) { $this->log( Cartflows_Log_Levels::ERROR, $message, $context ); } /** * Adds a warning level message. * * Exceptional occurrences that are not errors. * * Example: Use of deprecated APIs, poor use of an API, undesirable things that are not * necessarily wrong. * * @see Cartflows_WC_Logger::log * * @param string $message Message to log. * @param array $context Log context. */ public function warning( $message, $context = array() ) { $this->log( Cartflows_Log_Levels::WARNING, $message, $context ); } /** * Adds a notice level message. * * Normal but significant events. * * @see Cartflows_WC_Logger::log * * @param string $message Message to log. * @param array $context Log context. */ public function notice( $message, $context = array() ) { $this->log( Cartflows_Log_Levels::NOTICE, $message, $context ); } /** * Adds a info level message. * * Interesting events. * Example: User logs in, SQL logs. * * @see Cartflows_WC_Logger::log * * @param string $message Message to log. * @param array $context Log context. */ public function info( $message, $context = array() ) { $this->log( Cartflows_Log_Levels::INFO, $message, $context ); } /** * Adds a debug level message. * * Detailed debug information. * * @see Cartflows_WC_Logger::log * * @param string $message Message to log. * @param array $context Log context. */ public function debug( $message, $context = array() ) { $this->log( Cartflows_Log_Levels::DEBUG, $message, $context ); } /** * Clear entries for a chosen file/source. * * @param string $source Source/handle to clear. * @return bool */ public function clear( $source = '' ) { if ( ! $source ) { return false; } foreach ( $this->handlers as $handler ) { if ( is_callable( array( $handler, 'clear' ) ) ) { $handler->clear( $source ); } } return true; } /** * Clear all logs older than a defined number of days. Defaults to 30 days. * * @since 3.4.0 */ public function clear_expired_logs() { $days = absint( apply_filters( 'cartflows_logger_days_to_retain_logs', 30 ) ); $timestamp = strtotime( "-{$days} days" ); foreach ( $this->handlers as $handler ) { if ( is_callable( array( $handler, 'delete_logs_before_timestamp' ) ) ) { $handler->delete_logs_before_timestamp( $timestamp ); } } } } logger/class-cartflows-log-handler-file.php000066600000026764152133015060014771 0ustar00log_size_limit = apply_filters( 'cartflows_log_file_size_limit', $log_size_limit ); add_action( 'plugins_loaded', array( $this, 'write_cached_logs' ) ); } /** * Destructor. * * Cleans up open file handles. */ public function __destruct() { foreach ( $this->handles as $handle ) { if ( is_resource( $handle ) ) { fclose( $handle ); // @codingStandardsIgnoreLine. } } } /** * Handle a log entry. * * @param int $timestamp Log timestamp. * @param string $level emergency|alert|critical|error|warning|notice|info|debug. * @param string $message Log message. * @param array $context { * Additional information for log handlers. * * @type string $source Optional. Determines log file to write to. Default 'log'. * @type bool $_legacy Optional. Default false. True to use outdated log format * originally used in deprecated Cartflows_WC_Logger::add calls. * } * * @return bool False if value was not handled and true if value was handled. */ public function handle( $timestamp, $level, $message, $context ) { if ( isset( $context['source'] ) && $context['source'] ) { $handle = $context['source']; } else { $handle = 'log'; } $entry = self::format_entry( $timestamp, $level, $message, $context ); return $this->add( $entry, $handle ); } /** * Builds a log entry text from timestamp, level and message. * * @param int $timestamp Log timestamp. * @param string $level emergency|alert|critical|error|warning|notice|info|debug. * @param string $message Log message. * @param array $context Additional information for log handlers. * * @return string Formatted log entry. */ protected static function format_entry( $timestamp, $level, $message, $context ) { if ( isset( $context['_legacy'] ) && true === $context['_legacy'] ) { if ( isset( $context['source'] ) && $context['source'] ) { $handle = $context['source']; } else { $handle = 'log'; } $message = apply_filters( 'cartflows_logger_add_message', $message, $handle ); $time = date_i18n( 'm-d-Y @ H:i:s' ); $entry = "{$time} - {$message}"; } else { $entry = parent::format_entry( $timestamp, $level, $message, $context ); } return $entry; } /** * Open log file for writing. * * @param string $handle Log handle. * @param string $mode Optional. File mode. Default 'a'. * @return bool Success. */ protected function open( $handle, $mode = 'a' ) { if ( $this->is_open( $handle ) ) { return true; } $file = self::get_log_file_path( $handle ); if ( $file ) { if ( ! file_exists( $file ) ) { $temphandle = @fopen( $file, 'w+' ); // @codingStandardsIgnoreLine. @fclose( $temphandle ); // @codingStandardsIgnoreLine. if ( defined( 'FS_CHMOD_FILE' ) ) { @chmod( $file, FS_CHMOD_FILE ); // @codingStandardsIgnoreLine. } } $resource = @fopen( $file, $mode ); // @codingStandardsIgnoreLine. if ( $resource ) { $this->handles[ $handle ] = $resource; return true; } } return false; } /** * Check if a handle is open. * * @param string $handle Log handle. * @return bool True if $handle is open. */ protected function is_open( $handle ) { return array_key_exists( $handle, $this->handles ) && is_resource( $this->handles[ $handle ] ); } /** * Close a handle. * * @param string $handle Log handle. * @return bool success */ protected function close( $handle ) { $result = false; if ( $this->is_open( $handle ) ) { $result = fclose( $this->handles[ $handle ] ); // @codingStandardsIgnoreLine. unset( $this->handles[ $handle ] ); } return $result; } /** * Add a log entry to chosen file. * * @param string $entry Log entry text. * @param string $handle Log entry handle. * * @return bool True if write was successful. */ protected function add( $entry, $handle ) { $result = false; if ( $this->should_rotate( $handle ) ) { $this->log_rotate( $handle ); } if ( $this->open( $handle ) && is_resource( $this->handles[ $handle ] ) ) { $result = fwrite( $this->handles[ $handle ], $entry . PHP_EOL ); // @codingStandardsIgnoreLine. } else { $this->cache_log( $entry, $handle ); } return false !== $result; } /** * Clear entries from chosen file. * * @param string $handle Log handle. * * @return bool */ public function clear( $handle ) { $result = false; // Close the file if it's already open. $this->close( $handle ); /** * $this->open( $handle, 'w' ) == Open the file for writing only. Place the file pointer at * the beginning of the file, and truncate the file to zero length. */ if ( $this->open( $handle, 'w' ) && is_resource( $this->handles[ $handle ] ) ) { $result = true; } do_action( 'cartflows_log_clear', $handle ); return $result; } /** * Remove/delete the chosen file. * * @param string $handle Log handle. * * @return bool */ public function remove( $handle ) { $removed = false; $logs = $this->get_log_files(); $handle = sanitize_title( $handle ); if ( isset( $logs[ $handle ] ) && $logs[ $handle ] ) { $file = realpath( trailingslashit( CARTFLOWS_LOG_DIR ) . $logs[ $handle ] ); if ( 0 === stripos( $file, realpath( trailingslashit( CARTFLOWS_LOG_DIR ) ) ) && is_file( $file ) && is_writable( $file ) ) { // phpcs:ignore WordPress.VIP.FileSystemWritesDisallow.file_ops_is_writable $this->close( $file ); // Close first to be certain no processes keep it alive after it is unlinked. $removed = unlink( $file ); // phpcs:ignore WordPress.VIP.FileSystemWritesDisallow.file_ops_unlink } do_action( 'cartflows_log_remove', $handle, $removed ); } return $removed; } /** * Check if log file should be rotated. * * Compares the size of the log file to determine whether it is over the size limit. * * @param string $handle Log handle. * @return bool True if if should be rotated. */ protected function should_rotate( $handle ) { $file = self::get_log_file_path( $handle ); if ( $file ) { if ( $this->is_open( $handle ) ) { $file_stat = fstat( $this->handles[ $handle ] ); return $file_stat['size'] > $this->log_size_limit; } elseif ( file_exists( $file ) ) { return filesize( $file ) > $this->log_size_limit; } else { return false; } } else { return false; } } /** * Rotate log files. * * Logs are rotated by prepending '.x' to the '.log' suffix. * The current log plus 10 historical logs are maintained. * For example: * base.9.log -> [ REMOVED ] * base.8.log -> base.9.log * ... * base.0.log -> base.1.log * base.log -> base.0.log * * @param string $handle Log handle. */ protected function log_rotate( $handle ) { for ( $i = 8; $i >= 0; $i-- ) { $this->increment_log_infix( $handle, $i ); } $this->increment_log_infix( $handle ); } /** * Increment a log file suffix. * * @param string $handle Log handle. * @param null|int $number Optional. Default null. Log suffix number to be incremented. * @return bool True if increment was successful, otherwise false. */ protected function increment_log_infix( $handle, $number = null ) { if ( null === $number ) { $suffix = ''; $next_suffix = '.0'; } else { $suffix = '.' . $number; $next_suffix = '.' . ( $number + 1 ); } $rename_from = self::get_log_file_path( "{$handle}{$suffix}" ); $rename_to = self::get_log_file_path( "{$handle}{$next_suffix}" ); if ( $this->is_open( $rename_from ) ) { $this->close( $rename_from ); } if ( is_writable( $rename_from ) ) { // phpcs:ignore WordPress.VIP.FileSystemWritesDisallow.file_ops_is_writable return rename( $rename_from, $rename_to ); // phpcs:ignore WordPress.VIP.FileSystemWritesDisallow.file_ops_rename } else { return false; } } /** * Get a log file path. * * @param string $handle Log name. * @return bool|string The log file path or false if path cannot be determined. */ public static function get_log_file_path( $handle ) { if ( function_exists( 'wp_hash' ) ) { return trailingslashit( CARTFLOWS_LOG_DIR ) . self::get_log_file_name( $handle ); } else { wc_doing_it_wrong( __METHOD__, __( 'This method should not be called before plugins_loaded.', 'cartflows' ), '3.0' ); return false; } } /** * Get a log file name. * * File names consist of the handle, followed by the date, followed by a hash, .log. * * @since 3.3 * @param string $handle Log name. * @return bool|string The log file name or false if cannot be determined. */ public static function get_log_file_name( $handle ) { if ( function_exists( 'wp_hash' ) ) { $date_suffix = gmdate( 'Y-m-d', time() ); $hash_suffix = wp_hash( $handle ); return sanitize_file_name( implode( '-', array( $handle, $date_suffix, $hash_suffix ) ) . '.log' ); } else { wc_doing_it_wrong( __METHOD__, __( 'This method should not be called before plugins_loaded.', 'cartflows' ), '3.3' ); return false; } } /** * Cache log to write later. * * @param string $entry Log entry text. * @param string $handle Log entry handle. */ protected function cache_log( $entry, $handle ) { $this->cached_logs[] = array( 'entry' => $entry, 'handle' => $handle, ); } /** * Write cached logs. */ public function write_cached_logs() { foreach ( $this->cached_logs as $log ) { $this->add( $log['entry'], $log['handle'] ); } } /** * Delete all logs older than a defined timestamp. * * @since 3.4.0 * @param integer $timestamp Timestamp to delete logs before. */ public static function delete_logs_before_timestamp( $timestamp = 0 ) { if ( ! $timestamp ) { return; } $log_files = self::get_log_files(); foreach ( $log_files as $log_file ) { $last_modified = filemtime( trailingslashit( CARTFLOWS_LOG_DIR ) . $log_file ); if ( $last_modified < $timestamp ) { @unlink( trailingslashit( CARTFLOWS_LOG_DIR ) . $log_file ); // @codingStandardsIgnoreLine. } } } /** * Get all log files in the log directory. * * @since 3.4.0 * @return array */ public static function get_log_files() { $files = @scandir( CARTFLOWS_LOG_DIR ); // @codingStandardsIgnoreLine. $result = array(); if ( ! empty( $files ) ) { foreach ( $files as $key => $value ) { if ( ! in_array( $value, array( '.', '..' ), true ) ) { if ( ! is_dir( $value ) && strstr( $value, '.log' ) ) { $result[ sanitize_title( $value ) ] = $value; } } } } return $result; } } logger/class-cartflows-log-handler.php000066600000002637152133015060014045 0ustar00 $timestamp, 'level' => $level, 'message' => $message, 'context' => $context, ) ); } } logger/class-cartflows-log-levels.php000066600000005057152133015060013721 0ustar00 800, self::ALERT => 700, self::CRITICAL => 600, self::ERROR => 500, self::WARNING => 400, self::NOTICE => 300, self::INFO => 200, self::DEBUG => 100, ); /** * Severity integers mapped to level strings. * * This is the inverse of $level_severity. * * @var array */ protected static $severity_to_level = array( 800 => self::EMERGENCY, 700 => self::ALERT, 600 => self::CRITICAL, 500 => self::ERROR, 400 => self::WARNING, 300 => self::NOTICE, 200 => self::INFO, 100 => self::DEBUG, ); /** * Validate a level string. * * @param string $level Log level. * @return bool True if $level is a valid level. */ public static function is_valid_level( $level ) { return array_key_exists( strtolower( $level ), self::$level_to_severity ); } /** * Translate level string to integer. * * @param string $level Log level, options: emergency|alert|critical|error|warning|notice|info|debug. * @return int 100 (debug) - 800 (emergency) or 0 if not recognized */ public static function get_level_severity( $level ) { return self::is_valid_level( $level ) ? self::$level_to_severity[ strtolower( $level ) ] : 0; } /** * Translate severity integer to level string. * * @param int $severity Serevity level. * @return bool|string False if not recognized. Otherwise string representation of level. */ public static function get_severity_level( $severity ) { if ( ! array_key_exists( $severity, self::$severity_to_level ) ) { return false; } return self::$severity_to_level[ $severity ]; } } class-cartflows-meta-fields.php000066600000057704152133015060012571 0ustar00utils->is_step_post_type( $screen->post_type ) ) { wp_enqueue_style( 'woocommerce_admin_styles' ); wp_enqueue_script( 'select2' ); wp_enqueue_script( 'wc-enhanced-select' ); wp_enqueue_script( 'wcf-admin-meta', CARTFLOWS_URL . 'admin/meta-assets/js/admin-edit.js', array( 'jquery', 'wp-color-picker' ), CARTFLOWS_VER, true ); wp_enqueue_style( 'wcf-admin-meta', CARTFLOWS_URL . 'admin/meta-assets/css/admin-edit.css', array( 'wp-color-picker' ), CARTFLOWS_VER ); wp_style_add_data( 'wcf-admin-meta', 'rtl', 'replace' ); $localize = array( 'ajax_url' => admin_url( 'admin-ajax.php' ), 'google_fonts' => CartFlows_Font_Families::get_google_fonts(), 'system_fonts' => CartFlows_Font_Families::get_system_fonts(), 'font_weights' => array( '100' => __( 'Thin 100', 'cartflows' ), '200' => __( 'Extra-Light 200', 'cartflows' ), '300' => __( 'Light 300', 'cartflows' ), '400' => __( 'Normal 400', 'cartflows' ), '500' => __( 'Medium 500', 'cartflows' ), '600' => __( 'Semi-Bold 600', 'cartflows' ), '700' => __( 'Bold 700', 'cartflows' ), '800' => __( 'Extra-Bold 800', 'cartflows' ), '900' => __( 'Ultra-Bold 900', 'cartflows' ), ) ); wp_localize_script( 'jquery', 'wcf', apply_filters( 'wcf_js_localize', $localize ) ); do_action( 'cartflows_admin_meta_scripts' ); } } /** * Function to search coupons */ public function json_search_coupons() { check_admin_referer( 'wcf-json-search-coupons', 'security' ); global $wpdb; $term = (string) urldecode( sanitize_text_field( wp_unslash( $_GET['term'] ) ) ); // phpcs:ignore if ( empty( $term ) ) { die(); } $posts = wp_cache_get( 'wcf_search_coupons', 'wcf_funnel_Cart' ); if ( false === $posts ) { $posts = $wpdb->get_results( // phpcs:ignore $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}posts WHERE post_type = %s AND post_title LIKE %s AND post_status = %s", 'shop_coupon', $wpdb->esc_like( $term ) . '%', 'publish' ) ); wp_cache_set( 'wcf_search_coupons', $posts, 'wcf_funnel_Cart' ); } $coupons_found = array(); $all_discount_types = wc_get_coupon_types(); if ( $posts ) { foreach ( $posts as $post ) { $discount_type = get_post_meta( $post->ID, 'discount_type', true ); if ( ! empty( $all_discount_types[ $discount_type ] ) ) { $coupons_found[ get_the_title( $post->ID ) ] = get_the_title( $post->ID ) . ' (Type: ' . $all_discount_types[ $discount_type ] . ')'; } } } wp_send_json( $coupons_found ); } /** * Function to search coupons */ public function json_search_pages() { check_ajax_referer( 'wcf-json-search-pages', 'security' ); $term = (string) urldecode( sanitize_text_field( wp_unslash( $_GET['term'] ) ) ); // phpcs:ignore if ( empty( $term ) ) { die( 'not found' ); } $search_string = $term; $data = array(); $result = array(); add_filter( 'posts_search', array( $this, 'search_only_titles' ), 10, 2 ); $query = new WP_Query( array( 's' => $search_string, 'post_type' => 'page', 'posts_per_page' => -1, ) ); if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); $title = get_the_title(); $title .= ( 0 != $query->post->post_parent ) ? ' (' . get_the_title( $query->post->post_parent ) . ')' : ''; $id = get_the_id(); $data[] = array( 'id' => $id, 'text' => $title, ); } } if ( is_array( $data ) && ! empty( $data ) ) { $result[] = array( 'text' => '', 'children' => $data, ); } wp_reset_postdata(); // return the result in json. wp_send_json( $result ); } public function search_only_titles( $search, $wp_query ) { if ( ! empty( $search ) && ! empty( $wp_query->query_vars['search_terms'] ) ) { global $wpdb; $q = $wp_query->query_vars; $n = ! empty( $q['exact'] ) ? '' : '%'; $search = array(); foreach ( (array) $q['search_terms'] as $term ) { $search[] = $wpdb->prepare( "$wpdb->posts.post_title LIKE %s", $n . $wpdb->esc_like( $term ) . $n ); } if ( ! is_user_logged_in() ) { $search[] = "$wpdb->posts.post_password = ''"; } $search = ' AND ' . implode( ' AND ', $search ); } return $search; } function get_field( $field_data, $field_content ) { $label = isset( $field_data['label'] ) ? $field_data['label'] : ''; $help = isset( $field_data['help'] ) ? $field_data['help'] : ''; $after_html = isset( $field_data['after_html'] ) ? $field_data['after_html'] : ''; $name_class = 'field-' . $field_data['name']; $field_html = '
'; if( ! empty( $label ) || ! empty( $help ) ) { $field_html .= '
'; if( ! empty( $label ) ) { $field_html .= ''; } if ( ! empty( $help ) ) { $field_html .= ''; // $field_html .= ''; $field_html .= ''; $field_html .= ''; $field_html .= $help; $field_html .= ''; } $field_html .= '
'; } $field_html .= '
'; $field_html .= $field_content; if ( ! empty( $after_html ) ) { $field_html .= $after_html; } $field_html .= '
'; $field_html .= '
'; return $field_html; } function get_text_field( $field_data ) { $value = $field_data['value']; $attr = ''; if ( isset( $field_data['attr'] ) && is_array( $field_data['attr'] ) ) { foreach ( $field_data['attr'] as $attr_key => $attr_value ) { $attr .= ' ' . $attr_key . '="' . $attr_value . '"'; } } $field_content = ''; return $this->get_field( $field_data, $field_content ); } function get_shortcode_field( $field_data ) { $attr = ''; $attr_fields = array( 'readonly' => 'readonly', 'onfocus' => 'this.select()', 'onmouseup' => 'return false', ); if ( $attr_fields && is_array( $attr_fields ) ) { foreach ( $attr_fields as $attr_key => $attr_value ) { $attr .= ' ' . $attr_key . '="' . $attr_value . '"'; } } $field_content = ''; return $this->get_field( $field_data, $field_content ); } function get_display_field( $field_data ) { $field_content = $field_data['content']; return $this->get_field( $field_data, $field_content ); } function get_hr_line_field( $field_data ) { $field_data = array( 'name' => 'wcf-hr-line', 'content' => '
' ); $field_content = $field_data['content']; return $this->get_field( $field_data, $field_content ); } function get_number_field( $field_data ) { $value = $field_data['value']; $attr = ''; if ( isset( $field_data['attr'] ) && is_array( $field_data['attr'] ) ) { foreach ( $field_data['attr'] as $attr_key => $attr_value ) { $attr .= ' ' . $attr_key . '="' . $attr_value . '"'; } } $field_content = ''; return $this->get_field( $field_data, $field_content ); } function get_hidden_field( $field_data ) { $value = $field_data['value']; $attr = ''; if ( isset( $field_data['attr'] ) && is_array( $field_data['attr'] ) ) { foreach ( $field_data['attr'] as $attr_key => $attr_value ) { $attr .= ' ' . $attr_key . '="' . $attr_value . '"'; } } $field_content = ''; return $this->get_field( $field_data, $field_content ); } function get_area_field( $field_data ) { $value = $field_data['value']; $attr = ''; if ( isset( $field_data['attr'] ) && is_array( $field_data['attr'] ) ) { foreach ( $field_data['attr'] as $attr_key => $attr_value ) { $attr .= ' ' . $attr_key . '="' . $attr_value . '"'; } } $field_content = ''; return $this->get_field( $field_data, $field_content ); } function get_only_checkbox_field( $field_data ) { $value = $field_data['value']; $field_content = ''; if ( isset( $field_data['before'] ) ) { $field_content .= '' . $field_data['before'] . ''; } $field_content .= ''; $field_content .= ''; if ( isset( $field_data['after'] ) ) { $field_content .= '' . $field_data['after'] . ''; } if ( isset( $field_data['after_html'] ) ) { $field_content .= '' . $field_data['after_html'] . ''; } return $field_content; } function get_checkbox_field( $field_data ) { $value = $field_data['value']; $field_content = ''; if ( isset( $field_data['before'] ) ) { $field_content .= '' . $field_data['before'] . ''; } $toggle_data = ''; if ( isset( $field_data['toggle'] ) ) { $toggle_data .= 'toggle="' . htmlspecialchars( wp_json_encode( $field_data['toggle'] ) ) . '"'; } $field_content .= ''; $field_content .= ''; if ( isset( $field_data['after'] ) ) { $field_content .= '' . $field_data['after'] . ''; } return $this->get_field( $field_data, $field_content ); } function get_radio_field( $field_data ) { $value = $field_data['value']; $field_content = ''; if ( is_array( $field_data['options'] ) && ! empty( $field_data['options'] ) ) { foreach ( $field_data['options'] as $data_key => $data_value ) { $field_content .= '
'; $field_content .= ''; $field_content .= $data_value; $field_content .= '
'; } } return $this->get_field( $field_data, $field_content ); } function get_font_family_field( $field_data ) { $value = $field_data['value']; $pro_options = isset( $field_data['pro-options'] ) ? $field_data['pro-options'] : array(); $field_content = ''; return $this->get_field( $field_data, $field_content ); } function get_font_weight_field( $field_data ) { $value = $field_data['value']; $pro_options = isset( $field_data['pro-options'] ) ? $field_data['pro-options'] : array(); $field_content = ''; return $this->get_field( $field_data, $field_content ); } function get_select_field( $field_data ) { $value = $field_data['value']; $pro_options = isset( $field_data['pro-options'] ) ? $field_data['pro-options'] : array(); $field_content = ''; if ( isset( $field_data['after'] ) ) { $field_content .= '' . $field_data['after'] . ''; } return $this->get_field( $field_data, $field_content ); } function get_color_picker_field( $field_data ) { $value = $field_data['value']; $field_content = ''; return $this->get_field( $field_data, $field_content ); } function get_product_selection_field( $field_data ) { $value = $field_data['value']; $multiple = ''; if ( isset( $field_data['multiple'] ) && $field_data['multiple'] ) { $multiple = ' multiple="multiple"'; } $allow_clear = ''; if ( isset( $field_data['allow_clear'] ) && $field_data['allow_clear'] ) { $allow_clear = ' data-allow_clear="allow_clear"'; } $field_content = ''; return $this->get_field( $field_data, $field_content ); } function get_coupon_selection_field( $field_data ) { $value = $field_data['value']; $multiple = ''; if ( isset( $field_data['multiple'] ) && $field_data['multiple'] ) { $multiple = ' multiple="multiple"'; } $allow_clear = ''; if ( isset( $field_data['allow_clear'] ) && $field_data['allow_clear'] ) { $allow_clear = ' data-allow_clear="allow_clear"'; } $field_content = ''; return $this->get_field( $field_data, $field_content ); } function get_page_selection_field( $field_data ) { $value = $field_data['value']; $multiple = ''; if ( isset( $field_data['multiple'] ) && $field_data['multiple'] ) { $multiple = 'multiple="multiple"'; } $field_content = ''; return $this->get_field( $field_data, $field_content ); } function get_section( $field_data ) { $field_html = '
'; $field_html .= '
'; $field_html .= ''; if ( isset( $field_data['help'] ) ) { $field_html .= ''; } $field_html .= '
'; $field_html .= '
'; return $field_html; } function get_description_field( $field_data ) { $field_html = '
'; $field_html .= '
'; $field_html .= $field_data['content']; $field_html .= '
'; $field_html .= '
'; return $field_html; } function get_product_selection_repeater( $field_data ) { $value = $field_data['value']; if ( ! is_array( $value ) ) { $value[0] = array( 'product' => '', ); } else { if ( ! isset( $value[0] ) ) { $value[0] = array( 'product' => '', ); } } $name_class = 'field-' . $field_data['name']; $field_html = ''; $field_html .= ''; $field_html .= '
'; $field_html .= '
'; $field_html .= '
'; if ( is_array( $value ) ) { foreach ( $value as $p_key => $p_data ) { $selected_options = ''; if ( isset( $p_data['product'] ) ) { $product = wc_get_product( $p_data['product'] ); // posts. if ( ! empty( $product ) ) { $post_title = $product->get_name() . ' (#' . $p_data['product'] . ')'; $selected_options = ''; } } $field_html .= $this->generate_product_repeater_html( $p_key, $selected_options ); } } $field_html .= '
'; $field_html .= '
'; $field_html .= ''; $field_html .= ''. __( 'Create Product', 'cartflows' ) . ''; $field_html .= '
'; $field_html .= '
'; $field_html .= '
'; $field_html .= '
'; $field_html .= '
'; return $field_html; } function generate_product_repeater_html( $id, $options = '' ) { $field_html = '
'; $field_html .= '
'; /* Product Name */ $field_html .= '
'; $field_html .= ''; $field_html .= ''; $field_html .= ''; $field_html .= ''; $field_html .= ''; $field_html .= ''; $field_html .= ''. __( 'Remove', 'cartflows' ).''; $field_html .= ''; $field_html .= ''; $field_html .= '
'; $field_html .= '
'; $field_html .= '
'; return $field_html; } function get_image_field( $field_data ) { global $post; $value = $field_data['value']; $attr = ''; if ( isset( $field_data['attr'] ) && is_array( $field_data['attr'] ) ) { foreach ( $field_data['attr'] as $attr_key => $attr_value ) { $attr .= ' ' . $attr_key . '="' . $attr_value . '"'; } } $display_preview_box = ( isset( $value ) && '' != $value ) ? 'display:block;' : 'display:none'; $field_content = '
'; if( isset( $value ) ){ $field_content .= ''; } $field_content .= '
'; $image_data = htmlentities( serialize( get_post_meta( $post->ID, $field_data['name'].'-obj') ) ); $field_content .= ''; $field_content .= ''; $field_content .= ''; $display_remove_button = ( isset( $value ) && '' != $value ) ? 'display:inline-block; margin-left: 5px;' : 'display:none'; $field_content .= ''; return $this->get_field( $field_data, $field_content ); } /** * Localize variables in admin * * @param array $vars variables. */ function localize_vars( $vars ) { $ajax_actions = array( 'wcf_json_search_pages', 'wcf_json_search_coupons' ); foreach ( $ajax_actions as $action ) { $vars[ $action . '_nonce' ] = wp_create_nonce( str_replace( '_', '-', $action ) ); } /* Add product from iframe */ $product_src = esc_url_raw( add_query_arg( array( 'post_type' => 'product', 'wcf-woo-iframe' => 'true', ), admin_url( 'post-new.php' ) ) ); $vars['create_product_src'] = $product_src; /* Add product from iframe End */ return $vars; } } // @codingStandardsIgnoreEnd class-cartflows-divi-compatibility.php000066600000001722152133015060014166 0ustar00 How to use? * * $image = array( * 'url' => '', * 'id' => '', * ); * * $downloaded_image = CartFlows_Importer_Core::get_instance()->import( $image ); * * @package CartFlows * @since 1.0.0 */ if ( ! class_exists( 'CartFlows_Importer_Core' ) ) : /** * CartFlows Importer * * @since 1.0.0 */ class CartFlows_Importer_Core { /** * Instance * * @since 1.0.0 * @var object Class object. * @access private */ private static $instance; /** * Images IDs * * @var array The Array of already image IDs. * @since 1.0.0 */ private $already_imported_ids = array(); /** * Initiator * * @since 1.0.0 * @return object initialized object of class. */ public static function get_instance() { if ( ! isset( self::$instance ) ) { self::$instance = new self(); } return self::$instance; } /** * Constructor * * @since 1.0.0 */ public function __construct() { if ( ! function_exists( 'WP_Filesystem' ) ) { require_once ABSPATH . 'wp-admin/includes/file.php'; } WP_Filesystem(); } /** * Process Image Download * * @since 1.0.0 * @param array $attachments Attachment array. * @return array Attachment array. */ public function process( $attachments ) { $downloaded_images = array(); foreach ( $attachments as $key => $attachment ) { $downloaded_images[] = $this->import( $attachment ); } return $downloaded_images; } /** * Get Hash Image. * * @since 1.0.0 * @param string $attachment_url Attachment URL. * @return string Hash string. */ private function get_hash_image( $attachment_url ) { return sha1( $attachment_url ); } /** * Get Saved Image. * * @since 1.0.0 * @param string $attachment Attachment Data. * @return string Hash string. */ private function get_saved_image( $attachment ) { wcf()->logger->import_log( 'importer-core.php File' ); if ( apply_filters( 'cartflows_image_importer_skip_image', false, $attachment ) ) { self::log( 'Download (✕) Replace (✕) - ' . $attachment['url'] ); return $attachment; } global $wpdb; // Already imported? Then return! if ( isset( $this->already_imported_ids[ $attachment['id'] ] ) ) { self::log( 'Download (✓) Replace (✓) - ' . $attachment['url'] ); return $this->already_imported_ids[ $attachment['id'] ]; } // 1. Is already imported in Batch Import Process? $post_id = $wpdb->get_var( $wpdb->prepare( 'SELECT `post_id` FROM `' . $wpdb->postmeta . '` WHERE `meta_key` = \'_cartflows_image_hash\' AND `meta_value` = %s ;', $this->get_hash_image( $attachment['url'] ) ) ); // db call ok; no-cache ok. // 2. Is image already imported though XML? if ( empty( $post_id ) ) { // Get file name without extension. // To check it exist in attachment. $filename = preg_replace( '/\\.[^.\\s]{3,4}$/', '', basename( $attachment['url'] ) ); $post_id = $wpdb->get_var( $wpdb->prepare( 'SELECT `post_id` FROM `' . $wpdb->postmeta . '` WHERE `meta_key` = \'_wp_attached_file\' AND `meta_value` LIKE %s ;', '%' . $filename . '%' ) ); // db call ok; no-cache ok. self::log( 'Download (✕) Replace (✕) - ' . $attachment['url'] ); } if ( $post_id ) { $new_imgage_url = wp_get_attachment_url( $post_id ); $new_attachment = array( 'id' => $post_id, 'url' => $new_imgage_url, ); $this->already_imported_ids[ $attachment['id'] ] = $new_attachment; self::log( 'Download (✓) Replace (✓) - ' . $new_imgage_url ); return $new_attachment; } return false; } /** * Import Image * * @since 1.0.0 * @param array $attachment Attachment array. * @return array Attachment array. */ public function import( $attachment ) { $saved_image = $this->get_saved_image( $attachment ); if ( $saved_image ) { return $saved_image; } $args = array( 'timeout' => 300, ); $file_content = wp_remote_retrieve_body( wp_safe_remote_get( $attachment['url'], $args ) ); // Empty file content? if ( empty( $file_content ) ) { self::log( 'Download (✕) Replace (✕) - ' . $attachment['url'] ); self::log( 'Error: Failed wp_remote_retrieve_body().' ); return $attachment; } // Extract the file name and extension from the URL. $filename = basename( $attachment['url'] ); $upload = wp_upload_bits( $filename, null, $file_content ); $post = array( 'post_title' => $filename, 'guid' => $upload['url'], ); $info = wp_check_filetype( $upload['file'] ); if ( $info ) { $post['post_mime_type'] = $info['type']; } else { // For now just return the origin attachment. return $attachment; } $post_id = wp_insert_attachment( $post, $upload['file'] ); wp_update_attachment_metadata( $post_id, wp_generate_attachment_metadata( $post_id, $upload['file'] ) ); update_post_meta( $post_id, '_cartflows_image_hash', $this->get_hash_image( $attachment['url'] ) ); $new_attachment = array( 'id' => $post_id, 'url' => $upload['url'], ); self::log( 'Download (✓) Replace (✓) - ' . $attachment['url'] ); $this->already_imported_ids[ $attachment['id'] ] = $new_attachment; return $new_attachment; } /** * Debugging Log. * * @since 1.0.0 * @param mixed $log Log data. * @return void */ public static function log( $log ) { if ( ! WP_DEBUG_LOG ) { return; } if ( is_array( $log ) || is_object( $log ) ) { wcf()->logger->import_log( print_r( $log, true ) );//phpcs:ignore } else { wcf()->logger->import_log( $log ); } } } /** * Initialize class object with 'get_instance()' method */ CartFlows_Importer_Core::get_instance(); endif; class-cartflows-meta.php000066600000003370152133015060011313 0ustar00
meta->get_area_field( array( 'label' => __( 'Custom Script', 'cartflows' ), 'name' => 'wcf-custom-script', 'value' => htmlspecialchars( $options['wcf-custom-script'], ENT_COMPAT, 'utf-8' ), 'help' => esc_html__( 'Custom script lets you add your own custom script on front end of this flow page.', 'cartflows' ), ) ); ?>
utils->is_step_post_type() ) { // @codingStandardsIgnoreStart $flow_id = wcf()->utils->get_flow_id(); ?> is_flow_testmode( $flow_id ) ) { ?>
utils->get_flow_id(); } $test_mode = wcf()->options->get_flow_meta_value( $flow_id, 'wcf-testing' ); if ( 'no' === $test_mode ) { return false; } return true; } /** * Get steps data. * * @since 1.0.0 * @param int $flow_id flow ID. * * @return array */ public function get_steps( $flow_id ) { $steps = get_post_meta( $flow_id, 'wcf-steps', true ); if ( ! is_array( $steps ) ) { $steps = array(); } return $steps; } /** * Check thank you page exists. * * @since 1.0.0 * @param array $order order data. * * @return bool */ public function is_thankyou_page_exists( $order ) { $thankyou_step_exist = false; $flow_id = wcf()->utils->get_flow_id_from_order( $order->get_id() ); if ( $flow_id ) { $flow_steps = get_post_meta( $flow_id, 'wcf-steps', true ); $step_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() ); if ( is_array( $flow_steps ) ) { $current_step_found = false; foreach ( $flow_steps as $index => $data ) { if ( $current_step_found ) { if ( 'thankyou' === $data['type'] ) { $thankyou_step_exist = true; break; } } else { if ( intval( $data['id'] ) === $step_id ) { $current_step_found = true; } } } } } return $thankyou_step_exist; } /** * Check thank you page exists. * * @since 1.0.0 * @param array $order order data. * * @return bool */ public function get_thankyou_page_id( $order ) { $thankyou_step_id = false; $flow_id = wcf()->utils->get_flow_id_from_order( $order->get_id() ); if ( $flow_id ) { $flow_steps = get_post_meta( $flow_id, 'wcf-steps', true ); $step_id = wcf()->utils->get_checkout_id_from_order( $order->get_id() ); if ( is_array( $flow_steps ) ) { $current_step_found = false; foreach ( $flow_steps as $index => $data ) { if ( $current_step_found ) { if ( 'thankyou' === $data['type'] ) { $thankyou_step_id = intval( $data['id'] ); break; } } else { if ( intval( $data['id'] ) === $step_id ) { $current_step_found = true; } } } } } return $thankyou_step_id; } /** * Check thank you page exists. * * @since 1.0.0 * @param array $order order data. * * @return bool */ public function get_next_step_id( $order ) { $next_step_id = false; $flow_id = wcf()->utils->get_flow_id_from_order( $order->get_id() ); if ( $flow_id ) { $flow_steps = get_post_meta( $flow_id, 'wcf-steps', true ); $step_id = wcf()->utils->get_optin_id_from_order( $order->get_id() ); if ( is_array( $flow_steps ) ) { foreach ( $flow_steps as $index => $data ) { if ( intval( $data['id'] ) === $step_id ) { $next_step_index = $index + 1; if ( isset( $flow_steps[ $next_step_index ] ) ) { $next_step_id = intval( $flow_steps[ $next_step_index ]['id'] ); } break; } } } } return $next_step_id; } } /** * Kicking this off by calling 'get_instance()' method */ Cartflows_Flow_Frontend::get_instance(); class-cartflows-thrive-compatibility.php000066600000003115152133015060014532 0ustar00utils->is_step_post_type() ) { $bool = true; } return $bool; } } /** * Kicking this off by calling 'get_instance()' method */ Cartflows_Thrive_Compatibility::get_instance(); class-cartflows-bb-compatibility.php000066600000002565152133015060013624 0ustar00is_woo_active ) { // On Editor - Register WooCommerce frontend hooks before the Editor init. // Priority = 5, in order to allow plugins remove/add their wc hooks on init. if ( ! empty( $_REQUEST['action'] ) && 'elementor' === $_REQUEST['action'] && is_admin() ) { //phpcs:ignore add_action( 'init', array( $this, 'register_wc_hooks' ), 5 ); } add_action( 'elementor/editor/before_enqueue_scripts', array( $this, 'maybe_init_cart' ) ); } } /** * Get page template fiter callback for elementor preview mode * * @param string $template page template. * @return string */ public function get_page_template( $template ) { if ( is_singular() ) { $document = Plugin::$instance->documents->get_doc_for_frontend( get_the_ID() ); if ( $document ) { $template = $document->get_meta( '_wp_page_template' ); } } return $template; } /** * Rgister wc hookes for elementor preview mode */ public function register_wc_hooks() { wc()->frontend_includes(); } /** * Init cart in elementor preview mode */ public function maybe_init_cart() { $has_cart = is_a( WC()->cart, 'WC_Cart' ); if ( ! $has_cart ) { $session_class = apply_filters( 'woocommerce_session_handler', 'WC_Session_Handler' ); WC()->session = new $session_class(); WC()->session->init(); WC()->cart = new \WC_Cart(); WC()->customer = new \WC_Customer( get_current_user_id(), true ); } } } /** * Kicking this off by calling 'get_instance()' method */ Cartflows_Elementor_Compatibility::get_instance(); class-cartflows-api.php000066600000023634152133015060011143 0ustar00 self::get_licence_args(), '_fields' => 'id,slug,status,type,link,title,featured_media,template,cartflows_step_page_builder,cartflows_step_type,cartflows_step_flow,featured_image_url,licence_status,flow_type,step_type,page_builder,divi_content,post_meta', ); // @codingStandardsIgnoreEnd $url = add_query_arg( $request_params, self::get_step_endpoint_url() . $site_id ); $api_args = array( 'timeout' => 15, ); $response = self::remote_get( $url, $api_args ); if ( $response['success'] ) { $template = $response['data']; return array( 'title' => ( isset( $template['title']->rendered ) ) ? $template['title']->rendered : '', 'post_meta' => ( isset( $template['post_meta'] ) ) ? $template['post_meta'] : '', 'data' => $template, 'divi_content' => isset( $response['data']['divi_content'] ) ? $response['data']['divi_content'] : '', 'message' => $response['message'], // Your API Key is not valid. Please add valid API Key. 'success' => $response['success'], ); } return array( 'title' => '', 'post_meta' => array(), 'message' => $response['message'], 'data' => $response['data'], 'divi_content' => '', 'success' => $response['success'], ); } /** * Get Cloud Templates * * @since 1.0.0 * * @param array $args For selecting the demos (Search terms, pagination etc). * @return array CartFlows list. */ public static function get_templates( $args = array() ) { $request_params = wp_parse_args( $args, array( 'page' => '1', 'per_page' => '100', ) ); $url = add_query_arg( $request_params, self::get_step_endpoint_url() ); $api_args = array( 'timeout' => 15, ); $response = self::remote_get( $url, $api_args ); if ( $response['success'] ) { $templates_data = $response['data']; $templates = array(); foreach ( $templates_data as $key => $template ) { if ( ! isset( $template->id ) ) { continue; } $templates[ $key ]['id'] = isset( $template->id ) ? esc_attr( $template->id ) : ''; $templates[ $key ]['slug'] = isset( $template->slug ) ? esc_attr( $template->slug ) : ''; $templates[ $key ]['link'] = isset( $template->link ) ? esc_url( $template->link ) : ''; $templates[ $key ]['date'] = isset( $template->date ) ? esc_attr( $template->date ) : ''; $templates[ $key ]['title'] = isset( $template->title->rendered ) ? esc_attr( $template->title->rendered ) : ''; $templates[ $key ]['featured_image_url'] = isset( $template->featured_image_url ) ? esc_url( $template->featured_image_url ) : ''; $templates[ $key ]['content'] = isset( $template->content->rendered ) ? $template->content->rendered : ''; $templates[ $key ]['divi_content'] = isset( $template->divi_content ) ? $template->divi_content : ''; $templates[ $key ]['post_meta'] = isset( $template->post_meta ) ? $template->post_meta : ''; } return array( 'templates' => $templates, 'templates_count' => $response['count'], 'data' => $response, ); } return array( 'templates' => array(), 'templates_count' => 0, 'data' => $response, ); } /** * Get categories. * * @since 1.0.0 * @param array $args Arguments. * @return array Category data. */ public static function get_categories( $args = array() ) { $request_params = apply_filters( 'cartflows_categories_api_params', wp_parse_args( $args, array( 'page' => '1', 'per_page' => '100', ) ) ); $url = add_query_arg( $request_params, self::get_category_endpoint_url() ); $api_args = apply_filters( 'cartflows_api_args', array( 'timeout' => 15, ) ); $response = self::remote_get( $url, $api_args ); if ( $response['success'] ) { $categories_data = $response['data']; $categories = array(); foreach ( $categories_data as $key => $category ) { if ( isset( $category->count ) && ! empty( $category->count ) ) { $categories[] = array( 'id' => isset( $category->id ) ? absint( $category->id ) : 0, 'count' => isset( $category->count ) ? absint( $category->count ) : 0, 'description' => isset( $category->description ) ? $category->description : '', 'link' => isset( $category->link ) ? esc_url( $category->link ) : '', 'name' => isset( $category->name ) ? $category->name : '', 'slug' => isset( $category->slug ) ? sanitize_text_field( $category->slug ) : '', 'taxonomy' => isset( $category->taxonomy ) ? $category->taxonomy : '', 'parent' => isset( $category->parent ) ? $category->parent : '', ); } } return array( 'categories' => $categories, 'categories_count' => $response['count'], 'data' => $response, ); } return array( 'categories' => array(), 'categories_count' => 0, 'data' => $response, ); } /** * Remote GET API Request * * @since 1.0.0 * * @param string $url Target server API URL. * @param array $args Array of arguments for the API request. * @return mixed Return the API request result. */ public static function remote_get( $url = '', $args = array() ) { $request = wp_remote_get( $url, $args ); return self::request( $request ); } /** * Remote POST API Request * * @since 1.0.0 * * @param string $url Target server API URL. * @param array $args Array of arguments for the API request. * @return mixed Return the API request result. */ public static function remote_post( $url = '', $args = array() ) { $request = wp_remote_post( $url, $args ); return self::request( $request ); } /** * Site API Request * * @since 1.0.0 * * @param boolean $api_base Target server API URL. * @param array $args Array of arguments for the API request. * @return mixed Return the API request result. */ public static function site_request( $api_base = '', $args = array() ) { $api_url = self::get_request_api_url( $api_base ); return self::remote_post( $api_url, $args ); } /** * API Request * * Handle the API request and return the result. * * @since 1.0.0 * * @param array $request Array of arguments for the API request. * @return mixed Return the API request result. */ public static function request( $request ) { // Is WP Error? if ( is_wp_error( $request ) ) { return array( 'success' => false, 'message' => $request->get_error_message(), 'data' => $request, 'count' => 0, ); } // Invalid response code. if ( wp_remote_retrieve_response_code( $request ) != 200 ) { return array( 'success' => false, 'message' => $request['response'], 'data' => $request, 'count' => 0, ); } // Get body data. $body = wp_remote_retrieve_body( $request ); // Is WP Error? if ( is_wp_error( $body ) ) { return array( 'success' => false, 'message' => $body->get_error_message(), 'data' => $request, 'count' => 0, ); } // Decode body content. $body_decoded = json_decode( $body ); return array( 'success' => true, 'message' => __( 'Request successfully processed!', 'cartflows' ), 'data' => (array) $body_decoded, 'count' => wp_remote_retrieve_header( $request, 'x-wp-total' ), ); } } /** * Initialize class object with 'get_instance()' method */ CartFlows_API::get_instance(); endif; deprecated/deprecated-hooks.php000066600000001750152133015060012601 0ustar00= 4.6 */ do_action_deprecated( $tag, $args, $version, $replacement, $message ); } else { do_action_ref_array( $tag, $args ); } } } class-cartflows-metabox.php000066600000003641152133015060012025 0ustar00utils->get_flow_id_from_order( $post->ID ); $checkout_id = wcf()->utils->get_checkout_id_from_order( $post->ID ); $html_data = "

This is for debugging only.

Flow ID:: " . $flow_id . "

Checkout ID: " . $checkout_id . '

'; echo $html_data; } } /** * Kicking this off by calling 'get_instance()' method */ Cartflows_Metabox::get_instance(); endif; class-cartflows-functions.php000066600000017140152133015060012375 0ustar00ID ) ) { return $post->ID; } return 0; } /** * Returns step id. * * @since 1.0.0 */ function _get_wcf_step_id() { if ( wcf()->utils->is_step_post_type() ) { global $post; return $post->ID; } return false; } /** * Check if it is a landing page? * * @since 1.0.0 */ function _is_wcf_landing_type() { if ( wcf()->utils->is_step_post_type() ) { global $post; if ( 'landing' === get_post_meta( $post->ID, 'wcf-step-type', true ) ) { return true; } } return false; } /** * Returns landing id. * * @since 1.0.0 */ function _get_wcf_landing_id() { if ( _is_wcf_landing_type() ) { global $post; return $post->ID; } return false; } /** * Is custom checkout? * * @param int $checkout_id checkout ID. * @since 1.0.0 */ function _is_wcf_meta_custom_checkout( $checkout_id ) { $is_custom = wcf()->options->get_checkout_meta_value( $checkout_id, 'wcf-custom-checkout-fields' ); if ( 'yes' === $is_custom ) { return true; } return false; } /** * Check if page is cartflow checkout. * * @since 1.0.0 * @return bool */ function _is_wcf_checkout_type() { if ( wcf()->utils->is_step_post_type() ) { global $post; if ( 'checkout' === get_post_meta( $post->ID, 'wcf-step-type', true ) ) { return true; } } return false; } /** * Check if AJAX call is in progress. * * @since 1.0.0 * @return bool */ function _is_wcf_doing_checkout_ajax() { if ( wp_doing_ajax() || isset( $_GET['wc-ajax'] ) ) { //phpcs:ignore if ( isset( $_GET['wc-ajax'] ) && //phpcs:ignore 'checkout' === $_GET['wc-ajax'] && //phpcs:ignore isset( $_POST['_wcf_checkout_id'] ) //phpcs:ignore ) { return true; } } return false; } /** * Check if optin AJAX call is in progress. * * @since 1.0.0 * @return bool */ function _is_wcf_doing_optin_ajax() { if ( wp_doing_ajax() || isset( $_GET['wc-ajax'] ) ) { //phpcs:ignore if ( isset( $_GET['wc-ajax'] ) && //phpcs:ignore 'checkout' === $_GET['wc-ajax'] && //phpcs:ignore isset( $_POST['_wcf_optin_id'] ) //phpcs:ignore ) { return true; } } return false; } /** * Returns checkout ID. * * @since 1.0.0 * @return int/bool */ function _get_wcf_checkout_id() { if ( _is_wcf_checkout_type() ) { global $post; return $post->ID; } return false; } /** * Check if it is checkout shortcode. * * @since 1.0.0 * @return bool */ function _is_wcf_checkout_shortcode() { global $post; if ( ! empty( $post ) && has_shortcode( $post->post_content, 'cartflows_checkout' ) ) { return true; } return false; } /** * Check if it is checkout shortcode. * * @since 1.0.0 * @param string $content shortcode content. * @return bool */ function _get_wcf_checkout_id_from_shortcode( $content = '' ) { $checkout_id = 0; if ( ! empty( $content ) ) { $regex_pattern = get_shortcode_regex( array( 'cartflows_checkout' ) ); preg_match( '/' . $regex_pattern . '/s', $content, $regex_matches ); if ( ! empty( $regex_matches ) ) { if ( 'cartflows_checkout' == $regex_matches[2] ) { $attribure_str = str_replace( ' ', '&', trim( $regex_matches[3] ) ); $attribure_str = str_replace( '"', '', $attribure_str ); $attributes = wp_parse_args( $attribure_str ); if ( isset( $attributes['id'] ) ) { $checkout_id = $attributes['id']; } } } } return $checkout_id; } /** * Check if post type is upsell. * * @since 1.0.0 * @return bool */ function _is_wcf_upsell_type() { if ( wcf()->utils->is_step_post_type() ) { global $post; if ( 'upsell' === get_post_meta( $post->ID, 'wcf-step-type', true ) ) { return true; } } return false; } /** * Returns upsell ID. * * @since 1.0.0 * @return int/bool */ function _get_wcf_upsell_id() { if ( _is_wcf_upsell_type() ) { global $post; return $post->ID; } return false; } /** * Check if post is of type downsell. * * @since 1.0.0 * @return int/bool */ function _is_wcf_downsell_type() { if ( wcf()->utils->is_step_post_type() ) { global $post; if ( 'downsell' === get_post_meta( $post->ID, 'wcf-step-type', true ) ) { return true; } } return false; } /** * Get downsell page ID. * * @since 1.0.0 * @return int/bool */ function _get_wcf_downsell_id() { if ( _is_wcf_downsell_type() ) { global $post; return $post->ID; } return false; } /** * Check if page is of thank you type. * * @since 1.0.0 * @return int/bool */ function _is_wcf_thankyou_type() { if ( wcf()->utils->is_step_post_type() ) { global $post; if ( 'thankyou' === get_post_meta( $post->ID, 'wcf-step-type', true ) ) { return true; } } return false; } /** * Get thank you page ID. * * @since 1.0.0 * @return int/bool */ function _get_wcf_thankyou_id() { if ( _is_wcf_thankyou_type() ) { global $post; return $post->ID; } return false; } /** * Check if post type is upsell. * * @since 1.0.0 * @return bool */ function _is_wcf_base_offer_type() { if ( wcf()->utils->is_step_post_type() ) { global $post; $step_type = get_post_meta( $post->ID, 'wcf-step-type', true ); if ( 'upsell' === $step_type || 'downsell' === $step_type ) { return true; } } return false; } /** * Returns upsell ID. * * @since 1.0.0 * @return int/bool */ function _get_wcf_base_offer_id() { if ( _is_wcf_base_offer_type() ) { global $post; return $post->ID; } return false; } /** * Check if page is of optin type. * * @since 1.0.0 * @return int/bool */ function _is_wcf_optin_type() { if ( wcf()->utils->is_step_post_type() ) { global $post; if ( 'optin' === get_post_meta( $post->ID, 'wcf-step-type', true ) ) { return true; } } return false; } /** * Get optin page ID. * * @since 1.0.0 * @return int/bool */ function _get_wcf_optin_id() { if ( _is_wcf_optin_type() ) { global $post; return $post->ID; } return false; } /** * Define a constant if it is not already defined. * * @since 3.0.0 * @param string $name Constant name. * @param mixed $value Value. */ function wcf_maybe_define_constant( $name, $value ) { if ( ! defined( $name ) ) { define( $name, $value ); } } if ( ! function_exists( 'wp_body_open' ) ) { /** * Fire the wp_body_open action. * * Added for backwards compatibility to support WordPress versions prior to 5.2.0. */ function wp_body_open() { /** * Triggered after the opening tag. */ do_action( 'wp_body_open' ); } } /** * Check if type is optin by id. * * @param int $post_id post id. * * @return int/bool * @since 1.0.0 */ function _wcf_check_is_optin_by_id( $post_id ) { if ( 'optin' === get_post_meta( $post_id, 'wcf-step-type', true ) ) { return true; } return false; } class-cartflows-default-meta.php000066600000052274152133015060012744 0ustar00 array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-checkout-products' => array( 'default' => array(), 'sanitize' => 'FILTER_CARTFLOWS_CHECKOUT_PRODUCTS', ), 'wcf-checkout-layout' => array( 'default' => 'two-column', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-input-font-family' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-input-font-weight' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-heading-font-family' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-heading-font-weight' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-base-font-family' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-advance-options-fields' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-remove-product-field' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-checkout-place-order-button-text' => array( 'default' => '', 'sanitize' => 'FILTER_SANITIZE_STRING', ), 'wcf-base-font-weight' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-button-font-family' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-button-font-weight' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-primary-color' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-heading-color' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-section-bg-color' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-hl-bg-color' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-field-tb-padding' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-field-lr-padding' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-fields-skins' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-input-field-size' => array( 'default' => '33px', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-field-color' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-field-bg-color' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-field-border-color' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-box-border-color' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-field-label-color' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-submit-tb-padding' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-submit-lr-padding' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-input-button-size' => array( 'default' => '33px', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-submit-color' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-submit-hover-color' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-submit-bg-color' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-submit-bg-hover-color' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-submit-border-color' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-submit-border-hover-color' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-active-tab' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-header-logo-image' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-header-logo-width' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-custom-script' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), ); self::$checkout_fields = apply_filters( 'cartflows_checkout_meta_options', self::$checkout_fields, $post_id ); } return self::$checkout_fields; } /** * Save Checkout Meta fields. * * @param int $post_id post id. * @return void */ public function save_checkout_fields( $post_id ) { $post_meta = $this->get_checkout_fields( $post_id ); $this->save_meta_fields( $post_id, $post_meta ); } /** * Save Landing Meta fields. * * @param int $post_id post id. * @return void */ public function save_landing_fields( $post_id ) { $post_meta = $this->get_landing_fields( $post_id ); $this->save_meta_fields( $post_id, $post_meta ); } /** * Save ThankYou Meta fields. * * @param int $post_id post id. * @return void */ public function save_thankyou_fields( $post_id ) { $post_meta = $this->get_thankyou_fields( $post_id ); $this->save_meta_fields( $post_id, $post_meta ); } /** * Flow Default fields. * * @param int $post_id post id. * @return array */ public function get_flow_fields( $post_id ) { if ( null === self::$flow_fields ) { self::$flow_fields = array( 'wcf-steps' => array( 'default' => array(), 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-testing' => array( 'default' => 'no', 'sanitize' => 'FILTER_DEFAULT', ), ); } return apply_filters( 'cartflows_flow_meta_options', self::$flow_fields ); } /** * Save Flow Meta fields. * * @param int $post_id post id. * @return void */ public function save_flow_fields( $post_id ) { $post_meta = $this->get_flow_fields( $post_id ); if ( isset( $post_meta['wcf-steps'] ) ) { unset( $post_meta['wcf-steps'] ); } $this->save_meta_fields( $post_id, $post_meta ); } /** * Save Meta fields - Common Function. * * @param int $post_id post id. * @param array $post_meta options to store. * @return void */ public function save_meta_fields( $post_id, $post_meta ) { if ( ! ( $post_id && is_array( $post_meta ) ) ) { return; } foreach ( $post_meta as $key => $data ) { $meta_value = false; // Sanitize values. $sanitize_filter = ( isset( $data['sanitize'] ) ) ? $data['sanitize'] : 'FILTER_DEFAULT'; switch ( $sanitize_filter ) { case 'FILTER_SANITIZE_STRING': $meta_value = filter_input( INPUT_POST, $key, FILTER_SANITIZE_STRING ); break; case 'FILTER_SANITIZE_URL': $meta_value = filter_input( INPUT_POST, $key, FILTER_SANITIZE_URL ); break; case 'FILTER_SANITIZE_NUMBER_INT': $meta_value = filter_input( INPUT_POST, $key, FILTER_SANITIZE_NUMBER_INT ); break; case 'FILTER_CARTFLOWS_ARRAY': if ( isset( $_POST[ $key ] ) && is_array( $_POST[ $key ] ) ) { //phpcs:ignore $meta_value = array_map( 'sanitize_text_field', wp_unslash( $_POST[ $key ] ) ); //phpcs:ignore } break; case 'FILTER_CARTFLOWS_CHECKOUT_PRODUCTS': if ( isset( $_POST[ $key ] ) && is_array( $_POST[ $key ] ) ) { //phpcs:ignore $i = 0; $q = 0; foreach ( $_POST[ $key ] as $p_index => $p_data ) { // phpcs:ignore foreach ( $p_data as $i_key => $i_value ) { if ( is_array( $i_value ) ) { foreach ( $i_value as $q_key => $q_value ) { $meta_value[ $i ][ $i_key ][ $q ] = array_map( 'sanitize_text_field', $q_value ); $q++; } } else { $meta_value[ $i ][ $i_key ] = sanitize_text_field( $i_value ); } } $i++; } } break; case 'FILTER_CARTFLOWS_IMAGES': $meta_value = filter_input( INPUT_POST, $key, FILTER_DEFAULT ); if ( isset( $_POST[ $key . '-obj' ] )) { //phpcs:ignore if ( ! is_serialized( $_POST[ $key . '-obj' ] ) ) { //phpcs:ignore $image_obj = json_decode( stripcslashes( wp_unslash( $_POST[ $key . '-obj' ] ) ), true ); //phpcs:ignore $image_url = isset( $image_obj['sizes'] ) ? $image_obj['sizes'] : array(); $image_data = array( 'id' => isset( $image_obj['id'] ) ? intval( $image_obj['id'] ) : 0, 'url' => array( 'thumbnail' => isset( $image_url['thumbnail']['url'] ) ? esc_url_raw( $image_url['thumbnail']['url'] ) : '', 'medium' => isset( $image_url['medium']['url'] ) ? esc_url_raw( $image_url['medium']['url'] ) : '', 'full' => isset( $image_url['full']['url'] ) ? esc_url_raw( $image_url['full']['url'] ) : '', ), ); $new_meta_value = 0 !== $image_data['id'] ? $image_data : ''; update_post_meta( $post_id, $key . '-obj', $new_meta_value ); } } break; default: if ( 'FILTER_DEFAULT' === $sanitize_filter ) { $meta_value = filter_input( INPUT_POST, $key, FILTER_DEFAULT ); } else { $meta_value = apply_filters( 'cartflows_save_meta_field_values', $meta_value, $post_id, $key, $sanitize_filter ); } break; } if ( false !== $meta_value ) { update_post_meta( $post_id, $key, $meta_value ); } else { delete_post_meta( $post_id, $key ); } } } /** * Get checkout meta. * * @param int $post_id post id. * @param string $key options key. * @param mix $default options default value. * @return string */ public function get_flow_meta_value( $post_id, $key, $default = false ) { $value = $this->get_save_meta( $post_id, $key ); if ( ! $value ) { if ( $default ) { $value = $default; } else { $fields = $this->get_flow_fields( $post_id ); if ( isset( $fields[ $key ]['default'] ) ) { $value = $fields[ $key ]['default']; } } } return $value; } /** * Get checkout meta. * * @param int $post_id post id. * @param string $key options key. * @param mix $default options default value. * @return string */ public function get_checkout_meta_value( $post_id = 0, $key = '', $default = false ) { $value = $this->get_save_meta( $post_id, $key ); if ( ! $value ) { if ( false !== $default ) { $value = $default; } else { $fields = $this->get_checkout_fields( $post_id ); if ( isset( $fields[ $key ]['default'] ) ) { $value = $fields[ $key ]['default']; } } } return $value; } /** * Get post meta. * * @param int $post_id post id. * @param string $key options key. * @return string */ public function get_save_meta( $post_id, $key ) { $value = get_post_meta( $post_id, $key, true ); return $value; } /** * Thank You Default fields. * * @param int $post_id post id. * @return array */ public function get_thankyou_fields( $post_id ) { if ( null === self::$thankyou_fields ) { self::$thankyou_fields = array( 'wcf-field-google-font-url' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-active-tab' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-tq-text-color' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-tq-font-family' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-tq-font-size' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-tq-heading-color' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-tq-heading-font-family' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-tq-heading-font-wt' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-tq-container-width' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-tq-section-bg-color' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-tq-advance-options-fields' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-show-overview-section' => array( 'default' => 'yes', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-show-details-section' => array( 'default' => 'yes', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-show-billing-section' => array( 'default' => 'yes', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-show-shipping-section' => array( 'default' => 'yes', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-show-tq-redirect-section' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-tq-redirect-link' => array( 'default' => '', 'sanitize' => 'FILTER_SANITIZE_URL', ), 'wcf-tq-text' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-custom-script' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), ); } return apply_filters( 'cartflows_thankyou_meta_options', self::$thankyou_fields, $post_id ); } /** * Get Thank you section meta. * * @param int $post_id post id. * @param string $key options key. * @param mix $default options default value. * @return string */ public function get_thankyou_meta_value( $post_id, $key, $default = false ) { $value = $this->get_save_meta( $post_id, $key ); if ( ! $value ) { if ( $default ) { $value = $default; } else { $fields = $this->get_thankyou_fields( $post_id ); if ( isset( $fields[ $key ]['default'] ) ) { $value = $fields[ $key ]['default']; } } } return $value; } /** * Get Landing section meta. * * @param int $post_id post id. * @param string $key options key. * @param mix $default options default value. * @return string */ public function get_landing_meta_value( $post_id, $key, $default = false ) { $value = $this->get_save_meta( $post_id, $key ); if ( ! $value ) { if ( $default ) { $value = $default; } else { $fields = $this->get_landing_fields( $post_id ); if ( isset( $fields[ $key ]['default'] ) ) { $value = $fields[ $key ]['default']; } } } return $value; } /** * Landing Default fields. * * @param int $post_id post id. * @return array */ public function get_landing_fields( $post_id ) { if ( null === self::$landing_fields ) { self::$landing_fields = array( 'wcf-custom-script' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), ); } return apply_filters( 'cartflows_landing_meta_options', self::$landing_fields, $post_id ); } /** * Optin Default fields. * * @param int $post_id post id. * @return array */ public function get_optin_fields( $post_id ) { if ( null === self::$optin_fields ) { self::$optin_fields = array( 'wcf-optin-product' => array( 'default' => array(), 'sanitize' => 'FILTER_CARTFLOWS_ARRAY', ), /* Style */ 'wcf-field-google-font-url' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-primary-color' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-base-font-family' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-input-fields-skins' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-input-font-family' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-input-font-weight' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-input-field-size' => array( 'default' => '33px', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-field-tb-padding' => array( 'default' => '', 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT', ), 'wcf-field-lr-padding' => array( 'default' => '', 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT', ), 'wcf-field-color' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-field-bg-color' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-field-border-color' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-field-label-color' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-submit-button-text' => array( 'default' => __( 'Submit', 'cartflows' ), 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-submit-font-size' => array( 'default' => '', 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT', ), 'wcf-button-font-family' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-button-font-weight' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-submit-button-size' => array( 'default' => '33px', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-submit-tb-padding' => array( 'default' => '', 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT', ), 'wcf-submit-lr-padding' => array( 'default' => '', 'sanitize' => 'FILTER_SANITIZE_NUMBER_INT', ), 'wcf-submit-button-position' => array( 'default' => 'center', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-submit-color' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-submit-hover-color' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-submit-bg-color' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-submit-bg-hover-color' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-submit-border-color' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-submit-border-hover-color' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), /* Settings */ 'wcf-optin-pass-fields' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), 'wcf-optin-pass-specific-fields' => array( 'default' => 'first_name', 'sanitize' => 'FILTER_DEFAULT', ), /* Script */ 'wcf-custom-script' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), /* Hidden */ 'wcf-active-tab' => array( 'default' => '', 'sanitize' => 'FILTER_DEFAULT', ), ); } return apply_filters( 'cartflows_optin_meta_options', self::$optin_fields, $post_id ); } /** * Save Optin Meta fields. * * @param int $post_id post id. * @return void */ public function save_optin_fields( $post_id ) { $post_meta = $this->get_optin_fields( $post_id ); $this->save_meta_fields( $post_id, $post_meta ); } /** * Get optin meta. * * @param int $post_id post id. * @param string $key options key. * @param mix $default options default value. * @return string */ public function get_optin_meta_value( $post_id = 0, $key = '', $default = false ) { $value = $this->get_save_meta( $post_id, $key ); if ( ! $value ) { if ( false !== $default ) { $value = $default; } else { $fields = $this->get_optin_fields( $post_id ); if ( isset( $fields[ $key ]['default'] ) ) { $value = $fields[ $key ]['default']; } } } return $value; } } /** * Kicking this off by calling 'get_instance()' method */ Cartflows_Default_Meta::get_instance(); class-cartflows-importer.php000066600000155357152133015060012243 0ustar00post_type ) { $actions['export'] = '' . __( 'Export', 'cartflows' ) . ''; } return $actions; } /** * Add menus * * @since 1.1.4 */ public function add_to_menus() { add_submenu_page( 'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE, __( 'Flow Export', 'cartflows' ), __( 'Flow Export', 'cartflows' ), 'export', 'flow_exporter', array( $this, 'exporter_markup' ) ); add_submenu_page( 'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE, __( 'Flow Import', 'cartflows' ), __( 'Flow Import', 'cartflows' ), 'import', 'flow_importer', array( $this, 'importer_markup' ) ); } /** * Export flow with steps and its meta * * @since 1.1.4 */ public function export_flow() { if ( ! ( isset( $_GET['post'] ) || isset( $_POST['post'] ) || ( isset( $_REQUEST['action'] ) && 'cartflows_export_flow' == $_REQUEST['action'] ) ) ) { wp_die( esc_html__( 'No post to export has been supplied!', 'cartflows' ) ); } if ( ! isset( $_GET['flow_export_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['flow_export_nonce'] ) ), basename( __FILE__ ) ) ) { return; } // Get the original post id. $flow_id = ( isset( $_GET['post'] ) ? absint( $_GET['post'] ) : absint( $_POST['post'] ) ); $flows = array(); $flows[] = $this->get_flow_export_data( $flow_id ); $flows = apply_filters( 'cartflows_export_data', $flows ); nocache_headers(); header( 'Content-Type: application/json; charset=utf-8' ); header( 'Content-Disposition: attachment; filename=cartflows-flow-' . $flow_id . '-' . gmdate( 'm-d-Y' ) . '.json' ); header( 'Expires: 0' ); echo wp_json_encode( $flows ); exit; } /** * Export flow markup * * @since 1.1.4 */ public function exporter_markup() { include_once CARTFLOWS_DIR . 'includes/exporter.php'; } /** * Import flow markup * * @since 1.1.4 */ public function importer_markup() { include_once CARTFLOWS_DIR . 'includes/importer.php'; } /** * Export flow * * @since 1.1.4 */ public function export_json() { if ( empty( $_POST['cartflows-action'] ) || 'export' != $_POST['cartflows-action'] ) { return; } if ( isset( $_POST['cartflows-action-nonce'] ) && ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['cartflows-action-nonce'] ) ), 'cartflows-action-nonce' ) ) { return; } if ( ! current_user_can( 'manage_options' ) ) { return; } $flows = $this->get_all_flow_export_data(); $flows = apply_filters( 'cartflows_export_data', $flows ); nocache_headers(); header( 'Content-Type: application/json; charset=utf-8' ); header( 'Content-Disposition: attachment; filename=cartflows-flow-export-' . gmdate( 'm-d-Y' ) . '.json' ); header( 'Expires: 0' ); echo wp_json_encode( $flows ); exit; } /** * Get flow export data * * @since 1.1.4 * * @param integer $flow_id Flow ID. * @return array */ public function get_flow_export_data( $flow_id ) { $export_all = apply_filters( 'cartflows_export_all', false ); $valid_step_meta_keys = array( '_wp_page_template', '_thumbnail_id', 'classic-editor-remember', ); $new_steps = array(); $steps = get_post_meta( $flow_id, 'wcf-steps', true ); if ( $steps ) { foreach ( $steps as $key => $step ) { // Add step post meta. $new_all_meta = array(); $all_meta = get_post_meta( $step['id'] ); if ( is_array( $all_meta ) ) { if ( $export_all ) { foreach ( $all_meta as $meta_key => $value ) { $new_all_meta[ $meta_key ] = maybe_unserialize( $value[0] ); } } else { foreach ( $all_meta as $meta_key => $value ) { if ( substr( $meta_key, 0, strlen( 'wcf' ) ) === 'wcf' ) { $new_all_meta[ $meta_key ] = maybe_unserialize( $value[0] ); } elseif ( in_array( $meta_key, $valid_step_meta_keys, true ) ) { $new_all_meta[ $meta_key ] = maybe_unserialize( $value[0] ); } } } } // Add single step. $step_data_arr = array( 'title' => get_the_title( $step['id'] ), 'type' => $step['type'], 'meta' => $new_all_meta, 'post_content' => '', ); if ( $export_all ) { $step_post_obj = get_post( $step['id'] ); $step_data_arr['post_content'] = $step_post_obj->post_content; } $new_steps[] = $step_data_arr; } } // Add single flow. return array( 'title' => get_the_title( $flow_id ), 'steps' => $new_steps, ); } /** * Get all flow export data * * @since 1.1.4 */ public function get_all_flow_export_data() { $query_args = array( 'post_type' => CARTFLOWS_FLOW_POST_TYPE, // Query performance optimization. 'fields' => 'ids', 'no_found_rows' => true, 'posts_per_page' => -1, ); $query = new WP_Query( $query_args ); $flows = array(); if ( $query->posts ) { foreach ( $query->posts as $key => $post_id ) { $flows[] = $this->get_flow_export_data( $post_id ); } } return $flows; } /** * Import our exported file * * @since 1.1.4 */ public function import_json() { if ( empty( $_POST['cartflows-action'] ) || 'import' != $_POST['cartflows-action'] ) { return; } if ( isset( $_POST['cartflows-action-nonce'] ) && ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['cartflows-action-nonce'] ) ), 'cartflows-action-nonce' ) ) { return; } if ( ! current_user_can( 'manage_options' ) ) { return; } $filename = $_FILES['file']['name']; //phpcs:ignore $file_info = explode( '.', $filename ); $extension = end( $file_info ); if ( 'json' != $extension ) { wp_die( esc_html__( 'Please upload a valid .json file', 'cartflows' ) ); } $file = $_FILES['file']['tmp_name']; //phpcs:ignore if ( empty( $file ) ) { wp_die( esc_html__( 'Please upload a file to import', 'cartflows' ) ); } // Retrieve the settings from the file and convert the JSON object to an array. $flows = json_decode( file_get_contents( $file ), true );//phpcs:ignore $this->import_from_json_data( $flows ); add_action( 'admin_notices', array( $this, 'imported_successfully' ) ); } /** * Import flow from the JSON data * * @since x.x.x * @param array $flows JSON array. * @return void */ public function import_from_json_data( $flows ) { if ( $flows ) { foreach ( $flows as $key => $flow ) { $flow_title = $flow['title']; if ( post_exists( $flow['title'] ) ) { $flow_title = $flow['title'] . ' Copy'; } // Create post object. $new_flow_args = apply_filters( 'cartflows_flow_importer_args', array( 'post_type' => CARTFLOWS_FLOW_POST_TYPE, 'post_title' => $flow_title, 'post_status' => 'draft', ) ); // Insert the post into the database. $flow_id = wp_insert_post( $new_flow_args ); /** * Fire after flow import * * @since x.x.x * @param int $flow_id Flow ID. * @param array $new_flow_args Flow post args. * @param array $flows Flow JSON data. */ do_action( 'cartflows_flow_imported', $flow_id, $new_flow_args, $flows ); if ( $flow['steps'] ) { foreach ( $flow['steps'] as $key => $step ) { $new_step_args = apply_filters( 'cartflows_step_importer_args', array( 'post_type' => CARTFLOWS_STEP_POST_TYPE, 'post_title' => $step['title'], 'post_status' => 'publish', 'meta_input' => $step['meta'], 'post_content' => isset( $step['post_content'] ) ? $step['post_content'] : '', ) ); $new_step_id = wp_insert_post( $new_step_args ); /** * Fire after step import * * @since x.x.x * @param int $new_step_id step ID. * @param int $flow_id flow ID. * @param array $new_step_args Step post args. * @param array $flow_steps Flow steps. * @param array $flows All flows JSON data. */ do_action( 'cartflows_step_imported', $new_step_id, $flow_id, $new_step_args, $flow['steps'], $flows ); // Insert post meta. update_post_meta( $new_step_id, 'wcf-flow-id', $flow_id ); $step_taxonomy = CARTFLOWS_TAXONOMY_STEP_TYPE; $current_term = term_exists( $step['type'], $step_taxonomy ); // // Set type object. $data = get_term( $current_term['term_id'], $step_taxonomy ); $step_slug = $data->slug; wp_set_object_terms( $new_step_id, $data->slug, $step_taxonomy ); // Set type. update_post_meta( $new_step_id, 'wcf-step-type', $data->slug ); // Set flow. wp_set_object_terms( $new_step_id, 'flow-' . $flow_id, CARTFLOWS_TAXONOMY_STEP_FLOW ); self::get_instance()->set_step_to_flow( $flow_id, $new_step_id, $step['title'], $step_slug ); if ( isset( $step['post_content'] ) && ! empty( $step['post_content'] ) ) { // Download and replace images. $content = $this->get_content( $step['post_content'] ); // Update post content. wp_update_post( array( 'ID' => $new_step_id, 'post_content' => $content, ) ); } } } } } } /** * Download and Replace hotlink images * * @since x.x.x * * @param string $content Mixed post content. * @return array Hotlink image array. */ public function get_content( $content = '' ) { $all_links = wp_extract_urls( $content ); $image_links = array(); $image_map = array(); // Not have any link. if ( empty( $all_links ) ) { return $content; } foreach ( $all_links as $key => $link ) { if ( preg_match( '/\.(jpg|jpeg|png|gif)/i', $link ) ) { $image_links[] = $link; } } // Not have any image link. if ( empty( $image_links ) ) { return $content; } foreach ( $image_links as $key => $image_url ) { // Download remote image. $image = array( 'url' => $image_url, 'id' => wp_rand( 000, 999 ), ); $downloaded_image = CartFlows_Import_Image::get_instance()->import( $image ); // Old and New image mapping links. $image_map[ $image_url ] = $downloaded_image['url']; } // Replace old image links with new image links. foreach ( $image_map as $old_url => $new_url ) { $content = str_replace( $old_url, $new_url, $content ); } return $content; } /** * Imported notice * * @since 1.1.4 */ public function imported_successfully() { ?>

files_manager->clear_cache(); } } /** * JS Templates * * @since 1.0.0 * * @return void */ public function js_templates() { // Loading Templates. ?> post_type ) ) { return; } wp_enqueue_script( 'cartflows-rest-api', CARTFLOWS_URL . 'assets/js/rest-api.js', array( 'jquery' ), CARTFLOWS_VER, true ); wp_enqueue_style( 'cartflows-import', CARTFLOWS_URL . 'assets/css/import.css', null, CARTFLOWS_VER, 'all' ); wp_style_add_data( 'cartflows-import', 'rtl', 'replace' ); wp_enqueue_script( 'cartflows-import', CARTFLOWS_URL . 'assets/js/import.js', array( 'jquery', 'wp-util', 'cartflows-rest-api', 'updates' ), CARTFLOWS_VER, true ); $installed_plugins = get_plugins(); $is_wc_installed = isset( $installed_plugins['woocommerce/woocommerce.php'] ) ? 'yes' : 'no'; $is_wc_activated = wcf()->is_woo_active ? 'yes' : 'no'; $localize_vars = array( '_is_pro_active' => _is_cartflows_pro(), 'is_wc_installed' => $is_wc_installed, 'is_wc_activated' => $is_wc_activated, // Flow and its rest fields. 'flow' => CARTFLOWS_FLOW_POST_TYPE, 'flow_fields' => array( 'id', 'title', 'flow_type', 'page_builder', 'flow_steps', 'licence_status', 'featured_image_url', 'featured_media', // @required for field `featured_image_url`. ), // Flow type and rest fields. 'flow_type' => CARTFLOWS_TAXONOMY_FLOW_CATEGORY, 'flow_type_fields' => array( 'id', 'name', 'slug', ), // Flow page builder and rest fields. 'flow_page_builder' => CARTFLOWS_TAXONOMY_FLOW_PAGE_BUILDER, 'flow_page_builder_fields' => array( 'id', 'name', 'slug', ), // Step page builder and rest fields. 'step_page_builder' => CARTFLOWS_TAXONOMY_STEP_PAGE_BUILDER, 'step_page_builder_fields' => array( 'id', 'name', 'slug', ), // Step and its rest fields. 'step' => CARTFLOWS_STEP_POST_TYPE, 'step_fields' => array( 'title', 'featured_image_url', 'featured_media', // @required for field `featured_image_url`. 'id', 'flow_type', 'step_type', 'page_builder', 'licence_status', ), // Step type and its rest fields. 'step_type' => CARTFLOWS_TAXONOMY_STEP_TYPE, 'step_type_fields' => array( 'id', 'name', 'slug', ), 'domain_url' => CARTFLOWS_DOMAIN_URL, 'server_url' => CARTFLOWS_TEMPLATES_URL, 'server_rest_url' => CARTFLOWS_TEMPLATES_URL . 'wp-json/wp/v2/', 'site_url' => site_url(), 'import_url' => admin_url( 'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE . '&page=flow_importer' ), 'export_url' => admin_url( 'edit.php?post_type=' . CARTFLOWS_FLOW_POST_TYPE . '&page=flow_exporter' ), 'admin_url' => admin_url(), 'licence_args' => CartFlows_API::get_instance()->get_licence_args(), 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'debug' => ( ( defined( 'WP_DEBUG' ) && WP_DEBUG ) || isset( $_GET['debug'] ) ) ? true : false, //phpcs:ignore 'required_plugins' => Cartflows_Helper::get_plugins_groupby_page_builders(), 'default_page_builder' => Cartflows_Helper::get_common_setting( 'default_page_builder' ), ); $localize_vars['cartflows_activate_plugin_nonce'] = wp_create_nonce( 'cartflows_activate_plugin' ); // var_dump(Cartflows_Helper::get_common_setting( 'default_page_builder' )); // wp_die( ); // Add thickbox. add_thickbox(); wp_localize_script( 'cartflows-import', 'CartFlowsImportVars', $localize_vars ); wp_localize_script( 'cartflows-rest-api', 'CartFlowsImportVars', $localize_vars ); } /** * Import. * * @since 1.0.0 * * @hook wp_ajax_cartflows_import_flow_step * @return void */ public function import_flow() { if ( ! current_user_can( 'manage_options' ) ) { return; } check_ajax_referer( 'cf-import-flow-step', 'security' ); $flow_id = isset( $_POST['flow_id'] ) ? intval( $_POST['flow_id'] ) : ''; $template_id = isset( $_POST['template_id'] ) ? intval( $_POST['template_id'] ) : ''; wcf()->logger->import_log( '------------------------------------' ); wcf()->logger->import_log( 'STARTED! Importing FLOW' ); wcf()->logger->import_log( '------------------------------------' ); wcf()->logger->import_log( '(✓) Creating new step from remote step [' . $template_id . '] for FLOW ' . get_the_title( $flow_id ) . ' [' . $flow_id . ']' ); $response = CartFlows_API::get_instance()->get_template( $template_id ); $post_content = isset( $response['data']['content']->rendered ) ? $response['data']['content']->rendered : ''; if ( 'divi' === Cartflows_Helper::get_common_setting( 'default_page_builder' ) ) { if ( isset( $response['data']['divi_content'] ) && ! empty( $response['data']['divi_content'] ) ) { $post_content = $response['data']['divi_content']; } } if ( false === $response['success'] ) { wcf()->logger->import_log( '(✕) Failed to fetch remote data.' ); wp_send_json_error( $response ); } wcf()->logger->import_log( '(✓) Successfully getting remote step response ' . wp_json_encode( $response ) ); $new_step_id = wp_insert_post( array( 'post_type' => CARTFLOWS_STEP_POST_TYPE, 'post_title' => $response['title'], 'post_content' => $post_content, 'post_status' => 'publish', ) ); if ( is_wp_error( $new_step_id ) ) { wcf()->logger->import_log( '(✕) Failed to create new step for flow ' . $flow_id ); wp_send_json_error( $new_step_id ); } if ( 'divi' === Cartflows_Helper::get_common_setting( 'default_page_builder' ) ) { if ( isset( $response['data']['divi_content'] ) && ! empty( $response['data']['divi_content'] ) ) { update_post_meta( $new_step_id, 'divi_content', $response['data']['divi_content'] ); } } /* Imported Step */ update_post_meta( $new_step_id, 'cartflows_imported_step', 'yes' ); wcf()->logger->import_log( '(✓) Created new step ' . '"' . $response['title'] . '" id ' . $new_step_id );//phpcs:ignore // insert post meta. update_post_meta( $new_step_id, 'wcf-flow-id', $flow_id ); wcf()->logger->import_log( '(✓) Added flow ID ' . $flow_id . ' in post meta key wcf-flow-id.' ); /** * Import & Set type. */ $term = isset( $response['data']['step_type'] ) ? $response['data']['step_type'] : ''; $term_slug = ''; if ( $term ) { $taxonomy = CARTFLOWS_TAXONOMY_STEP_TYPE; $term_exist = term_exists( $term->slug, $taxonomy ); if ( empty( $term_exist ) ) { $terms = array( array( 'name' => $term->name, 'slug' => $term->slug, ), ); Cartflows_Step_Post_Type::get_instance()->add_terms( $taxonomy, $terms ); wcf()->logger->import_log( '(✓) Created new term name ' . $term->name . ' | term slug ' . $term->slug ); } $current_term = term_exists( $term->slug, $taxonomy ); // Set type object. $data = get_term( $current_term['term_id'], $taxonomy ); $term_slug = $data->slug; $term_name = $data->name; wp_set_object_terms( $new_step_id, $term_slug, CARTFLOWS_TAXONOMY_STEP_TYPE ); wcf()->logger->import_log( '(✓) Assigned existing term ' . $term_name . ' to the template ' . $new_step_id ); // Set type. update_post_meta( $new_step_id, 'wcf-step-type', $term_slug ); wcf()->logger->import_log( '(✓) Updated term ' . $term_name . ' to the post meta wcf-step-type.' ); } // Set flow. wp_set_object_terms( $new_step_id, 'flow-' . $flow_id, CARTFLOWS_TAXONOMY_STEP_FLOW ); wcf()->logger->import_log( '(✓) Assigned flow step flow-' . $flow_id ); /** * Update steps for the current flow. */ $flow_steps = get_post_meta( $flow_id, 'wcf-steps', true ); if ( ! is_array( $flow_steps ) ) { $flow_steps = array(); } $flow_steps[] = array( 'id' => $new_step_id, 'title' => $response['title'], 'type' => $term_slug, ); update_post_meta( $flow_id, 'wcf-steps', $flow_steps ); wcf()->logger->import_log( '(✓) Updated flow steps post meta key \'wcf-steps\' ' . wp_json_encode( $flow_steps ) ); // Import Post Meta. self::import_post_meta( $new_step_id, $response ); wcf()->logger->import_log( '(✓) Importing step "' . get_the_title( $new_step_id ) . '" [' . $new_step_id . '] for FLOW "' . get_the_title( $flow_id ) . '" [' . $flow_id . ']' ); wcf()->logger->import_log( '------------------------------------' ); wcf()->logger->import_log( 'COMPLETE! Importing FLOW' ); wcf()->logger->import_log( '------------------------------------' ); do_action( 'cartflows_import_complete' ); wcf()->logger->import_log( '(✓) BATCH STARTED for step ' . $new_step_id . ' for Blog name \'' . get_bloginfo( 'name' ) . '\' (' . get_current_blog_id() . ')' ); // Batch Process. do_action( 'cartflows_after_template_import', $new_step_id, $response ); /** * End */ wp_send_json_success( $new_step_id ); } /** * Import Step. * * @since 1.0.0 * @hook wp_ajax_cartflows_step_import * * @return void */ public function create_default_flow() { if ( ! current_user_can( 'manage_options' ) ) { return; } check_ajax_referer( 'cf-default-flow', 'security' ); // Create post object. $new_flow_post = array( 'post_content' => '', 'post_status' => 'publish', 'post_type' => CARTFLOWS_FLOW_POST_TYPE, ); // Insert the post into the database. $flow_id = wp_insert_post( $new_flow_post ); if ( is_wp_error( $flow_id ) ) { wp_send_json_error( $flow_id->get_error_message() ); } $flow_steps = array(); if ( wcf()->is_woo_active ) { $steps_data = array( 'sales' => array( 'title' => __( 'Sales Landing', 'cartflows' ), 'type' => 'landing', ), 'order-form' => array( 'title' => __( 'Checkout (Woo)', 'cartflows' ), 'type' => 'checkout', ), 'order-confirmation' => array( 'title' => __( 'Thank You (Woo)', 'cartflows' ), 'type' => 'thankyou', ), ); } else { $steps_data = array( 'landing' => array( 'title' => __( 'Landing', 'cartflows' ), 'type' => 'landing', ), 'thankyou' => array( 'title' => __( 'Thank You', 'cartflows' ), 'type' => 'landing', ), ); } foreach ( $steps_data as $slug => $data ) { $post_content = ''; $step_type = trim( $data['type'] ); $step_id = wp_insert_post( array( 'post_type' => CARTFLOWS_STEP_POST_TYPE, 'post_title' => $data['title'], 'post_content' => $post_content, 'post_status' => 'publish', ) ); if ( is_wp_error( $step_id ) ) { wp_send_json_error( $step_id->get_error_message() ); } if ( $step_id ) { $flow_steps[] = array( 'id' => $step_id, 'title' => $data['title'], 'type' => $step_type, ); // insert post meta. update_post_meta( $step_id, 'wcf-flow-id', $flow_id ); update_post_meta( $step_id, 'wcf-step-type', $step_type ); wp_set_object_terms( $step_id, $step_type, CARTFLOWS_TAXONOMY_STEP_TYPE ); wp_set_object_terms( $step_id, 'flow-' . $flow_id, CARTFLOWS_TAXONOMY_STEP_FLOW ); update_post_meta( $step_id, '_wp_page_template', 'cartflows-default' ); } } update_post_meta( $flow_id, 'wcf-steps', $flow_steps ); wp_send_json_success( $flow_id ); } /** * Create Flow * * @return void */ public function create_flow() { if ( ! current_user_can( 'manage_options' ) ) { return; } check_ajax_referer( 'cf-create-flow', 'security' ); // Create post object. $new_flow_post = array( 'post_content' => '', 'post_status' => 'publish', 'post_type' => CARTFLOWS_FLOW_POST_TYPE, ); // Insert the post into the database. $flow_id = wp_insert_post( $new_flow_post ); if ( is_wp_error( $flow_id ) ) { wp_send_json_error( $flow_id->get_error_message() ); } /* Imported Flow */ update_post_meta( $flow_id, 'cartflows_imported_flow', 'yes' ); wp_send_json_success( $flow_id ); } /** * Create Step * * @return void */ public function import_step() { if ( ! current_user_can( 'manage_options' ) ) { return; } check_ajax_referer( 'cf-step-import', 'security' ); $template_id = isset( $_POST['template_id'] ) ? intval( $_POST['template_id'] ) : ''; $flow_id = isset( $_POST['flow_id'] ) ? intval( $_POST['flow_id'] ) : ''; $step_title = isset( $_POST['step_title'] ) ? sanitize_text_field( wp_unslash( $_POST['step_title'] ) ) : ''; $step_type = isset( $_POST['step_type'] ) ? sanitize_title( wp_unslash( $_POST['step_type'] ) ) : ''; $step_custom_title = isset( $_POST['step_custom_title'] ) ? sanitize_title( wp_unslash( $_POST['step_custom_title'] ) ) : $step_title; $cartflow_meta = Cartflows_Flow_Meta::get_instance(); $post_id = $cartflow_meta->create_step( $flow_id, $step_type, $step_custom_title ); wcf()->logger->import_log( '------------------------------------' ); wcf()->logger->import_log( 'STARTED! Importing STEP' ); wcf()->logger->import_log( '------------------------------------' ); if ( empty( $template_id ) || empty( $post_id ) ) { /* translators: %s: template ID */ $data = sprintf( __( 'Invalid template id %1$s or post id %2$s.', 'cartflows' ), $template_id, $post_id ); wcf()->logger->import_log( $data ); wp_send_json_error( $data ); } wcf()->logger->import_log( 'Remote Step ' . $template_id . ' for local flow "' . get_the_title( $post_id ) . '" [' . $post_id . ']' ); $response = CartFlows_API::get_instance()->get_template( $template_id ); if ( 'divi' === Cartflows_Helper::get_common_setting( 'default_page_builder' ) ) { if ( isset( $response['data']['divi_content'] ) && ! empty( $response['data']['divi_content'] ) ) { update_post_meta( $post_id, 'divi_content', $response['data']['divi_content'] ); wp_update_post( array( 'ID' => $post_id, 'post_content' => $response['data']['divi_content'], ) ); } } /* Imported Step */ update_post_meta( $post_id, 'cartflows_imported_step', 'yes' ); // Import Post Meta. self::import_post_meta( $post_id, $response ); do_action( 'cartflows_import_complete' ); // Batch Process. do_action( 'cartflows_after_template_import', $post_id, $response ); wcf()->logger->import_log( '------------------------------------' ); wcf()->logger->import_log( 'COMPLETE! Importing Step' ); wcf()->logger->import_log( '------------------------------------' ); wp_send_json_success( $post_id ); } /** * Import Step. * * @since 1.0.0 * @hook wp_ajax_cartflows_step_create_blank * * @return void */ public function step_create_blank() { if ( ! current_user_can( 'manage_options' ) ) { return; } check_ajax_referer( 'cf-step-create-blank', 'security' ); $flow_id = isset( $_POST['flow_id'] ) ? intval( $_POST['flow_id'] ) : ''; $step_type = isset( $_POST['step_type'] ) ? sanitize_text_field( wp_unslash( $_POST['step_type'] ) ) : ''; $step_title = isset( $_POST['step_title'] ) ? sanitize_text_field( wp_unslash( $_POST['step_title'] ) ) : ''; if ( empty( $flow_id ) || empty( $step_type ) ) { /* translators: %s: flow ID */ $data = sprintf( __( 'Invalid flow id %1$s OR step type %2$s.', 'cartflows' ), $flow_id, $step_type ); wcf()->logger->import_log( $data ); wp_send_json_error( $data ); } wcf()->logger->import_log( '------------------------------------' ); wcf()->logger->import_log( 'STARTED! Creating Blank STEP for Flow ' . $flow_id ); $step_type_title = str_replace( '-', ' ', $step_type ); $step_type_slug = strtolower( str_replace( '-', ' ', $step_type ) ); $new_step_id = wp_insert_post( array( 'post_type' => CARTFLOWS_STEP_POST_TYPE, 'post_title' => $step_title, 'post_content' => '', 'post_status' => 'publish', ) ); // insert post meta. update_post_meta( $new_step_id, 'wcf-flow-id', $flow_id ); $taxonomy = CARTFLOWS_TAXONOMY_STEP_TYPE; $term_exist = term_exists( $step_type_slug, $taxonomy ); if ( empty( $term_exist ) ) { $terms = array( array( 'name' => $step_type_title, 'slug' => $step_type_slug, ), ); Cartflows_Step_Post_Type::get_instance()->add_terms( $taxonomy, $terms ); wcf()->logger->import_log( '(✓) Created new term name ' . $step_type_title . ' | term slug ' . $step_type_slug ); } $current_term = term_exists( $step_type_slug, $taxonomy ); // Set type object. $data = get_term( $current_term['term_id'], $taxonomy ); $step_slug = $data->slug; wp_set_object_terms( $new_step_id, $data->slug, CARTFLOWS_TAXONOMY_STEP_TYPE ); wcf()->logger->import_log( '(✓) Assigned existing term ' . $step_type_title . ' to the template ' . $new_step_id ); // Set Default page Layout. update_post_meta( $new_step_id, '_wp_page_template', 'cartflows-default' ); // Set type. update_post_meta( $new_step_id, 'wcf-step-type', $data->slug ); wcf()->logger->import_log( '(✓) Updated term ' . $data->name . ' to the post meta wcf-step-type.' ); // Set flow. wp_set_object_terms( $new_step_id, 'flow-' . $flow_id, CARTFLOWS_TAXONOMY_STEP_FLOW ); wcf()->logger->import_log( '(✓) Assigned flow step flow-' . $flow_id ); self::get_instance()->set_step_to_flow( $flow_id, $new_step_id, $step_type_title, $step_slug ); wcf()->logger->import_log( 'COMPLETE! Creating Blank STEP for Flow ' . $flow_id ); wcf()->logger->import_log( '------------------------------------' ); wp_send_json_success( $new_step_id ); } /** * Import Post Meta * * @since 1.0.0 * * @param integer $post_id Post ID. * @param array $response Post meta. * @return void */ public static function import_post_meta( $post_id, $response ) { $metadata = (array) $response['post_meta']; foreach ( $metadata as $meta_key => $meta_value ) { $meta_value = isset( $meta_value[0] ) ? $meta_value[0] : ''; if ( $meta_value ) { if ( is_serialized( $meta_value, true ) ) { $raw_data = maybe_unserialize( stripslashes( $meta_value ) ); } elseif ( is_array( $meta_value ) ) { $raw_data = json_decode( stripslashes( $meta_value ), true ); } else { $raw_data = $meta_value; } if ( '_elementor_data' === $meta_key ) { if ( is_array( $raw_data ) ) { $raw_data = wp_slash( wp_json_encode( $raw_data ) ); } else { $raw_data = wp_slash( $raw_data ); } } if ( '_elementor_data' !== $meta_key && '_elementor_draft' !== $meta_key && '_fl_builder_data' !== $meta_key && '_fl_builder_draft' !== $meta_key ) { if ( is_array( $raw_data ) ) { wcf()->logger->import_log( '(✓) Added post meta ' . $meta_key . ' | ' . wp_json_encode( $raw_data ) ); } else { if ( ! is_object( $raw_data ) ) { wcf()->logger->import_log( '(✓) Added post meta ' . $meta_key . ' | ' . $raw_data ); } } } update_post_meta( $post_id, $meta_key, $raw_data ); } } } /** * Import Template for Elementor * * @since 1.0.0 * * @param integer $post_id Post ID. * @param array $response Post meta. * @param array $page_build_data Page build data. * @return void */ public static function import_template_elementor( $post_id, $response, $page_build_data ) { if ( ! is_plugin_active( 'elementor/elementor.php' ) ) { $data = __( 'Elementor is not activated. Please activate plugin Elementor Page Builder to import the step.', 'cartflows' ); wcf()->logger->import_log( $data ); wp_send_json_error( $data ); } require_once CARTFLOWS_DIR . 'classes/batch-process/class-cartflows-importer-elementor.php'; wcf()->logger->import_log( '# Started "importing page builder data" for step ' . $post_id ); $obj = new \Elementor\TemplateLibrary\CartFlows_Importer_Elementor(); $obj->import_single_template( $post_id ); wcf()->logger->import_log( '# Complete "importing page builder data" for step ' . $post_id ); } /** * Supported post types * * @since 1.0.0 * * @return array Supported post types. */ public static function supported_post_types() { return apply_filters( 'cartflows_supported_post_types', array( CARTFLOWS_FLOW_POST_TYPE, ) ); } /** * Check supported post type * * @since 1.0.0 * * @param string $post_type Post type. * @return boolean Supported post type status. */ public static function is_supported_post( $post_type = '' ) { if ( in_array( $post_type, self::supported_post_types(), true ) ) { return true; } return false; } /** * Set steps to the flow * * @param integer $flow_id Flow ID. * @param integer $new_step_id New step ID. * @param string $step_title Flow Type. * @param string $step_slug Flow Type. */ public function set_step_to_flow( $flow_id, $new_step_id, $step_title, $step_slug ) { // Update steps for the current flow. $flow_steps = get_post_meta( $flow_id, 'wcf-steps', true ); if ( ! is_array( $flow_steps ) ) { $flow_steps = array(); } $flow_steps[] = array( 'id' => $new_step_id, 'title' => $step_title, 'type' => $step_slug, ); update_post_meta( $flow_id, 'wcf-steps', $flow_steps ); wcf()->logger->import_log( '(✓) Updated flow steps post meta key \'wcf-steps\' ' . wp_json_encode( $flow_steps ) ); } /** * Localize variables in admin * * @param array $vars variables. */ public function localize_vars( $vars ) { $ajax_actions = array( 'cf_step_import', 'cf_load_steps', 'cf_create_flow', 'cf_default_flow', 'cf_step_create_blank', 'cf_import_flow_step', ); foreach ( $ajax_actions as $action ) { $vars[ $action . '_nonce' ] = wp_create_nonce( str_replace( '_', '-', $action ) ); } return $vars; } /** * Ajax action to activate plugin */ public function activate_plugin() { if ( ! check_ajax_referer( 'cartflows_activate_plugin', 'security', false ) ) { wp_send_json_error( esc_html__( 'Action failed. Invalid Security Nonce.', 'cartflows' ) ); } if ( ! current_user_can( 'activate_plugins' ) ) { wp_send_json_error( array( 'success' => false, 'message' => __( 'User have not plugin install permissions.', 'cartflows' ), ) ); } $plugin_init = isset( $_POST['plugin_init'] ) ? sanitize_text_field( wp_unslash( $_POST['plugin_init'] ) ) : ''; $activate = activate_plugin( $plugin_init, '', false, true ); if ( is_wp_error( $activate ) ) { wp_send_json_error( array( 'success' => false, 'message' => $activate->get_error_message(), 'init' => $plugin_init, ) ); } wp_send_json_success( array( 'success' => true, 'message' => __( 'Plugin Successfully Activated', 'cartflows' ), 'init' => $plugin_init, ) ); } } /** * Initialize class object with 'get_instance()' method */ CartFlows_Importer::get_instance(); endif; class-cartflows-tracking.php000066600000015156152133015060012174 0ustar00get_google_analytics_settings( self::$google_analytics_settings ); } /** * Get ga settings. * * @param array $google_analytics_settings ga settings. */ public function get_google_analytics_settings( $google_analytics_settings ) { self::$google_analytics_settings = Cartflows_Helper::get_google_analytics_settings(); } /** * Render google tag framework. */ public function wcf_render_gtag() { $get_tracking_code = $this->wcf_ga_id(); if ( self::is_wcf_ga_tracking_on() ) { ?> cart->get_cart_contents_total(); $cart_items_count = WC()->cart->get_cart_contents_count(); $items = $order->get_items(); $cart_tax = $order->get_cart_tax(); $response['items'] = array(); $cart_contents = array(); $response = array( 'transaction_id' => $order_id, 'affiliation' => get_bloginfo( 'name' ), 'value' => $order->get_total(), 'currency' => $order->get_currency(), 'tax' => $order->get_cart_tax(), 'shipping' => $order->get_shipping_total(), 'coupon' => WC()->cart->get_coupons(), ); if ( empty( $offer_data ) ) { // Iterating through each WC_Order_Item_Product objects. foreach ( $items as $item => $value ) { $_product = wc_get_product( $value['product_id'] ); if ( ! $_product->is_type( 'variable' ) ) { $product_data = self::get_required_data( $_product ); } else { $variable_product = wc_get_product( $value['variation_id'] ); $product_data = self::get_required_data( $variable_product ); } array_push( $cart_contents, array( 'id' => $product_data['id'], 'name' => $product_data['name'], 'category' => wp_strip_all_tags( wc_get_product_category_list( $_product->get_id() ) ), 'price' => $product_data['price'], 'quantity' => $value['quantity'], ) ); } } else { array_push( $cart_contents, array( 'id' => $offer_data['id'], 'name' => $offer_data['name'], 'quantity' => $offer_data['qty'], 'price' => $offer_data['price'], ) ); } $response['items'] = $cart_contents; // Prepare the json data to send it to google. return $response; } /** * Prepare Ecommerce data for GA response. * * @return array */ public static function get_ga_items_list() { $items = WC()->cart->get_cart(); $items_data = array(); foreach ( $items as $item => $value ) { $_product = wc_get_product( $value['product_id'] ); if ( ! $_product->is_type( 'variable' ) ) { $product_data = self::get_required_data( $_product ); } else { $variable_product = wc_get_product( $value['variation_id'] ); $product_data = self::get_required_data( $variable_product ); } array_push( $items_data, array( 'id' => $product_data['id'], 'name' => $product_data['name'], 'category' => wp_strip_all_tags( wc_get_product_category_list( $_product->get_id() ) ), 'price' => $product_data['price'], 'quantity' => $value['quantity'], ) ); } return $items_data; } /** * Check tracking on. */ public static function is_wcf_ga_tracking_on() { $is_enabled = false; if ( 'disable' === self::$google_analytics_settings['enable_google_analytics'] ) { $is_enabled = false; } else { $is_enabled = true; } return apply_filters( 'cartflows_google_analytics_tracking_enabled', $is_enabled ); } /** * Check purchase event enable. */ public static function wcf_track_ga_purchase() { $google_analytics_settings = Cartflows_Helper::get_google_analytics_settings(); $wcf_track_ga_purchase = $google_analytics_settings['enable_purchase_event']; if ( is_array( $google_analytics_settings ) && ! empty( $google_analytics_settings ) && 'enable' === $wcf_track_ga_purchase ) { return true; } return false; } /** * Get product data. * * @param object $_product product data. */ public static function get_required_data( $_product ) { $data = array( 'id' => $_product->get_id(), 'name' => $_product->get_name(), 'price' => $_product->get_price(), ); return $data; } /** * Retreive google anlytics ID. */ public function wcf_ga_id() { $get_ga_id = self::$google_analytics_settings['google_analytics_id']; return empty( $get_ga_id ) ? false : $get_ga_id; } } /** * Kicking this off by calling 'get_instance()' method */ Cartflows_Tracking::get_instance(); class-cartflows-compatibility.php000066600000023213152133015060013234 0ustar00load_files(); // Override post meta. add_action( 'wp', array( $this, 'override_meta' ), 0 ); add_action( 'wp_enqueue_scripts', array( $this, 'load_fontawesome' ), 10000 ); } /** * Load page builder compatibility files */ public function load_files() { if ( class_exists( '\Elementor\Plugin' ) ) { require_once CARTFLOWS_DIR . 'classes/class-cartflows-elementor-compatibility.php'; } if ( $this->is_divi_enabled() ) { require_once CARTFLOWS_DIR . 'classes/class-cartflows-divi-compatibility.php'; } if ( $this->is_bb_enabled() ) { require_once CARTFLOWS_DIR . 'classes/class-cartflows-bb-compatibility.php'; } if ( class_exists( 'TCB_Post' ) ) { require_once CARTFLOWS_DIR . 'classes/class-cartflows-thrive-compatibility.php'; } if ( defined( 'LEARNDASH_VERSION' ) ) { require_once CARTFLOWS_DIR . 'classes/class-cartflows-learndash-compatibility.php'; } } /** * Check if it is beaver builder enabled. * * @since 1.1.4 */ public function is_bb_enabled() { if ( class_exists( 'FLBuilderModel' ) ) { return true; } return false; } /** * Check if elementor preview mode is on. */ public function is_elementor_preview_mode() { if ( class_exists( '\Elementor\Plugin' ) ) { if ( \Elementor\Plugin::$instance->preview->is_preview_mode() ) { return true; } } return false; } /** * Get Current Theme. */ public function get_current_theme() { $theme_name = ''; $theme = wp_get_theme(); if ( isset( $theme->parent_theme ) && '' != $theme->parent_theme || null != $theme->parent_theme ) { $theme_name = $theme->parent_theme; } else { $theme_name = $theme->name; } return $theme_name; } /** * Check if it is beaver builder preview mode */ public function is_bb_preview_mode() { if ( class_exists( 'FLBuilderModel' ) ) { if ( FLBuilderModel::is_builder_active() ) { return true; } else { return false; } } return false; } /** * Check for page builder preview mode. */ public function is_page_builder_preview() { if ( $this->is_elementor_preview_mode() || $this->is_bb_preview_mode() || $this->is_divi_builder_preview() ) { return true; } return false; } /** * Check if divi builder enabled for post id. */ public function is_divi_builder_preview() { if ( isset( $_GET['et_fb'] ) && '1' === $_GET['et_fb'] ) { //phpcs:ignore return true; } return false; } /** * Check if divi builder enabled for post id. * * @param int $post_id post id. */ public function is_divi_builder_enabled( $post_id ) { if ( function_exists( 'et_pb_is_pagebuilder_used' ) && et_pb_is_pagebuilder_used( $post_id ) ) { return true; } return false; } /** * Check if compatibility theme enabled. */ public function is_compatibility_theme_enabled() { $theme = wp_get_theme(); $is_compatibility = false; if ( $this->is_divi_enabled( $theme ) || $this->is_flatsome_enabled( $theme ) || $this->is_pro_enabled( $theme ) || $this->is_kallyas_enabled( $theme ) ) { $is_compatibility = true; } return apply_filters( 'cartflows_is_compatibility_theme', $is_compatibility ); } /** * Check if pro theme enabled for post id. * * @param object $theme theme data. * @return boolean */ public function is_pro_enabled( $theme = false ) { if ( ! $theme ) { $theme = wp_get_theme(); } if ( 'Pro' == $theme->name ) { return true; } return false; } /** * Check if kallyas theme enabled for post id. * * @param object $theme theme data. * @return boolean */ public function is_kallyas_enabled( $theme = false ) { if ( ! $theme ) { $theme = wp_get_theme(); } if ( 'Kallyas' == $theme->name ) { return true; } return false; } /** * Check if divi builder enabled for post id. * * @param object $theme theme data. * @return boolean */ public function is_divi_enabled( $theme = false ) { if ( ! $theme ) { $theme = wp_get_theme(); } if ( 'Divi' == $theme->name || 'Divi' == $theme->parent_theme || 'Extra' == $theme->name || 'Extra' == $theme->parent_theme ) { return true; } return false; } /** * Check if Divi theme is install status. * * @return boolean */ public function is_divi_theme_installed() { foreach ( (array) wp_get_themes() as $theme_dir => $theme ) { if ( 'Divi' == $theme->name || 'Divi' == $theme->parent_theme || 'Extra' == $theme->name || 'Extra' == $theme->parent_theme ) { return true; } } return false; } /** * Check if Flatsome enabled for post id. * * @param object $theme theme data. * @return boolean */ public function is_flatsome_enabled( $theme = false ) { if ( ! $theme ) { $theme = wp_get_theme(); } if ( 'Flatsome' == $theme->name || 'Flatsome' == $theme->parent_theme ) { return true; } return false; } /** * Check if The7 enabled for post id. * * @param object $theme theme data. * @return boolean */ public function is_the_seven_enabled( $theme = false ) { if ( ! $theme ) { $theme = wp_get_theme(); } if ( 'The7' == $theme->name || 'The7' == $theme->parent_theme ) { return true; } return false; } /** * Check if OceanWp enabled for post id. * * @param object $theme theme data. * @return boolean */ public function is_oceanwp_enabled( $theme = false ) { if ( ! $theme ) { $theme = wp_get_theme(); } if ( 'OceanWP' == $theme->name || 'OceanWP' == $theme->parent_theme ) { return true; } return false; } /** * Check for thrive architect edit page. * * @param int $post_id post id. */ public function is_thrive_edit_page( $post_id ) { if ( true === $this->is_thrive_builder_page( $post_id ) ) { return true; } else { return false; } } /** * Check if the page being rendered is the main ID on the editor page. * * @since 1.0.0 * @param String $post_id Post ID which is to be rendered. * @return boolean True if current if is being rendered is not being edited. */ private function is_thrive_builder_page( $post_id ) { $tve = ( isset( $_GET['tve'] ) && 'true' == $_GET['tve'] ) ? true : false; //phpcs:ignore $post = isset( $_GET['post'] ) ? intval( wp_unslash( $_GET['post'] ) ) : false; //phpcs:ignore return ( true == $tve && $post_id !== $post ); } /** * Overwrite meta for page */ public function override_meta() { // don't override meta for `elementor_library` post type. if ( 'elementor_library' == get_post_type() ) { return; } if ( ! is_singular() ) { return; } global $post; $post_id = $post->ID; $post_type = get_post_type(); if ( 'cartflows_step' == $post_type && ( $this->is_elementor_preview_mode() || $this->is_bb_preview_mode() || $this->is_thrive_edit_page( $post_id ) || $this->is_divi_builder_enabled( $post_id ) ) ) { if ( '' == $post->post_content ) { $this->overwrite_template( $post_id ); } } } /** * Assign cartflow canvas template to page. * * @param int $post_id post ID. */ public function overwrite_template( $post_id ) { $template = 'cartflows-canvas'; $key = '_wp_page_template'; $record_exists = get_post_meta( $post_id, $key, true ); if ( 'cartflows-canvas' == $record_exists ) { return; } // As elementor doesn't allow update post meta using update_post_meta, run wpdb query to update post meta. if ( class_exists( '\Elementor\Plugin' ) ) { global $wpdb; if ( '' == $record_exists || ! $record_exists ) { $wpdb->insert( $wpdb->prefix . 'postmeta', array( 'post_id' => $post_id, 'meta_key' => $key,//phpcs:ignore 'meta_value' => $template, //phpcs:ignore ) );// db call ok;. // alternative query to above query. // $table = $wpdb->prefix . 'postmeta'; // $wpdb->query($wpdb->prepare( "INSERT INTO { $table } ( `post_id`, `meta_key`, 'meta_value' ) // VALUES ( '$post_id', '$key', '$template' )" ) );// db call ok; no-cache ok. } else { $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->postmeta} SET meta_value = %s WHERE meta_key = %s AND post_id = %s;", $template, $key, $post_id ) ); // db call ok; no-cache ok. } } else { update_post_meta( $post_id, $key, $template ); } } /** * Load font awesome style from oceanwp on checkout page. */ public function load_fontawesome() { $theme = get_template(); if ( 'oceanwp' == strtolower( $theme ) && wcf()->utils->is_step_post_type() ) { $load_fa = apply_filters( 'cartflows_maybe_load_font_awesome', true ); if ( $load_fa ) { wp_enqueue_style( 'font-awesome', OCEANWP_CSS_DIR_URI . 'third/font-awesome.min.css', false );//phpcs:ignore } $custom_css = ' #oceanwp-cart-sidebar-wrap, #owp-qv-wrap{ display: none; }'; wp_add_inline_style( 'wcf-frontend-global', $custom_css ); } } } } Cartflows_Compatibility::get_instance();