Пример #1
0
function wppb_load_files()
{
    // Bail out if in admin panel
    if (is_admin()) {
        return;
    }
    // Make sure both sidebars are set - UGLY IF STATEMENT IS A HACK TO PREVENT MUCK UPS WHEN NO SETTINGS ARE PRESENT YET - IE: WHEN INSTALLING THE THEME
    if (get_option(WPPB_SETTINGS)) {
        $wppb_options = get_option(WPPB_SETTINGS);
        $wppb_options['show_widget1'] = 'on';
        $wppb_options['show_widget2'] = 'on';
        $wppb_options['name_widget1'] = 'Sidebar 1';
        $wppb_options['before_widget1'] = '<div id="%1$s" class="widget %2$s">';
        $wppb_options['after_widget1'] = '</div>';
        $wppb_options['before_title1'] = '<h3>';
        $wppb_options['after_title1'] = '</h3>';
        $wppb_options['name_widget2'] = 'Sidebar 2';
        $wppb_options['before_widget2'] = '<div id="%1$s" class="widget %2$s">';
        $wppb_options['after_widget2'] = '</div>';
        $wppb_options['before_title2'] = '<h3>';
        $wppb_options['after_title2'] = '</h3>';
        update_option(WPPB_SETTINGS, $wppb_options);
    }
    // Security check for image uploads
    if ($_FILES) {
        require_once ABSPATH . 'wp-admin/includes/file.php';
        // Load file necessary for processing image file on front-end
        require_once ABSPATH . 'wp-includes/pluggable.php';
        // Load file necessary for processing image file on front-end
        wppb_image_upload_form_check();
    }
}
Пример #2
0
/**
 * Create the options page
 * @since 0.1
 */
function upload_images_do_page()
{
    // Security checks
    wppb_image_upload_form_check();
    ?>
<div class="wrap">
	<?php 
    // Create screen icon by heading
    screen_icon('wppb-icon');
    echo '<h2>' . __('Upload images') . '</h2>';
    // "Options Saved" message as displayed at top of page on clicking "Save"
    if (isset($_REQUEST['updated'])) {
        echo '<div class="updated fade"><p><strong>' . __('Options saved') . '</strong></p></div>';
    }
    ?>
	<h3><?php 
    _e('Upload images here', 'wppb_lang');
    ?>
</h3>

	<form method="post" action="" enctype="multipart/form-data">
		<input type="hidden" name="MAX_FILE_SIZE" value="3000000" />
		<?php 
    wp_nonce_field('wppb_upload_image', 'image');
    ?>
		<p>
			<?php 
    _e('Note: This section is for adding and deleting images used in your theme only. For image uploads in your posts/pages please visit the ', 'wppb_lang');
    ?>
			<a href="<?php 
    echo admin_url();
    ?>
upload.php"><?php 
    _e('Media uploader', 'wppb_lang');
    ?>
</a>
		</p>
		<?php 
    wppb_image_upload_form_fields();
    ?>
		<ol>
			<?php 
    wppb_display_images();
    ?>
		</ol>
	</form>
</div>

<?php 
}