示例#1
0
/**
 * Get all the application keys
 * @return array Contains an array of all the application keys
 *
 * The array format is
 * [id (default_key for primary key, numeric increment for additional keys)]
 * 		['name']	=> <App Key Name>
 * 		['app_key']	=> <application key from Pushover.net>
 */
function ckpn_get_application_keys()
{
    $basic_options = ckpn_get_options();
    $additional_keys = get_option('_ckpn_additional_app_keys');
    $all_keys = array('default_key' => array('name' => 'Default Key', 'app_key' => $basic_options['application_key']));
    if (!empty($additional_keys)) {
        $all_keys = $all_keys + $additional_keys;
    }
    return $all_keys;
}
示例#2
0
/**
 * Saves the User Profile Settings
 * @param  int $user_id The User ID being saved
 * @return void         Saves to Usermeta
 */
function ckpn_save_profile_settings($user_id)
{
    if (!current_user_can('edit_user', $user_id)) {
        return false;
    }
    $user_key = sanitize_text_field($_POST['ckpn_user_key']);
    ckpn_update_user_to_keys_list($user_id, $user_key);
    $options = ckpn_get_options();
    if ($options['new_post']) {
        update_user_meta($user_id, 'ckpn_user_notify_posts', $_POST['ckpn_user_notify_posts']);
    }
}
示例#3
0
/**
 * Display the System Info Tab
 * @return void
 */
function ckpn_display_sysinfo()
{
    global $wpdb;
    $options = ckpn_get_options();
    if ($options['application_key'] != false) {
        $options['application_key'] = '[removed for display]';
    }
    if ($options['api_key'] != false) {
        $options['api_key'] = '[removed for display]';
    }
    ?>
	<textarea style="font-family: Menlo, Monaco, monospace; white-space: pre" onclick="this.focus();this.select()" readonly cols="150" rows="35">
SITE_URL:                 <?php 
    echo site_url() . "\n";
    ?>
HOME_URL:                 <?php 
    echo home_url() . "\n";
    ?>

CKPN Version:             <?php 
    echo CKPN_VERSION . "\n";
    ?>
WordPress Version:        <?php 
    echo get_bloginfo('version') . "\n";
    ?>

PUSHOVER NOTIFICATIONS SETTINGS:
<?php 
    foreach ($options as $name => $value) {
        if ($value == false) {
            $value = 'false';
        }
        if ($value == '1') {
            $value = 'true';
        }
        echo $name . ': ' . $value . "\n";
    }
    ?>

ACTIVE PLUGINS:
<?php 
    $plugins = get_plugins();
    $active_plugins = get_option('active_plugins', array());
    foreach ($plugins as $plugin_path => $plugin) {
        // If the plugin isn't active, don't show it.
        if (!in_array($plugin_path, $active_plugins)) {
            continue;
        }
        echo $plugin['Name'];
        ?>
: <?php 
        echo $plugin['Version'] . "\n";
    }
    ?>

CURRENT THEME:
<?php 
    if (get_bloginfo('version') < '3.4') {
        $theme_data = get_theme_data(get_stylesheet_directory() . '/style.css');
        echo $theme_data['Name'] . ': ' . $theme_data['Version'];
    } else {
        $theme_data = wp_get_theme();
        echo $theme_data->Name . ': ' . $theme_data->Version;
    }
    ?>


Multi-site:               <?php 
    echo is_multisite() ? 'Yes' . "\n" : 'No' . "\n";
    ?>

ADVANCED INFO:
PHP Version:              <?php 
    echo PHP_VERSION . "\n";
    ?>
MySQL Version:            <?php 
    echo mysql_get_server_info() . "\n";
    ?>
Web Server Info:          <?php 
    echo $_SERVER['SERVER_SOFTWARE'] . "\n";
    ?>

PHP Memory Limit:         <?php 
    echo ini_get('memory_limit') . "\n";
    ?>
PHP Post Max Size:        <?php 
    echo ini_get('post_max_size') . "\n";
    ?>
PHP Time Limit:           <?php 
    echo ini_get('max_execution_time') . "\n";
    ?>

WP_DEBUG:                 <?php 
    echo defined('WP_DEBUG') ? WP_DEBUG ? 'Enabled' . "\n" : 'Disabled' . "\n" : 'Not set' . "\n";
    ?>

WP Table Prefix:          <?php 
    echo "Length: " . strlen($wpdb->prefix);
    echo " Status:";
    if (strlen($wpdb->prefix) > 16) {
        echo " ERROR: Too Long";
    } else {
        echo " Acceptable";
    }
    echo "\n";
    ?>

Show On Front:            <?php 
    echo get_option('show_on_front') . "\n";
    ?>
Page On Front:            <?php 
    $id = get_option('page_on_front');
    echo get_the_title($id) . ' #' . $id . "\n";
    ?>
Page For Posts:           <?php 
    $id = get_option('page_on_front');
    echo get_the_title($id) . ' #' . $id . "\n";
    ?>

Session:                  <?php 
    echo isset($_SESSION) ? 'Enabled' : 'Disabled';
    echo "\n";
    ?>
Session Name:             <?php 
    echo esc_html(ini_get('session.name'));
    echo "\n";
    ?>
Cookie Path:              <?php 
    echo esc_html(ini_get('session.cookie_path'));
    echo "\n";
    ?>
Save Path:                <?php 
    echo esc_html(ini_get('session.save_path'));
    echo "\n";
    ?>
Use Cookies:              <?php 
    echo ini_get('session.use_cookies') ? 'On' : 'Off';
    echo "\n";
    ?>
Use Only Cookies:         <?php 
    echo ini_get('session.use_only_cookies') ? 'On' : 'Off';
    echo "\n";
    ?>

UPLOAD_MAX_FILESIZE:      <?php 
    if (function_exists('phpversion')) {
        echo ini_get('upload_max_filesize');
    }
    echo "\n";
    ?>
POST_MAX_SIZE:            <?php 
    if (function_exists('phpversion')) {
        echo ini_get('post_max_size');
    }
    echo "\n";
    ?>
WordPress Memory Limit:   <?php 
    echo WP_MEMORY_LIMIT;
    echo "\n";
    ?>
DISPLAY ERRORS:           <?php 
    echo ini_get('display_errors') ? 'On (' . ini_get('display_errors') . ')' : 'N/A';
    echo "\n";
    ?>
FSOCKOPEN:                <?php 
    echo function_exists('fsockopen') ? __('Your server supports fsockopen.', 'edd') : __('Your server does not support fsockopen.', 'edd');
    echo "\n";
    ?>
	</textarea>
	<?php 
}
/**
 * Fires when a new blog post is moved into the published status
 * @param  string $new_status Status the blog post is moving to
 * @param  string $old_status Previous post status
 * @param  object $post       The Post Object
 * @return void
 */
