// Retrieve ALL product posts $all_products = get_posts(array('post_type' => $this->post_type_key(), 'posts_per_page' => -1, 'post_status' => 'any')); // Begin an array of product titles // as served by the Etsy API $all_product_titles = array(); // Loop through each product from Etsy foreach ($paged_response->results as $product) { // Add the product title to our array $all_product_titles[] = $product->title; } // Loop through each product in our CPT foreach ($all_products as $this_product) { // Set our in_array outcome to a variable $in_product_array = in_array($this_product->post_title, $all_product_titles); // Set the default post status to publish $post_status = apply_filters('etsy_importer_default_post_status', 'publish'); // Check to see our post is in our product array. // If not, set it to draft mode. if (!$in_product_array) { $post_status = apply_filters('etsy_importer_updated_post_status', 'draft'); } // If it is not in the response, set it to draft $update_post_args = array('ID' => $this_product->ID, 'post_status' => $post_status); // Update our post settings wp_update_post(apply_filters('etsy_importer_updated_post_args', $update_post_args)); } } } // Instantiate the class Etsy_Importer::engage();
/** * Wrapper function around cmb2_get_option * @since 0.1.0 * @param string $key Options array key * @return mixed Option value */ function etsy_options_get_option($key = '') { return cmb2_get_option(Etsy_Importer::engage()->admin->key, $key); }