コード例 #1
0
ファイル: actions.admin.php プロジェクト: rohans/tradeinbooks
function pagelines_ajax_callback()
{
    global $wpdb;
    // this is how you get access to the database
    if ($_POST['type']) {
        $save_type = $_POST['type'];
    } else {
        $save_type = null;
    }
    //Uploads
    if ($save_type == 'upload') {
        $clickedID = $_POST['data'];
        // Acts as the name
        $filename = $_FILES[$clickedID];
        $filename['name'] = preg_replace('/[^a-zA-Z0-9._\\-]/', '', $filename['name']);
        $override['test_form'] = false;
        $override['action'] = 'wp_handle_upload';
        $uploaded_file = wp_handle_upload($filename, $override);
        $upload_tracking[] = $clickedID;
        pagelines_update_option($clickedID, $uploaded_file['url']);
        if (!empty($uploaded_file['error'])) {
            echo 'Upload Error: ' . $uploaded_file['error'];
        } else {
            echo $uploaded_file['url'];
        }
        // Is the Response
    } elseif ($save_type == 'image_reset') {
        $id = $_POST['data'];
        // Acts as the name
        pagelines_update_option($id, null);
    }
    die;
}
コード例 #2
0
	function pagelines_ajax_callback() {
		global $wpdb; // this is how you get access to the database
	
		if($_POST['type']){
			$save_type = $_POST['type'];
		}else $save_type = null;
	
		//Uploads
		if( $save_type == 'upload' ) {
		$clickedID = $_POST['data']; // Acts as the name

		$arr_file_type = wp_check_filetype( basename( $_FILES[$clickedID]['name']));
		$uploaded_file_type = $arr_file_type['type'];
		// Set an array containing a list of acceptable formats
		$allowed_file_types = array( 'image/jpg','image/jpeg','image/gif','image/png', 'image/x-icon' );
		if( in_array( $uploaded_file_type, $allowed_file_types ) ) {

			$filename = $_FILES[$clickedID];
			$filename['name'] = preg_replace( '/[^a-zA-Z0-9._\-]/', '', $filename['name'] ); 
			$override['test_form'] = false;
			$override['action'] = 'wp_handle_upload';    
			$uploaded_file = wp_handle_upload( $filename, $override );
			$upload_tracking[] = $clickedID;
			pagelines_update_option( $clickedID , $uploaded_file['url'] );

			$name = 'PageLines- ' .addslashes( $filename['name'] );

			$attachment = array(
                                'post_mime_type' => $uploaded_file_type,
                                'post_title' => $name,
                                'post_content' => '',
                                'post_status' => 'inherit'
                        );

			$attach_id = wp_insert_attachment( $attachment, $uploaded_file['file'] );
			$attach_data = wp_generate_attachment_metadata( $attach_id, $uploaded_file['file'] );
			wp_update_attachment_metadata( $attach_id,  $attach_data );
			} else {
				$uploaded_file['error'] = 'Unsupported file type!';
		}
		if( !empty( $uploaded_file['error'] ) ) {
			echo 'Upload Error: ' . $uploaded_file['error'];
		} else {
			echo $uploaded_file['url']; // Is the Response
			}
		}
		elseif( $save_type == 'image_reset' ){
			$id = $_POST['data']; // Acts as the name
			pagelines_update_option( $id, null );
		}
		die();
	}
コード例 #3
0
    function __construct( $theme, $version ){
    	$bad_users = array( 'admin', 'root', 'test', 'testing', '');
    	$this->theme  = $theme;
 		$this->version = $version;
		$this->username = get_pagelines_option( 'lp_username' );
		$this->password = get_pagelines_option( 'lp_password' );
		if ( in_array( strtolower( $this->username ), $bad_users ) ) {
			pagelines_update_option( 'lp_username', '' );
			pagelines_update_option( 'lp_password', '' );
			$this->username = '';
			$this->password = '';
			$this->pagelines_clear_update_transient();
		}
    }
