Skip to content

Commit

Permalink
Admin bugfix, other misc updates
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisblakley committed Feb 1, 2017
1 parent 0fc02a9 commit 97c769a
Show file tree
Hide file tree
Showing 17 changed files with 75 additions and 53 deletions.
2 changes: 1 addition & 1 deletion Nebula-Child/style.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion author.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<?php endif; ?>

<?php if ( get_the_author_meta('twitter') ): ?>
<a class="twitter" href="http://www.twitter.com/<?php echo get_the_author_meta('twitter'); ?>" target="_blank" title="@<?php echo get_the_author_meta('twitter'); ?>"><i class="fa fa-twitter-square"></i></a>
<a class="twitter" href="<?php echo nebula_twitter_url(get_the_author_meta('twitter')); ?>" target="_blank" title="@<?php echo get_the_author_meta('twitter'); ?>"><i class="fa fa-twitter-square"></i></a>
<?php endif; ?>

<?php if ( get_the_author_meta('googleplus') ): ?>
Expand Down
3 changes: 2 additions & 1 deletion functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ function register_nebula_scripts(){
'nebula_google_browser_api_key' => nebula_option('google_browser_api_key'),
'facebook_url' => nebula_option('facebook_url'),
'facebook_app_id' => nebula_option('facebook_app_id'),
'twitter_url' => nebula_option('twitter_url'),
'twitter_username' => nebula_option('twitter_username'),
'twitter_url' => nebula_twitter_url(),
'google_plus_url' => nebula_option('google_plus_url'),
'linkedin_url' => nebula_option('linkedin_url'),
'youtube_url' => nebula_option('youtube_url'),
Expand Down
63 changes: 33 additions & 30 deletions functions/nebula_admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,32 +134,35 @@ function nebula_admin_bar_menus($wp_admin_bar){
}
}

