Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge cleaner code #165

Merged
merged 11 commits into from
Apr 12, 2019
5 changes: 1 addition & 4 deletions auto-load-next-post.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,13 @@ public function __wakeup() {
* @access public
* @since 1.0.0
* @version 1.5.0
* @return Auto_Load_Next_Post
*/
public function __construct() {
$this->setup_constants();
$this->includes();
$this->init_hooks();

/**
* Auto Load Next Post is fully loaded.
*/
// Auto Load Next Post is fully loaded.
do_action( 'auto_load_next_post_loaded' );
} // END __construct()

Expand Down
3 changes: 1 addition & 2 deletions includes/admin/class-alnp-admin-notices.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,7 @@ public function add_notices() {
add_action( 'admin_notices', array( $this, 'theme_ready_notice' ) );
update_option( 'auto_load_next_post_theme_supported', $template );
}
}
else {
} else {
// If theme not supported then delete option.
delete_option( 'auto_load_next_post_theme_supported' );
}
Expand Down
2 changes: 2 additions & 0 deletions includes/admin/class-alnp-admin-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ public static function output_fields( $options ) {
}

// Description handling
$description = '';

if ( ! empty( $value['desc'] ) ) {
$description = $value['desc'];
}
Expand Down
12 changes: 7 additions & 5 deletions includes/admin/class-alnp-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function admin_scripts() {
$screen = get_current_screen();
$screen_id = $screen ? $screen->id : '';

if ( $screen->id == 'settings_page_auto-load-next-post-settings' ) {
if ( $screen_id == 'settings_page_auto-load-next-post-settings' ) {
// Select2 - Make sure that we remove other registered Select2 to prevent plugin conflict issues.
if ( wp_script_is( 'select2', 'registered' ) ) {
wp_dequeue_script( 'select2' );
Expand Down Expand Up @@ -284,9 +284,10 @@ public function plugin_row_meta( $links, $file, $data ) {
* @return string $text
*/
public function admin_footer_text( $text ) {
$current_screen = get_current_screen();
$screen = get_current_screen();
$screen_id = $screen ? $screen->id : '';

if ( isset( $current_screen->id ) && $current_screen->id == 'settings_page_auto-load-next-post-settings' ) {
if ( $screen_id == 'settings_page_auto-load-next-post-settings' ) {
// Rating and Review
$text = sprintf(
/* translators: 1: Auto Load Next Post 2:: five stars */
Expand All @@ -310,9 +311,10 @@ public function admin_footer_text( $text ) {
* @return string $text
*/
public function update_footer( $text ) {
$screen = get_current_screen();
$screen = get_current_screen();
$screen_id = $screen ? $screen->id : '';

if ( $screen->id == 'settings_page_auto-load-next-post-settings' ) {
if ( $screen_id == 'settings_page_auto-load-next-post-settings' ) {
return sprintf( __( '%s Version', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ) . ' ' . esc_attr( AUTO_LOAD_NEXT_POST_VERSION );
}

Expand Down
3 changes: 1 addition & 2 deletions includes/admin/views/html-admin-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@
// Checks if Auto Load Next Post Pro is installed before displaying sidebar.
if ( ! is_alnp_pro_version_installed() ) {
include_once( dirname( __FILE__ ) . '/html-admin-sidebar.php' );
}
else {
} else {
echo '<div class="alnp-sidebar">';

do_action( 'auto_load_next_post_after_settings' );
Expand Down
20 changes: 8 additions & 12 deletions includes/auto-load-next-post-core-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,16 @@ function auto_load_next_post_template_redirect() {
* If theme does not have a template file for Auto Load Next Post,
* the plugin will load a default template.
*/
$child_path = get_stylesheet_directory() . '/' . AUTO_LOAD_NEXT_POST_TEMPLATE_PATH;
$template_path = get_template_directory() . '/' . AUTO_LOAD_NEXT_POST_TEMPLATE_PATH;
$default_path = AUTO_LOAD_NEXT_POST_FILE_PATH;
$child_path = get_stylesheet_directory() . '/' . AUTO_LOAD_NEXT_POST_TEMPLATE_PATH;
$template_path = get_template_directory() . '/' . AUTO_LOAD_NEXT_POST_TEMPLATE_PATH;
$default_path = AUTO_LOAD_NEXT_POST_FILE_PATH;
$template_redirect = '';

if ( file_exists( $child_path . 'content-alnp.php' ) ) {
$template_redirect = $child_path . 'content-alnp.php';
}
else if( file_exists( $template_path . 'content-alnp.php') ) {
} else if ( file_exists( $template_path . 'content-alnp.php' ) ) {
$template_redirect = $template_path . 'content-alnp.php';
}
else if( file_exists( $default_path . '/template/content-alnp.php' ) ) {
} else if ( file_exists( $default_path . '/template/content-alnp.php' ) ) {
$template_redirect = $default_path . '/template/content-alnp.php';
}

Expand Down Expand Up @@ -122,8 +121,7 @@ function alnp_get_random_page_permalink( $post_type = 'post' ) {

return get_permalink( $id );
endwhile;
}
else {
} else {
return false;
}
} // END alnp_get_random_page_permalink()
Expand Down Expand Up @@ -156,13 +154,11 @@ function alnp_load_js_in_footer() {
*/
if ( ! function_exists( 'alnp_get_admin_screens' ) ) {
function alnp_get_admin_screens() {
$show_on_screens = array(
return array(
'dashboard',
'plugins',
'themes',
'settings_page_auto-load-next-post-settings'
);

return $show_on_screens;
}
}
11 changes: 7 additions & 4 deletions includes/customizer/class-alnp-customizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,12 @@ public function alnp_init_customizer( $wp_customize ) {
public function alnp_remove_widgets_panel( $components ) {
if ( $this->alnp_is_customizer() ) {
foreach( $components as $key => $component ) {
if ( $component == 'widgets' ) unset( $components[ 'widgets' ] );
if ( $component == 'nav_menus' ) unset( $components[ 'nav_menus' ] );
if ( $component == 'widgets' ) {
unset( $components[ 'widgets' ] );
}
if ( $component == 'nav_menus' ) {
unset( $components[ 'nav_menus' ] );
}
}
}

Expand Down Expand Up @@ -497,8 +501,7 @@ public function is_page_alnp_ready() {
return false;
} elseif ( is_home() ) {
return true;
}
elseif ( is_singular( apply_filters( 'alnp_customizer_posts_ready', array( 'post' ) ) ) ) {
} elseif ( is_singular( apply_filters( 'alnp_customizer_posts_ready', array( 'post' ) ) ) ) {
return true;
}

Expand Down
4 changes: 3 additions & 1 deletion includes/theme-support/class-alnp-theme-support.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ public function update_alnp_theme_selectors( $stylesheet = '', $old_theme = fals
// Preferred implementation, where theme provides an array of options
if ( isset( $theme_support[0] ) && is_array( $theme_support[0] ) ) {
foreach( $theme_support[0] as $key => $value ) {
if ( ! empty( $value ) ) update_option( 'auto_load_next_post_' . $key, $value );
if ( ! empty( $value ) ) {
update_option( 'auto_load_next_post_' . $key, $value );
}
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions template/theme-support/make/content-alnp.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
// Load content after the loop.
do_action( 'alnp_load_after_loop' );

else :
else :

// Load content if there are no more posts.
do_action( 'alnp_no_more_posts' );
// Load content if there are no more posts.
do_action( 'alnp_no_more_posts' );

endif; // END if have_posts()
endif; // END if have_posts()