/**
  * HTML OUTPUT.
  *
  * @since NHP_Options 1.0
  */
 function _options_page_html()
 {
     echo '<div class="wrap">';
     echo '<div id="' . $this->args['page_icon'] . '" class="icon32"><br/></div>';
     echo '<h2 id="nhp-opts-heading">' . get_admin_page_title() . '</h2>';
     echo isset($this->args['intro_text']) ? $this->args['intro_text'] : '';
     do_action('nhp-opts-page-before-form');
     do_action('nhp-opts-page-before-form-' . $this->args['opt_name']);
     echo '<form method="post" action="options.php" enctype="multipart/form-data" id="nhp-opts-form-wrapper">';
     settings_fields($this->args['opt_name'] . '_group');
     if (isset($_GET['tab'])) {
         echo '<input type="hidden" id="last_tab" name="' . $this->args['opt_name'] . '[last_tab]" value="' . $_GET['tab'] . '" />';
     } else {
         echo '<input type="hidden" id="last_tab" name="' . $this->args['opt_name'] . '[last_tab]" value="0" />';
     }
     echo '<div id="nhp-opts-header">';
     echo '<input type="submit" name="submit" value="' . __('Save Changes', 'nhp-opts') . '" class="button-primary" />';
     //echo '<input type="submit" name="' . $this->args['opt_name'] . '[defaults]" value="' . __('Reset to Defaults', 'nhp-opts') . '" class="button-secondary" />';
     echo '<div class="clear"></div><!--clearfix-->';
     echo '</div>';
     if (isset($_GET['settings-updated']) && $_GET['settings-updated'] == 'true' && get_transient('nhp-opts-saved') == '1') {
         if (isset($this->options['imported']) && $this->options['imported'] == 1) {
             echo '<div id="nhp-opts-imported">' . __('<strong>Settings Imported!</strong>', 'nhp-opts') . '</div>';
         } else {
             echo '<div id="nhp-opts-save">' . __('<strong>Settings Saved!</strong>', 'nhp-opts') . '</div>';
         }
         delete_transient('nhp-opts-saved');
     }
     echo '<div id="nhp-opts-save-warn">' . __('<strong>Settings have changed!, you should save them!</strong>', 'nhp-opts') . '</div>';
     echo '<div id="nhp-opts-field-errors">' . __('<strong><span></span> error(s) were found!</strong>', 'nhp-opts') . '</div>';
     echo '<div id="nhp-opts-field-warnings">' . __('<strong><span></span> warning(s) were found!</strong>', 'nhp-opts') . '</div>';
     echo '<div class="clear"></div><!--clearfix-->';
     echo '<div id="nhp-opts-sidebar">';
     echo '<ul id="snp-nhp-opts-group-menu">';
     foreach ($this->sections as $k => $section) {
         $icon = !isset($section['icon']) ? '<img src="' . $this->url . 'img/glyphicons/glyphicons_019_cogwheel.png" /> ' : '<img src="' . $section['icon'] . '" /> ';
         echo '<li id="' . $k . '_snp_section_group_li" class="snp-nhp-opts-group-tab-link-li">';
         echo '<a href="javascript:void(0);" id="' . $k . '_snp_section_group_li_a" class="snp-nhp-opts-group-tab-link-a" data-rel="' . $k . '">' . $icon . $section['title'] . '</a>';
         echo '</li>';
     }
     echo '<li class="divide">&nbsp;</li>';
     do_action('nhp-opts-after-section-menu-items', $this);
     do_action('nhp-opts-after-section-menu-items-' . $this->args['opt_name'], $this);
     if (true === $this->args['show_import_export']) {
         echo '<li id="import_export_default_section_group_li" class="snp-nhp-opts-group-tab-link-li">';
         echo '<a href="javascript:void(0);" id="import_export_default_section_group_li_a" class="snp-nhp-opts-group-tab-link-a" data-rel="import_export_default"><img src="' . $this->url . 'img/glyphicons/glyphicons_082_roundabout.png" /> ' . __('Import / Export', 'nhp-opts') . '</a>';
         echo '</li>';
         echo '<li class="divide">&nbsp;</li>';
     }
     //if
     foreach ((array) $this->extra_tabs as $k => $tab) {
         $icon = !isset($tab['icon']) ? '<img src="' . $this->url . 'img/glyphicons/glyphicons_019_cogwheel.png" /> ' : '<img src="' . $tab['icon'] . '" /> ';
         echo '<li id="' . $k . '_snp_section_group_li" class="snp-nhp-opts-group-tab-link-li">';
         echo '<a href="javascript:void(0);" id="' . $k . '_snp_section_group_li_a" class="snp-nhp-opts-group-tab-link-a custom-tab" data-rel="' . $k . '">' . $icon . $tab['title'] . '</a>';
         echo '</li>';
     }
     if (true === $this->args['dev_mode']) {
         echo '<li id="dev_mode_default_section_group_li" class="snp-nhp-opts-group-tab-link-li">';
         echo '<a href="javascript:void(0);" id="dev_mode_default_section_group_li_a" class="snp-nhp-opts-group-tab-link-a custom-tab" data-rel="dev_mode_default"><img src="' . $this->url . 'img/glyphicons/glyphicons_195_circle_info.png" /> ' . __('Dev Mode Info', 'nhp-opts') . '</a>';
         echo '</li>';
     }
     //if
     echo '</ul>';
     echo '</div>';
     echo '<div id="nhp-opts-main">';
     foreach ($this->sections as $k => $section) {
         echo '<div id="' . $k . '_snp_section_group' . '" class="snp-nhp-opts-group-tab">';
         do_settings_sections($k . '_snp_section_group');
         echo '</div>';
     }
     if (true === $this->args['show_import_export']) {
         echo '<div id="import_export_default_section_group' . '" class="snp-nhp-opts-group-tab">';
         echo '<h3>' . __('Import / Export Options', 'nhp-opts') . '</h3>';
         echo '<h4>' . __('Import Options', 'nhp-opts') . '</h4>';
         echo '<p><a href="javascript:void(0);" id="nhp-opts-import-code-button" class="button-secondary">Import from file</a> <a href="javascript:void(0);" id="nhp-opts-import-link-button" class="button-secondary">Import from URL</a></p>';
         echo '<div id="nhp-opts-import-code-wrapper">';
         echo '<div class="snp-nhp-opts-section-desc">';
         echo '<p class="description" id="import-code-description">' . apply_filters('nhp-opts-import-file-description', __('Input your backup file below and hit Import to restore your sites options from a backup.', 'nhp-opts')) . '</p>';
         echo '</div>';
         echo '<textarea id="import-code-value" name="' . $this->args['opt_name'] . '[import_code]" class="large-text" rows="8"></textarea>';
         echo '</div>';
         echo '<div id="nhp-opts-import-link-wrapper">';
         echo '<div class="snp-nhp-opts-section-desc">';
         echo '<p class="description" id="import-link-description">' . apply_filters('nhp-opts-import-link-description', __('Input the URL to another sites options set and hit Import to load the options from that site.', 'nhp-opts')) . '</p>';
         echo '</div>';
         echo '<input type="text" id="import-link-value" name="' . $this->args['opt_name'] . '[import_link]" class="large-text" value="" />';
         echo '</div>';
         echo '<p id="nhp-opts-import-action"><input type="submit" id="nhp-opts-import" name="' . $this->args['opt_name'] . '[import]" class="button-primary" value="' . __('Import', 'nhp-opts') . '"> <span>' . apply_filters('nhp-opts-import-warning', __('WARNING! This will overwrite any existing options, please proceed with caution!', 'nhp-opts')) . '</span></p>';
         echo '<div id="import_divide"></div>';
         echo '<h4>' . __('Export Options', 'nhp-opts') . '</h4>';
         echo '<div class="snp-nhp-opts-section-desc">';
         echo '<p class="description">' . apply_filters('nhp-opts-backup-description', __('Here you can copy/download your themes current option settings. Keep this safe as you can use it as a backup should anything go wrong. Or you can use it to restore your settings on this site (or any other site). You also have the handy option to copy the link to yours sites settings. Which you can then use to duplicate on another site', 'nhp-opts')) . '</p>';
         echo '</div>';
         echo '<p><a href="javascript:void(0);" id="nhp-opts-export-code-copy" class="button-secondary">Copy</a> <a href="' . snp_add_query_arg(array('feed' => 'nhpopts', 'action' => 'download_options', 'secret' => md5(AUTH_KEY . SECURE_AUTH_KEY), 'option' => $this->args['opt_name']), site_url()) . '" id="nhp-opts-export-code-dl" class="button-primary">Download</a> <a href="javascript:void(0);" id="nhp-opts-export-link" class="button-secondary">Copy Link</a></p>';
         $backup_options = $this->options;
         $backup_options['nhp-opts-backup'] = '1';
         $encoded_options = '###' . serialize($backup_options) . '###';
         echo '<textarea class="large-text" id="nhp-opts-export-code" rows="8">';
         print_r($encoded_options);
         echo '</textarea>';
         echo '<input type="text" class="large-text" id="nhp-opts-export-link-value" value="' . snp_add_query_arg(array('feed' => 'nhpopts', 'secret' => md5(AUTH_KEY . SECURE_AUTH_KEY), 'option' => $this->args['opt_name']), site_url()) . '" />';
         echo '</div>';
     }
     foreach ((array) $this->extra_tabs as $k => $tab) {
         echo '<div id="' . $k . '_snp_section_group' . '" class="snp-nhp-opts-group-tab">';
         echo '<h3>' . $tab['title'] . '</h3>';
         echo $tab['content'];
         echo '</div>';
     }
     if (true === $this->args['dev_mode']) {
         echo '<div id="dev_mode_default_section_group' . '" class="snp-nhp-opts-group-tab">';
         echo '<h3>' . __('Dev Mode Info', 'nhp-opts') . '</h3>';
         echo '<div class="snp-nhp-opts-section-desc">';
         echo '<textarea class="large-text" rows="24">' . print_r($this, true) . '</textarea>';
         echo '</div>';
         echo '</div>';
     }
     do_action('nhp-opts-after-section-items', $this);
     do_action('nhp-opts-after-section-items-' . $this->args['opt_name'], $this);
     echo '<div class="clear"></div><!--clearfix-->';
     echo '</div>';
     echo '<div class="clear"></div><!--clearfix-->';
     echo '<div id="nhp-opts-footer">';
     if (isset($this->args['share_icons'])) {
         echo '<div id="nhp-opts-share">';
         foreach ($this->args['share_icons'] as $link) {
             echo '<a href="' . $link['link'] . '" title="' . $link['title'] . '" target="_blank"><img src="' . $link['img'] . '"/></a>';
         }
         echo '</div>';
     }
     echo '<input type="submit" name="submit" value="' . __('Save Changes', 'nhp-opts') . '" class="button-primary" />';
     //echo '<input type="submit" name="' . $this->args['opt_name'] . '[defaults]" value="' . __('Reset to Defaults', 'nhp-opts') . '" class="button-secondary" />';
     echo '<div class="clear"></div><!--clearfix-->';
     echo '</div>';
     echo '</form>';
     do_action('nhp-opts-page-after-form');
     do_action('nhp-opts-page-after-form-' . $this->args['opt_name']);
     echo '<div class="clear"></div><!--clearfix-->';
     echo '</div><!--wrap-->';
 }
