elementor
5 years ago
class-simple-author-box-admin-page.php
5 years ago
class-simple-author-box-block.php
5 years ago
class-simple-author-box-helper.php
5 years ago
class-simple-author-box-previewer.php
5 years ago
class-simple-author-box-social.php
6 years ago
class-simple-author-box-user-profile.php
5 years ago
class-simple-author-box-widget.php
5 years ago
class-simple-author-box.php
5 years ago
functions.php
5 years ago
functions.php
94 lines
| 1 | <?php |
| 2 | |
| 3 | // If this file is called directly, busted! |
| 4 | if ( ! defined( 'ABSPATH' ) ) { |
| 5 | exit; |
| 6 | } |
| 7 | |
| 8 | /*---------------------------------------------------------------------------------------------------------- |
| 9 | Adding the author box to the end of your single post |
| 10 | -----------------------------------------------------------------------------------------------------------*/ |
| 11 | if ( ! function_exists( 'wpsabox_author_box' ) ) { |
| 12 | |
| 13 | |
| 14 | function wpsabox_author_box( $saboxmeta = null, $user_id = null) { |
| 15 | |
| 16 | $show = ( is_single() || is_author() || is_archive() ); |
| 17 | |
| 18 | /** |
| 19 | * Hook: sabox_check_if_show. |
| 20 | * |
| 21 | * @hooked Simple_Author_Box::check_if_show_archive - 10 |
| 22 | */ |
| 23 | |
| 24 | $show = apply_filters( 'sabox_check_if_show', $show ); |
| 25 | |
| 26 | if ( $show ) { |
| 27 | |
| 28 | global $post; |
| 29 | |
| 30 | $template = Simple_Author_Box_Helper::get_template(); |
| 31 | |
| 32 | ob_start(); |
| 33 | $sabox_options = Simple_Author_Box_Helper::get_option( 'saboxplugin_options' ); |
| 34 | $sabox_author_id = $user_id ? $user_id : $post->post_author; |
| 35 | $show_post_author_box = apply_filters( 'sabox_check_if_show_post_author_box', true, $sabox_options ); |
| 36 | |
| 37 | do_action( 'sabox_before_author_box', $sabox_options ); |
| 38 | |
| 39 | if ( $show_post_author_box ) { |
| 40 | include( $template ); |
| 41 | } |
| 42 | |
| 43 | do_action( 'sabox_after_author_box', $sabox_options ); |
| 44 | |
| 45 | $sabox = ob_get_clean(); |
| 46 | $return = $saboxmeta . $sabox; |
| 47 | |
| 48 | // Filter returning HTML of the Author Box |
| 49 | $saboxmeta = apply_filters( 'sabox_return_html', $return, $sabox, $saboxmeta ); |
| 50 | |
| 51 | } |
| 52 | |
| 53 | return $saboxmeta; |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | //return notice if user hasn't filled Biographical Info |
| 58 | function sab_user_description_notice() { |
| 59 | $user_id = get_current_user_id(); |
| 60 | $user = get_userdata( $user_id ); |
| 61 | $user_descrition = $user->description; |
| 62 | $user_roles = $user->roles; |
| 63 | if ( ! $user_descrition && in_array( 'author', $user_roles ) ) { |
| 64 | |
| 65 | ?> |
| 66 | <div class="notice notice-info is-dismissible"> |
| 67 | <p><?php _e( 'Please complete Biographical Info', 'simple-author-box' ); ?></p> |
| 68 | </div> |
| 69 | <?php |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | add_action( 'admin_notices', 'sab_user_description_notice' ); |
| 74 | |
| 75 | |
| 76 | //return notice if user hasn't filled any social profiles |
| 77 | function sab_user_social_notice() { |
| 78 | $user_id = get_current_user_id(); |
| 79 | $user_social = get_user_meta( $user_id, 'sabox_social_links' ); |
| 80 | $user = get_userdata( $user_id ); |
| 81 | $user_roles = $user->roles; |
| 82 | |
| 83 | if ( ! $user_social && in_array( 'author', $user_roles ) ) { |
| 84 | |
| 85 | ?> |
| 86 | <div class="notice notice-info is-dismissible"> |
| 87 | <p><?php _e( 'Please enter a social profile', 'simple-author-box' ); ?></p> |
| 88 | </div> |
| 89 | <?php |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | add_action( 'admin_notices', 'sab_user_social_notice' ); |
| 94 |