roles as $role) { // Rule exists and it is set if( isset( $mashsb_options["user_roles_for_sharing_options"] ) && in_array( str_replace( ' ', null, strtolower( $role ) ), $mashsb_options["user_roles_for_sharing_options"] ) ) { // Garbage collection unset($user); return true; } } unset ($user); return false; } add_filter( 'mashsb_rwmb_meta_boxes', 'mashsb_meta_boxes' ); function mashsb_meta_boxes( $meta_boxes ) { global $mashsb_options, $post; $prefix = 'mashsb_'; $post_types = isset( $mashsb_options['post_types'] ) ? $mashsb_options['post_types'] : array(); foreach ( $post_types as $key => $value ): $post_type[] = $key; endforeach; $post_type[] = 'post'; $post_type[] = 'page'; $twitter_handle = isset( $mashsb_options['mashsharer_hashtag'] ) ? $mashsb_options['mashsharer_hashtag'] : ''; // Do not show meta boxes if( !mashsb_show_meta_box() ) { return apply_filters( 'mashsb_meta_box_settings', $meta_boxes, 10, 0 ); } // Setup our meta box using an array $meta_boxes[0] = array( 'id' => 'mashsb_meta', 'title' => 'MashShare Social Sharing Options', 'pages' => $post_type, 'context' => 'normal', 'priority' => 'high', 'fields' => array( // Setup the social media image array( 'name' => ' ' . __( 'Social Media Image', 'mashsb' ), 'desc' => __( 'Optimal size for post shared images on Facebook, Google+ and LinkedIn is 1200px x 630px. Aspect ratio 1.9:1', 'mashsb' ), 'id' => $prefix . 'og_image', 'type' => 'image_advanced', 'clone' => false, 'max_file_uploads' => 1, 'class' => 'mashsb-og-image' ), // Setup the social media title array( 'name' => ' ' . __( 'Social Media Title', 'mashsb' ), 'desc' => __( 'This title is used by the open graph meta tag og:title and will be used when users share your content on Facebook, LinkedIn, or Google+. Leave this blank to use ', 'mashsb' ) . (mashsb_yoast_active() ? __( 'Yoast Facebook / SEO title', 'mashsb' ) : 'the post title'), 'id' => $prefix . 'og_title', 'type' => 'textarea', 'clone' => false, 'class' => 'mashsb-og-title' ), // Setup the social media description array( 'name' => ' ' . __( 'Social Media Description', 'mashsb' ), 'desc' => __( 'This description is used by the open graph meta tag og:description and will be used when users share your content on Facebook, LinkedIn, and Google Plus. Leave this blank to use ', 'mashsb' ) . (mashsb_yoast_active() ? __( 'Yoast Facebook open graph description or the post excerpt.', 'mashsb' ) : ' the post excerpt.'), 'id' => $prefix . 'og_description', 'type' => 'textarea', 'clone' => false, 'class' => 'mashsb-og-desc' ), array( 'name' => 'divider', 'id' => 'divider', 'type' => 'divider' ), // Setup the pinterest optimized image array( 'name' => ' ' . __( 'Pinterest Image', 'mashsb' ) . '', 'desc' => __( 'Pinned images need to be more vertical than horizontal in orientation. Use an aspect ratio of 2:3 to 1:3.5 and a minimum width of 600 pixels. So an image that is 600 pixels wide should be between 900 and 2100 pixels tall.', 'mashsb' ), 'id' => $prefix . 'pinterest_image', 'type' => 'image_advanced', 'clone' => false, 'max_file_uploads' => 1, 'class' => 'mashsb-pinterest-image' ), // Setup the pinterest description array( 'name' => ' ' . __('Pinterest Description', 'mashsb' ) . '', 'desc' => __( 'Place a customized message that will be used when this post is shared on Pinterest. Leave this blank to use the ', 'mashsb' ) . (mashsb_yoast_active() ? __( 'Yoast SEO title', 'mashsb' ) : __( 'the post title', 'mashsb' )), 'id' => $prefix . 'pinterest_description', 'type' => 'textarea', 'clone' => false, 'class' => 'mashsb-pinterest-desc' ), // Setup the Custom Tweet box array( 'name' => ' ' . __('Custom Tweet','mashsb'), 'desc' => mashsb_twitter_desc(), 'id' => $prefix . 'custom_tweet', 'type' => 'textarea', 'clone' => false, 'class' => 'mashsb-custom-tweet' ), array( 'id' => $prefix . 'position', 'name' => __('Share Button Position','mashsb'), 'type' => 'select', 'placeholder' => __('Use Global Setting','mashsb'), 'before' => '
', 'after' => '
', 'options' => array( 'disable' => __('Disable Automatic Buttons','mashsb'), 'before' => __('Above Content','mashsb'), 'after' => __('Below Content','mashsb'), 'both' => __('Above & Below Content','mashsb'), ) ), // Setup the og:type array( 'name' => ' ' . __( 'Open Graph Type', 'mashsb' ), 'desc' => __( 'This is used by the open graph meta tag og:type. Leave this blank to use the default value "article". ', 'mashsb' ), 'id' => $prefix . 'og_type', 'type' => 'text', 'clone' => false, 'class' => 'mashsb-og-type', 'before' => '
', 'after' => '
', ), array( 'helper'=> '', 'id' => $prefix . 'validate_og', 'before' => '
', 'after' => '
', 'type' => 'validate_og' ), array( 'name' => 'divider', 'id' => 'divider', 'type' => 'divider' ), array( 'id' => $prefix . 'twitter_handle', 'type' => 'hidden_data', 'std' => $twitter_handle, ), ) ); return apply_filters( 'mashsb_meta_box_settings', $meta_boxes, 10, 0 ); } /** * Check if Yoast is active * * @return boolean true when yoast is active */ function mashsb_yoast_active() { if( defined( 'WPSEO_VERSION' ) ) { return true; } } function mashsb_twitter_desc() { $str = ""; if( mashsb_get_twitter_username() ) { $str .= __( 'Based on your username @', 'mashsb' ) . mashsb_get_twitter_username() . __( ' ,the shortened post url and the current content above', 'mashsb' ); } else { $str .= __( 'Based on the shortened post url and the current content above', 'mashsb' ); } $str .= __( ' your tweet has a maximum of 140 characters. ', 'mashsb' ); if (!mashsb_yoast_active()){ $str .= __( 'If this is left blank the post title will be used. ', 'mashsb' ); }else{ $str .= __( 'If this is left blank the Yoast Twitter Title or post title will be used. ', 'mashsb' ); } return $str; }