| | 1276 | /** |
| | 1277 | * Output the Add new post button to blog. |
| | 1278 | * |
| | 1279 | * @since BuddyPress (2.2.0) |
| | 1280 | */ |
| | 1281 | function bp_blog_new_post_button() { |
| | 1282 | echo bp_get_blog_new_post_button(); |
| | 1283 | } |
| | 1284 | /** |
| | 1285 | * Get the Add new post to blog button. |
| | 1286 | * |
| | 1287 | * @since BuddyPress (2.2.0) |
| | 1288 | * |
| | 1289 | * @see BP_Button for a complete description of arguments and return |
| | 1290 | * value. |
| | 1291 | * |
| | 1292 | * @param array $args { |
| | 1293 | * Arguments are listed below, with their default values. For a |
| | 1294 | * complete description of arguments, see {@link BP_Button}. |
| | 1295 | * @type string $id Default: 'add_blog_post'. |
| | 1296 | * @type string $component Default: 'blogs'. |
| | 1297 | * @type bool $must_be_logged_in Default: true. |
| | 1298 | * @type bool $block_self Default: false. |
| | 1299 | * @type string $wrapper_class Default: 'blog-button add-post'. |
| | 1300 | * @type string $link_href Permalink of the wp-admin/post-new.php current blog in the loop. |
| | 1301 | * @type string $link_class Default: 'blog-button add-post'. |
| | 1302 | * @type string $link_text Default: 'Add post to site'. |
| | 1303 | * @type string $link_title Default: 'Add post to site'. |
| | 1304 | * } |
| | 1305 | * @return string The HTML for the Visit button. |
| | 1306 | */ |
| | 1307 | function bp_get_blog_new_post_button() { |
| | 1308 | if ( ! is_user_logged_in() ) { |
| | 1309 | return false; |
| | 1310 | } |
| | 1311 | if ( ! bp_current_user_can( 'edit_posts', bp_get_blog_id() ) ) { |
| | 1312 | return false; |
| | 1313 | } |
| | 1314 | $button_args = array( |
| | 1315 | 'id' => 'add_blog_post', |
| | 1316 | 'component' => 'blogs', |
| | 1317 | 'must_be_logged_in' => true, |
| | 1318 | 'block_self' => false, |
| | 1319 | 'link_text' => __( 'Add post to site', 'buddypress' ), |
| | 1320 | 'link_title' => __( 'Add post to site', 'buddypress' ), |
| | 1321 | 'link_class' => 'blog-button add-post', |
| | 1322 | 'link_href' => bp_get_blog_permalink() . 'wp-admin/post-new.php', |
| | 1323 | 'wrapper_class' => 'blog-button add-post', |
| | 1324 | ); |
| | 1325 | |
| | 1326 | return bp_get_button( apply_filters( 'bp_get_blog_new_post_button', $button_args ) ); |
| | 1327 | } |
| | 1328 | |