function ckpn_post_published($new_status, $old_status, $post)
{
    // By default only send on post and page publishing
    $allowed_post_types = apply_filters('ckpn_post_publish_types', array('post', 'page'));
    // Only do this when a post transitions to being published
    if (in_array($post->post_type, $allowed_post_types) && $new_status == 'publish' && $old_status != 'publish') {
        $user_keys = array();
        $title = get_bloginfo('name') . ': ' . __('New Post', CKPN_CORE_TEXT_DOMAIN);
        $title = apply_filters('ckpn_new_post_title', $title, $post);
        $author_data = get_userdata($post->post_author);
        $author_name = $author_data->display_name;
        $message = get_the_title($post->ID) . __(' by ', CKPN_CORE_TEXT_DOMAIN) . $author_name;
        $message = apply_filters('ckpn_new_post_message', $message, $post);
        $url = get_permalink($post->ID);
        $url_title = __('View Post', CKPN_CORE_TEXT_DOMAIN);
        $args = array('title' => $title, 'message' => $message, 'url' => $url, 'url_title' => $url_title);
        $new_post_roles = ckpn_get_option('new_post_roles');
        $user_array = array();
        foreach ($new_post_roles as $role => $value) {
            $user_args = array('role' => $role, 'fields' => 'ID');
            $users = get_users($user_args);
            $user_array = array_unique(array_merge($users, $user_array));
        }
        $super_admins = array();
        if (defined('MULTISITE') && MULTISITE) {
            $super_admin_logins = get_super_admins();
            foreach ($super_admin_logins as $super_admin_login) {
                $user = get_user_by('login', $super_admin_login);
                if ($user) {
                    $super_admins[] = $user->ID;
                }
            }
        }
        $users_to_alert = array_unique(array_merge($user_array, $super_admins));
        $current_user = wp_get_current_user();
        // Unset the Post Author for non-scheduled posts
        if ($old_status !== 'future' && ($key = array_search($post->post_author, $users_to_alert)) !== false && $current_user->ID == $post->post_author) {
            unset($users_to_alert[$key]);
        }
        $options = ckpn_get_options();
        // Add the default admin key from settings if it's different than the authors
        if (get_user_meta($post->post_author, 'ckpn_user_key', true) !== $options['api_key']) {
            $user_keys = array($options['api_key']);
        }
        $users_with_keys = ckpn_get_users_with_keys();
        // Search the users for their Keys and send the posts
        foreach ($users_to_alert as $user) {
            $selected = get_user_meta($user, 'ckpn_user_notify_posts', true);
            if ($selected && array_key_exists($user, $users_with_keys)) {
                $user_keys[] = $users_with_keys[$user];
            }
        }
        $user_keys = array_unique($user_keys);
        foreach ($user_keys as $user) {
            $args['user'] = $user;
            ckpn_send_notification($args);
        }
    }
}
 /**
  * Original get_options unifier
  * @return array List of options
  * @deprecated as of 1.5
  * @access public
  */
 public function get_options()
 {
     return ckpn_get_options();
 }