/* Plugin Name: Launchpad Plugin URI: http://cysy.com Description: Adds a custom theme options page for the CYSY framework. Version: 1.0 Author: Cheyne Sutherland Author URI: http://cysy.com */ /*----------------------------------------------------------------------------------- LOAD JQUERY, OTHER PLUGIN ASSETS, & SAVED OPTIONS -------------------------------------------------------------------------------------*/ // GET REGISTERED JQUERY function launchpad_get_jquery() { wp_enqueue_script('jquery'); } add_action('init', 'launchpad_get_jquery'); // DEFINE PLUGIN FILE PATH define('LAUNCHPAD_PLUGIN_PATH', WP_PLUGIN_URL . '/' . plugin_basename(dirname(__FILE__)) . '/'); function launchpad_register_scripts() { // LOAD LIGHTSLIDER JAVASCRIPT FILE wp_enqueue_script('lightslider', LAUNCHPAD_PLUGIN_PATH.'js/lightslider.js', array('jquery')); // LOAD PLUGIN JAVASCRIPT FILE wp_enqueue_script('launchpad-scripts', LAUNCHPAD_PLUGIN_PATH.'js/launchpad.js', array('jquery')); // LOAD PLUGIN STYLESHEET wp_enqueue_style('launchpad-styles', LAUNCHPAD_PLUGIN_PATH.'css/style.css'); // LOAD OLYMPUS STYLESHEET wp_enqueue_style('olympus-styles', LAUNCHPAD_PLUGIN_PATH.'css/olympus.css'); // LOAD LIGHTSLIDER STYLESHEET wp_enqueue_style('lightslider-styles', LAUNCHPAD_PLUGIN_PATH.'css/lightslider.css'); } add_action( 'wp_enqueue_scripts', 'launchpad_register_scripts' ); /*----------------------------------------------------------------------------------- REGISTER LAUNCHPAD PLUGIN SETTINGS ON INSTALL -------------------------------------------------------------------------------------*/ // ON PLUGIN ACTIVATION, EXECUTE INSTALL_LAUNCHPAD FUNCTION register_activation_hook(__FILE__, install_launchpad()); function install_launchpad() { // REGISTER LAUNCHPAD MENU ITEM function launchpad_menu_item() { add_menu_page( 'Launchpad', // TITLE TAG 'Launchpad', // MENU ITEM LABEL 'update_core', // USER CAPABILITY 'launchpad', // SLUG 'launchpad_admin_page', // CALLBACK FUNCTION 'dashicons-location-alt', // https://developer.wordpress.org/resource/dashicons/ '58' // MENU POSITION ); } add_action('admin_menu', 'launchpad_menu_item'); // REGISTER LAUNCHPAD SETTINGS add_action('admin_init', 'register_launchpad_settings'); } /*----------------------------------------------------------------------------------- LAUNCHPAD FUNCTIONS -------------------------------------------------------------------------------------*/ // ADD MENU SEPARATOR function add_launchpad_admin_menu_separator($position) { global $menu; $menu[$position] = array( 0 => '', 1 => 'read', 2 => 'separator' . $position, 3 => '', 4 => 'wp-menu-separator' ); } add_action('init_custom_menu_separator', 'add_launchpad_admin_menu_separator'); // ADD MENU SEPARATOR ABOVE OPTIONS PAGE function set_launchpad_admin_menu_separator() { do_action('init_custom_menu_separator', 57); } add_action('init', 'set_launchpad_admin_menu_separator'); // LAUNCHPAD SETTINGS function register_launchpad_settings() { register_setting('launchpad-settings', 'launchpad'); } // GET DIRECTORY SIZE function get_foldersize($path) { $total_size = 0; $files = scandir($path); $cleanPath = rtrim($path, '/') . '/'; foreach($files as $t) { if ('.' != $t && '..' != $t) { $currentFile = $cleanPath . $t; if (is_dir($currentFile)) { $size = get_foldersize($currentFile); $total_size += $size; } else { $size = filesize($currentFile); $total_size += $size; } } } return $total_size; } // FORMAT DIRECTORY SIZE function wp_formatsize($size) { $units = explode(' ', 'B KB MB GB TB PB'); $mod = 1024; for ($i = 0; $size > $mod; $i++) $size /= $mod; $endIndex = strpos($size, ".") + 3; return substr($size, 0, $endIndex) . ' ' . $units[$i]; } /*----------------------------------------------------------------------------------- LAUNCHPAD OPTIONS PAGE -------------------------------------------------------------------------------------*/ function launchpad_admin_page() { if (!current_user_can('manage_options')) { wp_die(__('You do not have sufficient permissions to access this page.')); } // FETCH SAVED OPTION VALUES $options = get_option('launchpad'); // FETCH DIRECTORY FOLDER SIZES $upload_dir = wp_upload_dir(); $theme_dir = get_theme_root(); $upload_space = get_foldersize($upload_dir['basedir']); $content_space = get_foldersize(WP_CONTENT_DIR); $theme_space = get_foldersize($theme_dir); $plugin_space = get_foldersize(WP_PLUGIN_DIR); $wp_space = get_foldersize(ABSPATH); $active_theme = get_template_directory(); $active_theme_space = get_foldersize($active_theme); // MATH FOR DIRECTORY FOLDER SIZE PERCENTAGES $total = $content_space; $uploads = $upload_space / $total * 100; $plugins = $plugin_space / $total * 100; $themes = $theme_space / $total * 100; $active = ($active_theme_space / 2048000) * 38.86; echo '
Enjoy upcoming festivals and events this summer in Gulf Shores and Orange Beach, Alabama.<\/p>\n
Enjoy upcoming festivals and events this summer in Gulf Shores and Orange Beach, Alabama. 10th Annual Gulf Coast Hot Air Balloon Festival – Jun 13, 2014 2:00 PM – 10:00 PM Rewind Fest at The Wharf – Jul 5, 2014 6:00 PM 2014 Blue Marlin Grand Championship of the Gulf – 7\/9\/2014, 7\/10\/2014, 7\/11\/2014, 7\/12\/2014, […]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[10,8],"class_list":["post-6911","post","type-post","status-publish","format-standard","hentry","category-news","tag-orange-beach-alabama-condo-rentals","tag-orange-beach-vacation-rentals"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.sugsands.com\/wp-json\/wp\/v2\/posts\/6911","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sugsands.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sugsands.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sugsands.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sugsands.com\/wp-json\/wp\/v2\/comments?post=6911"}],"version-history":[{"count":0,"href":"https:\/\/www.sugsands.com\/wp-json\/wp\/v2\/posts\/6911\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sugsands.com\/wp-json\/wp\/v2\/media?parent=6911"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sugsands.com\/wp-json\/wp\/v2\/categories?post=6911"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sugsands.com\/wp-json\/wp\/v2\/tags?post=6911"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}