Skip to content

Commit

Permalink
Refactoring for download-directory/load.php
Browse files Browse the repository at this point in the history
  • Loading branch information
alexxgermann committed Oct 6, 2016
1 parent 0812cbc commit 4cf94d1
Showing 1 changed file with 39 additions and 46 deletions.
85 changes: 39 additions & 46 deletions runway-framework/framework/includes/download-directory/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,73 +14,66 @@

// Settings
$fields = array(
'var' => array(),
'array' => array()
'var' => array(),
'array' => array()
);

$default = array();

global $settingshortname;



$settings = array(
'name' => __('Add-ons', 'runway'),
'alias' => 'directory',
'option_key' => $settingshortname.'download-directory',
'fields' => $fields,
'default' => $default,
'parent_menu' => 'hidden',
'menu_permissions' => 'administrator',
'file' => __FILE__,
'js' => array(
FRAMEWORK_URL.'framework/js/jquery-ui.min.js',
),
'css' => array(
FRAMEWORK_URL.'framework/includes/download-directory/css/style.css',
),
'name' => __( 'Add-ons', 'runway' ),
'alias' => 'directory',
'option_key' => $settingshortname . 'download-directory',
'fields' => $fields,
'default' => $default,
'parent_menu' => 'hidden',
'menu_permissions' => 'administrator',
'file' => __FILE__,
'js' => array(
FRAMEWORK_URL . 'framework/js/jquery-ui.min.js',
),
'css' => array(
FRAMEWORK_URL . 'framework/includes/download-directory/css/style.css',
),
);

global $directory, $Directory_Settings;

// Required components
include 'object.php';
include __DIR__ . '/object.php';

$Directory_Settings = new Directory_Settings_Object( $settings );

// Load admin components
if ( is_admin() ) {
include 'settings-object.php';
$directory = new Directory_Admin( $settings );
include __DIR__ . '/settings-object.php';
$directory = new Directory_Admin( $settings );
}

function test_requested() {
echo 'Test';
exit();
}
if ( ! function_exists( 'download_directory_report' ) ) {
function download_directory_report( $reports_object ) {

add_action( 'wp_ajax_test', 'test_requested' );
global $directory;

add_action( 'add_report', 'download_directory_report' );
$downloads_tmp_dir = $directory->downloads_dir;
$reports_object->assign_report( array(
'source' => 'Download Directory',
'report_key' => 'download_tmp_dir_exists',
'path' => $downloads_tmp_dir,
'success_message' => sprintf( __( 'Downloads directory (%s) is exists.', 'runway' ), $downloads_tmp_dir ),
'fail_message' => sprintf( __( 'Downloads directory (%s) is not exists.', 'runway' ), $downloads_tmp_dir ),
), 'DIR_EXISTS' );

function download_directory_report( $reports_object ) {
global $directory;
$upload_dir = wp_upload_dir( );
$downloads_tmp_dir = $directory->downloads_dir;
$reports_object->assign_report( array(
'source' => 'Download Directory',
'report_key' => 'download_tmp_dir_exists',
'path' => $downloads_tmp_dir,
'success_message' => sprintf( __('Downloads directory (%s) is exists.', 'runway'), $downloads_tmp_dir),
'fail_message' => sprintf( __('Downloads directory (%s) is not exists.', 'runway'), $downloads_tmp_dir),
), 'DIR_EXISTS' );
$reports_object->assign_report( array(
'source' => 'Download Directory',
'report_key' => 'download_tmp_dir_writable',
'path' => $downloads_tmp_dir,
'success_message' => sprintf( __( 'Downloads directory (%s) is writable.', 'runway' ), $downloads_tmp_dir ),
'fail_message' => sprintf( __( 'Downloads directory (%s) is not writable.', 'runway' ), $downloads_tmp_dir ),
), 'IS_WRITABLE' );

$reports_object->assign_report( array(
'source' => 'Download Directory',
'report_key' => 'download_tmp_dir_writable',
'path' => $downloads_tmp_dir,
'success_message' => sprintf( __('Downloads directory (%s) is writable.', 'runway'), $downloads_tmp_dir),
'fail_message' => sprintf( __('Downloads directory (%s) is not writable.', 'runway'), $downloads_tmp_dir),
), 'IS_WRITABLE' );
}
add_action( 'add_report', 'download_directory_report' );
}
?>

0 comments on commit 4cf94d1

Please sign in to comment.