//Children pages
$child_pages = new WP_Query(array(
'post_type' => $post_type_object->labels->singular_name,
'posts_per_page' => -1,
'post_parent' => get_the_id(),
'order' => 'ASC',
'orderby' => 'menu_order'
));
if ( $child_pages->have_posts() ){
$wp_admin_bar->add_node(array(
'parent' => $node_id,
'id' => 'nebula-children',
'title' => '<i class="nebula-admin-fa fa fa-fw fa-level-down" style="font-family: \'FontAwesome\'; color: #a0a5aa; color: rgba(240, 245, 250, .6); margin-right: 5px;"></i> Children ' . ucwords($post_type_object->labels->name) . ' <small>(' . $child_pages->found_posts . ')</small>',
if ( !is_admin_page() ){ //@todo "Nebula" 0: Remove this conditional when this bug is fixed: https://core.trac.wordpress.org/ticket/18408
//Children pages
$child_pages = new WP_Query(array(
'post_type' => $post_type_object->labels->singular_name,
'posts_per_page' => -1,
'post_parent' => get_the_id(),
'order' => 'ASC',
'orderby' => 'menu_order'
));

while ( $child_pages->have_posts() ){
$child_pages->the_post();
if ( $child_pages->have_posts() ){
$wp_admin_bar->add_node(array(
'parent' => 'nebula-children',
'id' => 'nebula-child-' . get_the_id(),
'title' => '<i class="nebula-admin-fa fa fa-fw fa-file-o" style="font-family: \'FontAwesome\'; color: #a0a5aa; color: rgba(240, 245, 250, .6); margin-right: 5px;"></i> ' . get_the_title(),
'href' => ( is_admin_page() )? get_edit_post_link() : get_permalink(),
'parent' => $node_id,
'id' => 'nebula-children',
'title' => '<i class="nebula-admin-fa fa fa-fw fa-level-down" style="font-family: \'FontAwesome\'; color: #a0a5aa; color: rgba(240, 245, 250, .6); margin-right: 5px;"></i> Children ' . ucwords($post_type_object->labels->name) . ' <small>(' . $child_pages->found_posts . ')</small>',
));

while ( $child_pages->have_posts() ){
$child_pages->the_post();
$wp_admin_bar->add_node(array(
'parent' => 'nebula-children',
'id' => 'nebula-child-' . get_the_id(),
'title' => '<i class="nebula-admin-fa fa fa-fw fa-file-o" style="font-family: \'FontAwesome\'; color: #a0a5aa; color: rgba(240, 245, 250, .6); margin-right: 5px;"></i> ' . get_the_title(),
'href' => ( is_admin_page() )? get_edit_post_link() : get_permalink(),
));
}
}

wp_reset_postdata();
}
wp_reset_query();
}

$wp_admin_bar->add_node(array(
Expand Down Expand Up @@ -286,7 +289,7 @@ function nebula_admin_bar_style_script_overrides(){

//Disable Wordpress Core update notifications in WP Admin
if ( nebula_option('wp_core_updates_notify', 'disabled') ){
add_filter('pre_site_transient_update_core', create_function('$a', "return null;"));
add_filter('pre_site_transient_update_core', '__return_null');
}

//Show update warning on Wordpress Core/Plugin update admin pages
Expand Down Expand Up @@ -731,7 +734,7 @@ function dashboard_nebula_ataglance(){
$all_plugins = get_transient('nebula_count_plugins');
if ( empty($all_plugins) || is_debug() ){
$all_plugins = get_plugins();
set_transient('nebula_count_plugins', $all_plugins, 60*60*12); //12 hour cache
set_transient('nebula_count_plugins', $all_plugins, 60*60*36); //36 hour cache
}
$active_plugins = get_option('active_plugins', array());
echo '<li><i class="fa fa-plug fa-fw"></i> <a href="plugins.php"><strong>' . count($all_plugins) . '</strong> Plugins</a> installed <small>(' . count($active_plugins) . ' active)</small></li>';
Expand All @@ -740,7 +743,7 @@ function dashboard_nebula_ataglance(){
$user_count = get_transient('nebula_count_users');
if ( empty($user_count) || is_debug() ){
$user_count = count_users();
set_transient('nebula_count_users', $user_count, 60*60*24); //24 hour cache
set_transient('nebula_count_users', $user_count, 60*60*36); //36 hour cache
}
$users_icon = 'users';
$users_plural = 'Users';
Expand Down Expand Up @@ -1047,7 +1050,7 @@ function dashboard_social(){
}

if ( nebula_option('twitter_username') ){
echo '<li><i class="fa fa-twitter-square fa-fw"></i> <a href="https://twitter.com/' . str_replace('@', '', nebula_option('twitter_username')) . '" target="_blank">Twitter</a></li>';
echo '<li><i class="fa fa-twitter-square fa-fw"></i> <a href="' . nebula_twitter_url() . '" target="_blank">Twitter</a></li>';
}

if ( nebula_option('google_plus_url') ){
Expand Down Expand Up @@ -1293,13 +1296,13 @@ function top_domain_name($url){
$nebula_parent_size = get_transient('nebula_directory_size_parent_theme');
if ( empty($nebula_parent_size) || is_debug() ){
$nebula_parent_size = foldersize(get_template_directory());
set_transient('nebula_directory_size_parent_theme', $nebula_parent_size, 60*60*12); //12 hour cache
set_transient('nebula_directory_size_parent_theme', $nebula_parent_size, 60*60*24); //24 hour cache
}

$nebula_child_size = get_transient('nebula_directory_size_child_theme');
if ( empty($nebula_child_size) || is_debug() ){
$nebula_child_size = foldersize(get_template_directory());
set_transient('nebula_directory_size_child_theme', $nebula_child_size, 60*60*12); //12 hour cache
set_transient('nebula_directory_size_child_theme', $nebula_child_size, 60*60*24); //24 hour cache
}

echo '<li><i class="fa fa-code"></i> Parent theme directory size: <strong>' . round($nebula_parent_size/1048576, 2) . 'mb</strong> </li>';
Expand All @@ -1313,7 +1316,7 @@ function top_domain_name($url){
$nebula_size = get_transient('nebula_directory_size_theme');
if ( empty($nebula_size) || is_debug() ){
$nebula_size = foldersize(get_stylesheet_directory());
set_transient('nebula_directory_size_theme', $nebula_size, 60*60*12); //12 hour cache
set_transient('nebula_directory_size_theme', $nebula_size, 60*60*24); //24 hour cache
}
echo '<li><i class="fa fa-code"></i> Theme directory size: <strong>' . round($nebula_size/1048576, 2) . 'mb</strong> </li>';
}
Expand All @@ -1335,7 +1338,7 @@ function top_domain_name($url){
$uploads_size = get_transient('nebula_directory_size_uploads');
if ( empty($uploads_size) || is_debug() ){
$uploads_size = foldersize($upload_dir['basedir']);
set_transient('nebula_directory_size_uploads', $uploads_size, 60*60*24); //24 hour cache
set_transient('nebula_directory_size_uploads', $uploads_size, 60*60*36); //36 hour cache
}

if ( function_exists('wp_max_upload_size') ){
Expand Down Expand Up @@ -2111,4 +2114,4 @@ function nebula_ajax_drop_nv_table(){
}

wp_die();
}
}
5 changes: 5 additions & 0 deletions functions/nebula_automation.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ function nebula_register_required_plugins(){
'slug' => 'query-monitor',
'required' => false,
),
array(
'name' => '404 to 301',
'slug' => '404-to-301',
'required' => false,
),
);

if ( file_exists(WP_PLUGIN_DIR . '/woocommerce') ){
Expand Down
16 changes: 8 additions & 8 deletions functions/nebula_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ function nebula_twitter_follow($counts=0, $username=false){
}
?>
<div class="nebula-social-button twitter-follow">
<a href="https://twitter.com/<?php echo str_replace('@', '', $username); ?>" class="twitter-follow-button" <?php echo ( $counts != 0 )? '': 'data-show-count="false"'; ?> <?php echo ( !empty($username) )? '': 'data-show-screen-name="false"'; ?>>Follow <?php echo $username; ?></a>
<a href="<?php echo nebula_twitter_url($username); ?>" class="twitter-follow-button" <?php echo ( $counts != 0 )? '': 'data-show-count="false"'; ?> <?php echo ( !empty($username) )? '': 'data-show-screen-name="false"'; ?>>Follow <?php echo $username; ?></a>
<?php twitter_widget_script(); ?>
</div>
<?php
Expand Down Expand Up @@ -1505,7 +1505,7 @@ function nebula_close_or_exact($rating=0, $close_threshold=80, $exact_threshold=
$menus = get_transient('nebula_autocomplete_menus');
if ( empty($menus) || is_debug() ){
$menus = get_terms('nav_menu');
set_transient('nebula_autocomplete_menus', $menus, 60*60); //1 hour cache
set_transient('nebula_autocomplete_menus', $menus, 60*60*24); //24 hour cache. This transient is deleted when a post is updated or Nebula Options are saved.
}
foreach($menus as $menu){
$menu_items = wp_get_nav_menu_items($menu->term_id);
Expand Down Expand Up @@ -1543,7 +1543,7 @@ function nebula_close_or_exact($rating=0, $close_threshold=80, $exact_threshold=
$categories = get_transient('nebula_autocomplete_categories');
if ( empty($categories) || is_debug() ){
$categories = get_categories();
set_transient('nebula_autocomplete_categories', $categories, 60*60); //1 hour cache
set_transient('nebula_autocomplete_categories', $categories, 60*60*24); //24 hour cache. This transient is deleted when a post is updated or Nebula Options are saved.
}
foreach ( $categories as $category ){
$suggestion = array();
Expand All @@ -1566,7 +1566,7 @@ function nebula_close_or_exact($rating=0, $close_threshold=80, $exact_threshold=
$tags = get_transient('nebula_autocomplete_tags');
if ( empty($tags) || is_debug() ){
$tags = get_tags();
set_transient('nebula_autocomplete_tags', $tags, 60*60); //1 hour cache
set_transient('nebula_autocomplete_tags', $tags, 60*60*24); //24 hour cache. This transient is deleted when a post is updated or Nebula Options are saved.
}
foreach ( $tags as $tag ){
$suggestion = array();
Expand All @@ -1590,7 +1590,7 @@ function nebula_close_or_exact($rating=0, $close_threshold=80, $exact_threshold=
$authors = get_transient('nebula_autocomplete_authors');
if ( empty($authors) || is_debug() ){
$authors = get_users(array('role' => 'author')); //@TODO "Nebula" 0: This should get users who have made at least one post. Maybe get all roles (except subscribers) then if postcount >= 1?
set_transient('nebula_autocomplete_authors', $authors, 60*60); //1 hour cache
set_transient('nebula_autocomplete_authors', $authors, 60*60*24*7); //1 week cache. This transient is deleted when a post is updated or Nebula Options are saved.
}
foreach ( $authors as $author ){
$author_name = ( $author->first_name != '' )? $author->first_name . ' ' . $author->last_name : $author->display_name; //might need adjusting here
Expand Down Expand Up @@ -1653,7 +1653,7 @@ function nebula_advanced_search(){
'posts_per_page' => -1,
'nopaging' => true
));
set_transient('nebula_everything_query', $everything_query, 60*60); //1 hour cache
set_transient('nebula_everything_query', $everything_query, 60*60*48); //48 hour cache. This transient is deleted when a post is updated or Nebula Options are saved.
}
$posts = $everything_query->get_posts();

Expand Down Expand Up @@ -2349,7 +2349,7 @@ function nebula_weather($zipcode=null, $data=''){
}

$weather_json = $response['body'];
set_transient('nebula_weather_' . $zipcode, $weather_json, 60*15); //15 minute expiration
set_transient('nebula_weather_' . $zipcode, $weather_json, 60*30); //30 minute expiration
}
$weather_json = json_decode($weather_json);

Expand Down Expand Up @@ -2480,7 +2480,7 @@ function video_meta($provider, $id){
$video_json = $response['body'];
}

set_transient('nebula_' . $provider . '_' . $id, $video_json, 60*60); //1 hour expiration
set_transient('nebula_' . $provider . '_' . $id, $video_json, 60*60*12); //12 hour expiration
}
$video_json = json_decode($video_json);

Expand Down
13 changes: 13 additions & 0 deletions functions/nebula_options.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,19 @@ function nebula_full_address($encoded=false){
return $full_address;
}

//Get the full Twitter URL for a user
function nebula_twitter_url($username=false){
if ( empty($username) ){
$username = nebula_option('twitter_username');
}

if ( !empty($username) ){
return 'https://twitter.com/' . $username;
}

return false;
}

//Register the requested version of Bootstrap.
function nebula_bootrap_version($lang=false){
if ( nebula_option('bootstrap_version') === 'bootstrap3' ){
Expand Down
2 changes: 1 addition & 1 deletion functions/nebula_security.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ function nebula_get_domain_blacklist(){
WP_Filesystem();
global $wp_filesystem;
$wp_filesystem->put_contents($domain_blacklist_json_file, $domain_blacklist);
set_transient('nebula_domain_blacklist', $domain_blacklist, 60*60*24); //24 hour cache
set_transient('nebula_domain_blacklist', $domain_blacklist, 60*60*36); //36 hour cache
}
}

Expand Down
2 changes: 1 addition & 1 deletion functions/nebula_utilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -2231,7 +2231,7 @@ function nebula_sass_color($color='primary', $theme='child'){
WP_Filesystem();
global $wp_filesystem;
$scss_variables = $wp_filesystem->get_contents($variables_file);
set_transient($transient_name, $scss_variables, 60*60); //1 hour cache
set_transient($transient_name, $scss_variables, 60*60*12); //12 hour cache
}

switch ( str_replace(array('$', ' ', '_', '-'), '', $color) ){
Expand Down
2 changes: 1 addition & 1 deletion includes/data/nebula_theme.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "4.8.30",
"version": "4.9.1",
"details_url": "https://github.com/chrisblakley/Nebula/commits/master",
"download_url": "https://github.com/chrisblakley/Nebula/archive/master.zip"
}
4 changes: 2 additions & 2 deletions includes/metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@
}

if ( nebula_option('twitter_username') ){
$company_same_as .= '"http://www.twitter.com/' . nebula_option('twitter_username') . '",';
$company_same_as .= '"' . nebula_twitter_url() . '",';
}

if ( nebula_option('google_plus_url') ){
Expand Down Expand Up @@ -266,7 +266,7 @@
}

if ( get_the_author_meta('twitter', $user->ID) ){
$person_same_as .= '"http://www.twitter.com/' . get_the_author_meta('twitter', $user->ID) . '",';
$person_same_as .= '"' . nebula_twitter_url(get_the_author_meta('twitter', $user->ID)) . '",';
}

if ( get_the_author_meta('googleplus', $user->ID) ){
Expand Down
4 changes: 2 additions & 2 deletions style.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion stylesheets/css/admin.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion stylesheets/css/login.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 97c769a

Please sign in to comment.