Example #2
0
function snp_clone_form()
{
    if (isset($_GET['nonce']) && isset($_GET['post_id'])) {
        $nonce = $_GET['nonce'];
        $post_id = $_GET['post_id'];
    } else {
        $nonce = $_POST['nonce'];
        $post_id = $_POST['post_id'];
    }
    if (!isset($nonce) || !wp_verify_nonce($nonce, 'snp_nonce')) {
        return;
    }
    if (!current_user_can('edit_post', $post_id) || !current_user_can('edit_page', $post_id)) {
        return;
    }
    $old_post = get_post($post_id);
    $new_post = array('post_status' => 'draft', 'menu_order' => $old_post->menu_order, 'post_type' => $old_post->post_type, 'comment_status' => $old_post->comment_status, 'ping_status' => $old_post->ping_status, 'pinged' => $old_post->pinged, 'post_author' => $old_post->post_author, 'post_category' => $old_post->post_category, 'post_content' => $old_post->post_content, 'post_excerpt' => $old_post->post_excerpt, 'post_name' => $old_post->post_name, 'post_parent' => $old_post->post_parent, 'post_password' => $old_post->post_password, 'post_title' => $old_post->post_title . ' - ' . __('Copy', 'arscode') . '', 'post_type' => $old_post->post_type, 'tags_input' => $old_post->tags_input, 'to_ping' => $old_post->to_ping, 'tax_input' => $old_post->tax_input);
    $new_post_id = wp_insert_post($new_post);
    $post_meta_keys = get_post_custom_keys($post_id);
    if (empty($post_meta_keys)) {
        return;
    }
    foreach ($post_meta_keys as $meta_key) {
        $meta_values = get_post_custom_values($meta_key, $post_id);
        foreach ($meta_values as $meta_value) {
            if (!in_array($meta_key, array('snp_views', 'snp_conversions'))) {
                $meta_value = maybe_unserialize($meta_value);
                add_post_meta($new_post_id, $meta_key, $meta_value);
            }
        }
    }
    $redirect = snp_add_query_arg(array('action' => 'edit', 'post' => $new_post_id, 'nonce' => null), 'post.php');
    wp_redirect($redirect);
    exit;
}