コード例 #4
0
/**
*
* @TODO do
*
*/
function pagelines_process_reset_options($option_array = null)
{
    if (isset($_POST['pl_reset_settings']) && current_user_can('edit_themes')) {
        do_action('extend_flush');
        if (isset($_POST['the_pl_setting']) && !isset($_POST['reset_callback'])) {
            update_option($_POST['the_pl_setting'], array());
        }
        if (isset($_POST['reset_callback'])) {
            call_user_func($_POST['reset_callback']);
        }
    }
    $option_array = isset($option_array) ? $option_array : get_option_array();
    foreach ($option_array as $menuitem => $options) {
        foreach ($options as $oid => $o) {
            if (isset($o['type']) && $o['type'] == 'reset' && ploption($oid)) {
                call_user_func($o['callback']);
                // Set the 'reset' option back to not set !important
                pagelines_update_option($oid, null);
                wp_redirect(admin_url(PL_SETTINGS_URL . '&reset=true&opt_id=' . $oid));
                exit;
            }
        }
    }
}
コード例 #5
0
function reset_layout_to_default(){
	
	$dlayout = new PageLinesLayout;
	
	$layout_map = $dlayout->default_layout_setup();

	pagelines_update_option('layout', $layout_map);
}
コード例 #6
0
function pagelines_process_reset_options()
{
    foreach (get_option_array() as $menuitem => $options) {
        foreach ($options as $optionid => $o) {
            if ($o['type'] == 'reset' && pagelines_option($optionid)) {
                call_user_func($o['callback']);
                // Set the 'reset' option back to not set !important
                pagelines_update_option($optionid, null);
                wp_redirect(admin_url('admin.php?page=pagelines&reset=true&opt_id=' . $optionid));
                exit;
            }
        }
    }
}
コード例 #7
0
/**
 * 
 *
 *  Write Dynamic CSS to file
 *
 *  @package PageLines Core
 *  @subpackage Sections
 *  @since 1.2.0
 *
 */
function pagelines_build_dynamic_css( $trigger = 'N/A' ){

	// Create directories and folders for storing dynamic files
	if(!file_exists(PAGELINES_DCSS) ) {
		if ( false === pagelines_make_uploads() ); {
		pagelines_update_option( 'inline_dynamic_css', true );
		return;
		}	
	}
	// Write to dynamic files
	if ( is_writable(PAGELINES_DCSS) && !is_multisite() ){
		$pagelines_dynamic_css = new PageLinesCSS;
		$pagelines_dynamic_css->create('texturize');
		pagelines_make_uploads($pagelines_dynamic_css->css ."\n\n/* Trigger: ". $trigger . '*/');
	}

}
コード例 #8
0
    function _get_image_upload_option($optionid, $option_settings, $optionvalue = '')
    {
        if (get_option($optionid)) {
            pagelines_update_option($optionid, get_option($optionid));
            update_option($optionid, null);
        }
        ?>
<p>	
		<label class="context" for="<?php 
        echo $optionid;
        ?>
"><?php 
        echo $option_settings['inputlabel'];
        ?>
</label><br/>
		<input class="regular-text uploaded_url" type="text" name="<?php 
        pagelines_option_name($optionid);
        ?>
" value="<?php 
        echo esc_url(pagelines_option($optionid));
        ?>
" /><br/><br/>
		<span id="<?php 
        echo $optionid;
        ?>
" class="image_upload_button button">Upload Image</span>
		<span title="<?php 
        echo $optionid;
        ?>
" id="reset_<?php 
        echo $optionid;
        ?>
" class="image_reset_button button">Remove</span>
		<input type="hidden" class="ajax_action_url" name="wp_ajax_action_url" value="<?php 
        echo admin_url("admin-ajax.php");
        ?>
" />
		<input type="hidden" class="image_preview_size" name="img_size_<?php 
        echo $optionid;
        ?>
" value="<?php 
        echo $option_settings['imagepreview'];
        ?>
"/>
	</p>
	<?php 
        if (pagelines_option($optionid)) {
            ?>
		<img class="pagelines_image_preview" id="image_<?php 
            echo $optionid;
            ?>
" src="<?php 
            echo pagelines_option($optionid);
            ?>
" style="width:<?php 
            echo $option_settings['imagepreview'];
            ?>
px"/>
	<?php 
        }
        ?>
	
<?php 
    }