/** * Kicking this off with the 'widgets_init' hook */ function layers_widgets_init() { global $layers_widgets; $layers_widgets = new Layers_Widgets(); $layers_widgets->init(); }
/** * Ajax Duplication * * This function takes a page, generates export cod and creates a duplicate */ public function do_ajax_duplicate() { if (!check_ajax_referer('layers-migrator-duplicate', 'nonce', false)) { die('You threw a Nonce exception'); } // Nonce // We need a page title and post ID for this to work if (!isset($_POST['post_title']) || !isset($_POST['post_id'])) { return; } $pageid = layers_create_builder_page(esc_attr($_POST['post_title'] . ' ' . __('(Copy)', 'layerswp'))); // Create the page sidebar on the fly Layers_Widgets::register_builder_sidebar($pageid); // Set the page ID $import_data['post_id'] = $pageid; $post = get_post($_POST['post_id']); // Set the Widget Data for import $import_data['widget_data'] = $this->export_data($post); // Run data import $import_progress = $this->import($import_data); $results = array('post_id' => $pageid, 'data_report' => $import_progress, 'page_location' => admin_url() . 'post.php?post=' . $pageid . '&action=edit&message=1'); do_action('layers_backup_sidebars_widgets'); die(json_encode($results)); }