/**
  * Update the less variables on the DB and recompile the CSS
  *
  * @param array $variables
  * @param boolean $resetting are we resetting or updating variables?
  */
 private function update_variables_and_compile_css(array $variables, $resetting)
 {
     $no_parse_errors = $this->invalidate_cache($variables, true);
     if ($no_parse_errors) {
         $this->db_adapter->write_data_to_config(Ai1ec_Lessphp_Controller::DB_KEY_FOR_LESS_VARIABLES, $variables);
         $message = Ai1ec_Helper_Factory::create_admin_message_instance(sprintf('<p>' . __("Theme options were updated successfully. <a href='%s'>Visit site</a>", AI1EC_PLUGIN_NAME) . '</p>', get_site_url()));
         if (true === $resetting) {
             $message = Ai1ec_Helper_Factory::create_admin_message_instance(sprintf('<p>' . __("Theme options were successfully reset to their default values. <a href='%s'>Visit site</a>", AI1EC_PLUGIN_NAME) . '</p>', get_site_url()));
         }
         $message->set_message_type('updated');
         $this->admin_notices_helper->add_renderable_children($message);
     }
 }
 /**
  * Create a duplicate from a posts' instance
  */
 function duplicate_post_create_duplicate($post, $status = '')
 {
     $new_post_author = $this->duplicate_post_get_current_user();
     $new_post_status = $status;
     if (empty($new_post_status)) {
         $new_post_status = $post->post_status;
     }
     $new_post_status = $this->get_new_post_status($new_post_status);
     $new_post = array('menu_order' => $post->menu_order, 'comment_status' => $post->comment_status, 'ping_status' => $post->ping_status, 'pinged' => $post->pinged, 'post_author' => $new_post_author->ID, 'post_content' => $post->post_content, 'post_date' => $post->post_date, 'post_date_gmt' => get_gmt_from_date($post->post_date), 'post_excerpt' => $post->post_excerpt, 'post_parent' => $post->post_parent, 'post_password' => $post->post_password, 'post_status' => $new_post_status, 'post_title' => $post->post_title, 'post_type' => $post->post_type, 'to_ping' => $post->to_ping);
     $new_post_id = wp_insert_post($new_post);
     $edit_event_url = esc_attr(admin_url("post.php?post={$new_post_id}&action=edit"));
     $message = Ai1ec_Helper_Factory::create_admin_message_instance(sprintf(__('<p>The event <strong>%s</strong> was cloned succesfully. <a href="%s">Edit cloned event</a></p>', AI1EC_PLUGIN_NAME), $post->post_title, $edit_event_url));
     $message->set_message_type('updated');
     $this->admin_notice_helper->add_renderable_children($message);
     // If you have written a plugin which uses non-WP database tables to save
     // information about a post you can hook this action to dupe that data.
     if ($post->post_type == 'page' || function_exists('is_post_type_hierarchical') && is_post_type_hierarchical($post->post_type)) {
         do_action('dp_duplicate_page', $new_post_id, $post);
     } else {
         do_action('dp_duplicate_post', $new_post_id, $post);
     }
     if ('ai1ec_event' === $post->post_type) {
         try {
             $old_event = new Ai1ec_Event($post->ID);
             $old_event->post_id = $new_post_id;
             unset($old_event->post);
             $old_event->save();
         } catch (Ai1ec_Event_Not_Found $exception) {
             /* ignore */
         }
     }
     delete_post_meta($new_post_id, '_dp_original');
     add_post_meta($new_post_id, '_dp_original', $post->ID);
     // If the copy gets immediately published, we have to set a proper slug.
     if ($new_post_status == 'publish' || $new_post_status == 'future') {
         $post_name = wp_unique_post_slug($post->post_name, $new_post_id, $new_post_status, $post->post_type, $post->post_parent);
         $new_post = array();
         $new_post['ID'] = $new_post_id;
         $new_post['post_name'] = $post_name;
         // Update the post into the database
         wp_update_post($new_post);
     }
     return $new_post_id;
 }