...
 
Commits (7)
......@@ -14,7 +14,7 @@ define("ADVANCED_VIEW",false);
<svg aria-hidden="true" class="octicon octicon-mark-github" height="32" version="1.1" viewBox="0 0 16 16" width="32"><path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path></svg>
</a>
<a href="https://paypal.me/51edpo" target="_blank"><img src="<?php echo plugins_url( 'img/paypal.png', __FILE__ );?>" style="height:30px;"></a> <a href="https://patreon.com/simonfrey" target="_blank"><img src="<?php echo plugins_url( 'img/patron.png', __FILE__ );?>" style="height:30px;"></a> <a href="https://liberapay.com/Mastodon-Auto-Share-Team/donate" target="_blank"><img src="<?php echo plugins_url( 'img/donate.svg', __FILE__ );?>"></a>
<a href="https://paypal.me/51edpo" target="_blank"><img src="<?php echo plugins_url( 'img/paypal.png', __FILE__ );?>" style="height:30px;"></a>
<br>
<br>
<?php if(ACCOUNT_CONNECTED): ?>
......@@ -117,6 +117,15 @@ define("ADVANCED_VIEW",false);
</td>
</tr>
<tr style="display:<?php echo ACCOUNT_CONNECTED ? "block" : "none"?>">
<th scope="row">
<label for="cats_as_tags"><?php esc_html_e( 'Use categories as tags', 'autopost-to-mastodon' ); ?></label>
</th>
<td>
<input type="checkbox" id="cats_as_tags" name="cats_as_tags" value="on" <?php echo ( $cats_as_tags == 'on')?'checked':''; ?>>
</td>
</tr>
<tr style="display:<?php echo ACCOUNT_CONNECTED ? "block" : "none"?>">
<th scope="row">
<label for="autopost_standard"><?php esc_html_e( 'Autopost new posts', 'autopost-to-mastodon' ); ?></label>
......@@ -124,7 +133,30 @@ define("ADVANCED_VIEW",false);
<td>
<input type="checkbox" id="autopost_standard" name="autopost_standard" value="on" <?php echo ( $autopost == 'on')?'checked':''; ?>>
</td>
</tr>
</tr>
<tr style="display:<?php echo ACCOUNT_CONNECTED ? "block" : "none"?>">
<th scope="row">
<label for="post_types"><?php esc_html_e( 'Choose active post types', 'autopost-to-mastodon' ); ?></label>
</th>
<td>
<fieldset id="post_types">
<?php
// get all post types
$args = array(
'public' => true,
// '_builtin' => false,
);
$output = 'objects';
$operator = 'and';
$wp_post_types = get_post_types( $args, $output, $operator );
foreach ( $wp_post_types as $post_type ) {
$checked = ($post_types[$post_type->name] == 'on')?'checked':'';
echo "<label for=\"" . $post_type->name . "\"><input type=\"checkbox\" id=\"" . $post_type->name . "\" name=\"" . $post_type->name . "\"" . $checked . " />" . $post_type->label . "</label></br>";
}
?>
</fieldset>
</td>
</tr>
</tbody>
</table>
......
......@@ -107,4 +107,8 @@ msgid "characters"
msgstr "Zeichen"
msgid "View Toot"
msgstr "Zum Toot"
\ No newline at end of file
msgstr "Zum Toot"
msgid "Choose active post types"
msgstr "Aktiviere für folgende Post-Types"
......@@ -3,9 +3,9 @@
* Plugin Name: Mastodon Autopost
* Plugin URI: https://github.com/simonfrey/mastodon_wordpress_autopost
* Description: A Wordpress Plugin that automatically posts your new articles to Mastodon
* Version: 3.4
* Version: 3.6
* Author: L1am0
* Author URI: http://www.simon-frey.eu
* Author URI: https://www.simon-frey.eu
* License: GPL2
* Text Domain: autopost-to-mastodon
* Domain Path: /languages
......@@ -208,6 +208,30 @@ class autopostToMastodon
update_option('autopostToMastodon-postOnStandard', 'off');
}
if (isset($_POST['cats_as_tags'])) {
update_option('autopostToMastodon-catsAsTags', 'on');
} else {
update_option('autopostToMastodon-catsAsTags', 'off');
}
// get all post types
$args = array(
'public' => true,
);
$output = 'names';
$operator = 'and';
$post_types = get_post_types( $args, $output, $operator );
// check post for content type configs
foreach ( $post_types as $post_type ) {
if (isset($_POST[$post_type]) ? $_POST[$post_type] : "off" == "on") {
update_option("autopostToMastodon-post_types-$post_type", 'on');
}
else {
update_option("autopostToMastodon-post_types-$post_type", 'off');
}
}
update_option('autopostToMastodon-content-warning', sanitize_textarea_field($content_warning));
$account = $client->verify_credentials($token);
......@@ -248,6 +272,21 @@ class autopostToMastodon
$toot_size = get_option('autopostToMastodon-toot-size', 500);
$content_warning = get_option('autopostToMastodon-content-warning', '');
$autopost = get_option('autopostToMastodon-postOnStandard', 'on');
$cats_as_tags = get_option('autopostToMastodon-catsAsTags', 'on');
$post_types = [];
// get all post types
$args = array(
'public' => true,
);
$output = 'names';
$operator = 'and';
$wp_post_types = get_post_types( $args, $output, $operator );
// add form context data for post type options
foreach ( $wp_post_types as $post_type ) {
$post_types[$post_type] = get_option("autopostToMastodon-post_types-$post_type", 'on');
}
include 'form.tpl.php';
}
......@@ -413,14 +452,33 @@ class autopostToMastodon
*/
public function add_metabox()
{
add_meta_box(
'autopostToMastodon_metabox',
'Mastodon Autopost',
array($this, 'metabox'),
['post', 'page'],
'side',
'high'
$active_post_types = [];
// get all post types
$args = array(
'public' => true,
);
$output = 'names';
$operator = 'and';
$post_types = get_post_types( $args, $output, $operator );
// add form context data for post type options
foreach ( $post_types as $post_type ) {
if (get_option("autopostToMastodon-post_types-$post_type", 'on') == 'on') {
array_push($active_post_types, $post_type);
}
}
// empty array activates everywhere -> check
if (!empty($active_post_types)) {
add_meta_box(
'autopostToMastodon_metabox',
'Mastodon Autopost',
array($this, 'metabox'),
$active_post_types,
'side',
'high'
);
}
}
/**
......@@ -472,18 +530,27 @@ class autopostToMastodon
$message_template = str_replace("[permalink]", $post_permalink, $message_template);
//Replace tags
$post_tags = get_the_tags($id);
$post_tags_content = '';
$cats_as_tags = get_option('autopostToMastodon-catsAsTags', 'off');
if ($cats_as_tags == 'on') {
$post_cats = get_the_category($id);
if (sizeof($post_cats) > 0 && $post_cats) {
foreach ($post_cats as $cat) {
$post_tags_content = $post_tags_content . '#' . preg_replace('/\s+/', '', html_entity_decode($cat->name, ENT_COMPAT, 'UTF-8')) . ' ';
}
}
}
$post_tags = get_the_tags($id);
if (sizeof($post_tags) > 0) {
$post_tags_content = '';
if ($post_tags) {
foreach ($post_tags as $tag) {
$post_tags_content = $post_tags_content . '#' . preg_replace('/\s+/', '', html_entity_decode($tag->name, ENT_COMPAT, 'UTF-8')) . ' ';
}
$post_tags_content = trim($post_tags_content);
}
$message_template = str_replace("[tags]", $post_tags_content, $message_template);
}
$message_template = str_replace("[tags]", $post_tags_content, $message_template);
//Replace excerpt
//Replace with the excerpt of the post
......
......@@ -2,10 +2,10 @@
Contributors: l1am0, Hellexis
Tags: mastodon, Mastodon, Mastdon Autopost, federated web, GNU social, statusnet, social web, social media, auto post
Requires at least: 4.6
Tested up to: 5.2.1
Stable tag: 3.4
Tested up to: 5.3.2
Stable tag: 3.6
License: GPLv2
Donate link: https://patreon.com/simonfrey
Donate link: https://paypal.me/51edpo
License URI: http://www.gnu.org/licenses/gpl-2.0.html
A Wordpress Plugin that automatically posts your new articles to Mastodon. The best: It is set and forget!
......@@ -26,7 +26,7 @@ For any questions, do not hesitate to contact me:
Do you want to help translating this plugin in your language? [Visit the translation page](https://translate.wordpress.org/projects/wp-plugins/autopost-to-mastodon)
Please consider donating via [Patreon](https://patreon.com/simonfrey), [PayPal](https://paypal.me/51edpo) or [Liberapay](https://liberapay.com/Mastodon-Auto-Share-Team/donate) <3
Please consider donating via [PayPal](https://paypal.me/51edpo) <3
== Frequently Asked Questions ==
......@@ -46,6 +46,12 @@ The plugin never transmits any data to me, or anyone else than the mastodon node
== Changelog ==
= 3.6 =
* Allow the plugin to work on custom post types (Thanks to [unicode-it](https://github.com/unicode-it))
= 3.5 =
* Use categorys as hashtags on posts (Thanks to [rseabra](https://github.com/rseabra))
= 3.4 =
* Fix for the manual added excerpt to also get encoded and remove html tags
......
......@@ -10,4 +10,15 @@ delete_option( 'autopostToMastodon-instance' );
delete_option( 'autopostToMastodon-message' );
delete_option( 'autopostToMastodon-mode' );
delete_option( 'autopostToMastodon-toot-size' );
delete_option( 'autopostToMastodon-notice' );
\ No newline at end of file
delete_option( 'autopostToMastodon-notice' );
// get all post types
$args = array(
'public' => true,
);
$output = 'names';
$operator = 'and';
$post_types = get_post_types( $args, $output, $operator );
// delete configs for all post_types
foreach ( $post_types as $post_type ) {
delete_option("autopostToMastodon-post_types-$post_type" );
}
......@@ -77,12 +77,15 @@ function bp_activity_action_post_update() {
* Filters activity object for BuddyPress core and plugin authors before posting activity update.
*
* @since 1.2.0
* @since 5.0.0 Fixed filter signature to match other instances of filter,
* with $activity_id as the first param.
*
* @param string $object Activity item being associated to.
* @param string $item_id Component ID being posted to.
* @param string $content Activity content being posted.
* @param int $activity_id ID of the activity item.
* @param string $object Activity item being associated to.
* @param string $item_id Component ID being posted to.
* @param string $content Activity content being posted.
*/
$activity_id = apply_filters( 'bp_activity_custom_update', $object, $item_id, $content );
$activity_id = apply_filters( 'bp_activity_custom_update', 0, $object, $item_id, $content );
}
// Provide user feedback.
......
......@@ -310,7 +310,7 @@ function bp_activity_admin_load() {
) );
wp_enqueue_style( 'bp_activity_admin_css', $bp->plugin_url . "bp-activity/admin/css/admin{$min}.css", array(), bp_get_version() );
wp_style_add_data( 'bp_activity_admin_css', 'rtl', true );
wp_style_add_data( 'bp_activity_admin_css', 'rtl', 'replace' );
if ( $min ) {
wp_style_add_data( 'bp_activity_admin_css', 'suffix', $min );
}
......@@ -840,13 +840,19 @@ function bp_activity_admin_get_activity_actions() {
$action = array_values( (array) $action );
for ( $i = 0, $i_count = count( $action ); $i < $i_count; $i++ ) {
/**
* Don't take in account:
* - a mis-named Friends activity type from before BP 1.6,
* - The Group's component 'activity_update' one as the Activity component is using it.
*/
if ( 'friends_register_activity_action' === $action[$i]['key'] || 'bp_groups_format_activity_action_group_activity_update' === $action[$i]['format_callback'] ) {
continue;
}
$actions[ $action[$i]['key'] ] = $action[$i]['value'];
}
}
// This was a mis-named activity type from before BP 1.6.
unset( $actions['friends_register_activity_action'] );
// Sort array by the human-readable value.
natsort( $actions );
......@@ -870,13 +876,20 @@ function bp_activity_admin_edit_metabox_type( $item ) {
foreach ( bp_activity_get_actions() as $action ) {
$action = array_values( (array) $action );
for ( $i = 0, $i_count = count( $action ); $i < $i_count; $i++ )
for ( $i = 0, $i_count = count( $action ); $i < $i_count; $i++ ) {
/**
* Don't take in account:
* - a mis-named Friends activity type from before BP 1.6,
* - The Group's component 'activity_update' one as the Activity component is using it.
*/
if ( 'friends_register_activity_action' === $action[$i]['key'] || 'bp_groups_format_activity_action_group_activity_update' === $action[$i]['format_callback'] ) {
continue;
}
$actions[ $action[$i]['key'] ] = $action[$i]['value'];
}
}
// This was a mis-named activity type from before BP 1.6.
unset( $actions['friends_register_activity_action'] );
// Sort array by the human-readable value.
natsort( $actions );
......
......@@ -36,7 +36,7 @@ function bp_activity_mentions_script() {
wp_enqueue_script( 'bp-mentions', buddypress()->plugin_url . "bp-activity/js/mentions{$min}.js", array( 'jquery', 'jquery-atwho' ), bp_get_version(), true );
wp_enqueue_style( 'bp-mentions-css', buddypress()->plugin_url . "bp-activity/css/mentions{$min}.css", array(), bp_get_version() );
wp_style_add_data( 'bp-mentions-css', 'rtl', true );
wp_style_add_data( 'bp-mentions-css', 'rtl', 'replace' );
if ( $min ) {
wp_style_add_data( 'bp-mentions-css', 'suffix', $min );
}
......
......@@ -818,14 +818,16 @@ add_filter( 'bp_activity_set_mentions_scope_args', 'bp_activity_filter_mentions_
* Registers Activity personal data exporter.
*
* @since 4.0.0
* @since 5.0.0 adds an `exporter_bp_friendly_name` param to exporters.
*
* @param array $exporters An array of personal data exporters.
* @return array An array of personal data exporters.
*/
function bp_activity_register_personal_data_exporter( $exporters ) {
$exporters['buddypress-activity'] = array(
'exporter_friendly_name' => __( 'BuddyPress Activity Data', 'buddypress' ),
'callback' => 'bp_activity_personal_data_exporter',
'exporter_friendly_name' => __( 'BuddyPress Activity Data', 'buddypress' ),
'callback' => 'bp_activity_personal_data_exporter',
'exporter_bp_friendly_name' => _x( 'Activity Data', 'BuddyPress Activity data exporter friendly name', 'buddypress' ),
);
return $exporters;
......
......@@ -3848,6 +3848,11 @@ function bp_activity_show_filters( $context = '' ) {
$action['key'] = 'friendship_accepted,friendship_created';
}
// The 'activity_update' filter is already used by the Activity component.
if ( 'bp_groups_format_activity_action_group_activity_update' === $action['format_callback'] ) {
continue;
}
$filters[ $action['key'] ] = $action['label'];
}
......
......@@ -360,8 +360,10 @@ class BP_Activity_Activity {
public static function get( $args = array() ) {
global $wpdb;
$function_args = func_get_args();
// Backward compatibility with old method of passing arguments.
if ( !is_array( $args ) || func_num_args() > 1 ) {
if ( !is_array( $args ) || count( $function_args ) > 1 ) {
_deprecated_argument( __METHOD__, '1.6', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) );
$old_args_keys = array(
......@@ -378,7 +380,7 @@ class BP_Activity_Activity {
10 => 'spam'
);
$args = bp_core_parse_args_array( $old_args_keys, func_get_args() );
$args = bp_core_parse_args_array( $old_args_keys, $function_args );
}
$bp = buddypress();
......@@ -1467,6 +1469,8 @@ class BP_Activity_Activity {
public static function get_activity_comments( $activity_id, $left, $right, $spam = 'ham_only', $top_level_parent_id = 0 ) {
global $wpdb;
$function_args = func_get_args();
if ( empty( $top_level_parent_id ) ) {
$top_level_parent_id = $activity_id;
}
......@@ -1514,7 +1518,7 @@ class BP_Activity_Activity {
* @param BP_Activity_Activity $value Magic method referring to currently called method.
* @param array $func_args Array of the method's argument list.
*/
if ( apply_filters( 'bp_use_legacy_activity_query', false, __METHOD__, func_get_args() ) ) {
if ( apply_filters( 'bp_use_legacy_activity_query', false, __METHOD__, $function_args ) ) {
/**
* Filters the MySQL prepared statement for the legacy activity query.
......@@ -1539,6 +1543,7 @@ class BP_Activity_Activity {
$descendant_ids = $wpdb->get_col( $sql );
$descendants = self::get_activity_data( $descendant_ids );
$descendants = self::append_user_fullnames( $descendants );
$descendants = self::generate_action_strings( $descendants );
}
$ref = array();
......
......@@ -124,9 +124,30 @@ class BP_Activity_Component extends BP_Component {
require $this->path . 'bp-activity/screens/just-me.php';
}
// Screens - User secondary nav.
if ( bp_is_user() && in_array( bp_current_action(), array( 'friends', 'groups', 'favorites', 'mentions' ), true ) ) {
require $this->path . 'bp-activity/screens/' . bp_current_action() . '.php';
/**
* Screens - User secondary nav.
*
* For these specific actions, slugs can be customized using `BP_{COMPONENT}_SLUGS`.
* As a result, we need to map filenames with slugs.
*/
$filenames = array(
'favorites' => 'favorites',
'mentions' => 'mentions',
);
if ( bp_is_active( 'friends' ) ) {
$filenames[bp_get_friends_slug()] = 'friends';
}
if ( bp_is_active( 'groups' ) ) {
$filenames[bp_get_groups_slug()] = 'groups';
}
// The slug is the current action requested.
$slug = bp_current_action();
if ( bp_is_user() && isset( $filenames[ $slug ] ) ) {
require $this->path . 'bp-activity/screens/' . $filenames[ $slug ] . '.php';
}
// Screens - Single permalink.
......@@ -435,4 +456,16 @@ class BP_Activity_Component extends BP_Component {
parent::setup_cache_groups();
}
/**
* Init the BP REST API.
*
* @since 5.0.0
*
* @param array $controllers Optional. See BP_Component::rest_api_init() for
* description.
*/
public function rest_api_init( $controllers = array() ) {
parent::rest_api_init( array( 'BP_REST_Activity_Endpoint' ) );
}
}
......@@ -338,11 +338,7 @@ class BP_Activity_List_Table extends WP_List_Table {
*
* @return array Key/value pairs for the bulk actions dropdown.
*/
function get_bulk_actions() {
$actions = array();
$actions['bulk_spam'] = __( 'Mark as Spam', 'buddypress' );
$actions['bulk_ham'] = __( 'Not Spam', 'buddypress' );
$actions['bulk_delete'] = __( 'Delete Permanently', 'buddypress' );
public function get_bulk_actions() {
/**
* Filters the default bulk actions so plugins can add custom actions.
......@@ -351,7 +347,11 @@ class BP_Activity_List_Table extends WP_List_Table {
*
* @param array $actions Default available actions for bulk operations.
*/
return apply_filters( 'bp_activity_list_table_get_bulk_actions', $actions );
return apply_filters( 'bp_activity_list_table_get_bulk_actions', array(
'bulk_spam' => __( 'Mark as Spam', 'buddypress' ),
'bulk_ham' => __( 'Not Spam', 'buddypress' ),
'bulk_delete' => __( 'Delete Permanently', 'buddypress' ),
) );
}
/**
......@@ -364,6 +364,7 @@ class BP_Activity_List_Table extends WP_List_Table {
* @return array The columns to appear in the Activity list table.
*/
function get_columns() {
/**
* Filters the titles for the columns for the activity list table.
*
......@@ -373,7 +374,7 @@ class BP_Activity_List_Table extends WP_List_Table {
*/
return apply_filters( 'bp_activity_list_table_get_columns', array(
'cb' => '<input name type="checkbox" />',
'author' => _x('Author', 'Admin SWA column header', 'buddypress' ),
'author' => _x( 'Author', 'Admin SWA column header', 'buddypress' ),
'comment' => _x( 'Activity', 'Admin SWA column header', 'buddypress' ),
'action' => _x( 'Action', 'Admin SWA column header', 'buddypress' ),
'response' => _x( 'In Response To', 'Admin SWA column header', 'buddypress' ),
......@@ -383,20 +384,20 @@ class BP_Activity_List_Table extends WP_List_Table {
/**
* Get the column names for sortable columns.
*
* Currently, returns an empty array (no columns are sortable).
*
* @since 1.6.0
* @todo For this to work, BP_Activity_Activity::get() needs updating
* to support ordering by specific fields.
*
* @return array The columns that can be sorted on the Activity screen.
*/
function get_sortable_columns() {
return array();
public function get_sortable_columns() {
/*return array(
'author' => array( 'activity_author', false ), // Intentionally not using "=>"
);*/
/**
* Filters the column names for the sortable columns.
*
* @since 5.0.0
*
* @param array $value Array of column names.
*/
return apply_filters( 'bp_activity_list_table_get_sortable_columns', array() );
}
/**
......@@ -434,6 +435,11 @@ class BP_Activity_List_Table extends WP_List_Table {
$component = 'xprofile';
}
// The 'activity_update' filter is already used by the Activity component.
if ( isset( $actions->activity_update ) && 'bp_groups_format_activity_action_group_activity_update' === $actions->activity_update['format_callback'] ) {
unset( $actions->activity_update );
}
if ( bp_is_active( $component ) ) {
if ( $component === 'xprofile' ) {
$component_name = buddypress()->profile->name;
......@@ -454,7 +460,7 @@ class BP_Activity_List_Table extends WP_List_Table {
<?php
// Skip the incorrectly named pre-1.6 action.
if ( 'friends_register_activity_action' !== $action_key ) : ?>
if ( 'friends_register_activity_action' !== $action_key ) : ?>
<option value="<?php echo esc_attr( $action_key ); ?>" <?php selected( $action_key, $selected ); ?>><?php echo esc_html( $action_values[ 'value' ] ); ?></option>
......
......@@ -139,8 +139,10 @@ class BP_Activity_Template {
public function __construct( $args ) {
$bp = buddypress();
$function_args = func_get_args();
// Backward compatibility with old method of passing arguments.
if ( !is_array( $args ) || func_num_args() > 1 ) {
if ( !is_array( $args ) || count( $function_args ) > 1 ) {
_deprecated_argument( __METHOD__, '1.6', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) );
$old_args_keys = array(
......@@ -159,7 +161,7 @@ class BP_Activity_Template {
12 => 'page_arg'
);
$args = bp_core_parse_args_array( $old_args_keys, func_get_args() );
$args = bp_core_parse_args_array( $old_args_keys, $function_args );
}
$defaults = array(
......
......@@ -61,7 +61,8 @@ class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
echo $args['before_widget'];
echo $args['before_title'] . $title . $args['after_title'];
if ( empty( $instance['max_posts'] ) || empty( $instance['max_posts'] ) ) {
$max_limit = bp_get_widget_max_count_limit( __CLASS__ );
if ( empty( $instance['max_posts'] ) || $instance['max_posts'] > $max_limit ) {
$instance['max_posts'] = 10;
}
......@@ -128,10 +129,13 @@ class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
* @return array $instance The parsed options to be saved.
*/
public function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance = $old_instance;
$max_limit = bp_get_widget_max_count_limit( __CLASS__ );
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['max_posts'] = strip_tags( $new_instance['max_posts'] );
$instance['link_title'] = (bool) $new_instance['link_title'];
$instance['max_posts'] = $new_instance['max_posts'] > $max_limit ? $max_limit : intval( $new_instance['max_posts'] );
$instance['link_title'] = ! empty( $new_instance['link_title'] );
return $instance;
}
......@@ -150,15 +154,17 @@ class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
'link_title' => false,
) );
$max_limit = bp_get_widget_max_count_limit( __CLASS__ );
$title = strip_tags( $instance['title'] );
$max_posts = strip_tags( $instance['max_posts'] );
$max_posts = $instance['max_posts'] > $max_limit ? $max_limit : intval( $instance['max_posts'] );
$link_title = (bool) $instance['link_title'];
?>
<p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _ex( 'Title:', 'Label for the Title field of the Recent Networkwide Posts widget', 'buddypress' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" style="width: 100%;" /></label></p>
<p><label for="<?php echo $this->get_field_id( 'link_title' ); ?>"><input type="checkbox" name="<?php echo $this->get_field_name( 'link_title' ); ?>" value="1" <?php checked( $link_title ); ?> /> <?php _e( 'Link widget title to Blogs directory', 'buddypress' ); ?></label></p>
<p><label for="<?php echo $this->get_field_id( 'max_posts' ); ?>"><?php _e( 'Max posts to show:', 'buddypress' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_posts' ); ?>" name="<?php echo $this->get_field_name( 'max_posts' ); ?>" type="text" value="<?php echo esc_attr( $max_posts ); ?>" style="width: 30%" /></label></p>
<p><label for="<?php echo $this->get_field_id( 'max_posts' ); ?>"><?php _e( 'Max posts to show:', 'buddypress' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_posts' ); ?>" name="<?php echo $this->get_field_name( 'max_posts' ); ?>" type="number" min="1" max="<?php echo esc_attr( $max_limit ); ?>" value="<?php echo esc_attr( $max_posts ); ?>" style="width: 30%" /></label></p>
<?php
}
}
......@@ -1135,3 +1135,46 @@ function bp_core_admin_body_classes( $classes ) {
return $classes . ' buddypress';
}
add_filter( 'admin_body_class', 'bp_core_admin_body_classes' );
/**
* Adds a BuddyPress category to house BuddyPress blocks.
*
* @since 5.0.0
*
* @param array $categories Array of block categories.
* @param object $post Post being loaded.
*/
function bp_block_category( $categories = array(), $post = null ) {
if ( ! ( $post instanceof WP_Post ) ) {
return $categories;
}
/**
* Filter here to add/remove the supported post types for the BuddyPress blocks category.
*
* @since 5.0.0
*
* @param array $value The list of supported post types. Defaults to WordPress built-in ones.
*/
$post_types = apply_filters( 'bp_block_category_post_types', array( 'post', 'page' ) );
if ( ! $post_types ) {
return $categories;
}
// Get the post type of the current item.
$post_type = get_post_type( $post );
if ( ! in_array( $post_type, $post_types, true ) ) {
return $categories;
}
return array_merge( $categories, array(
array(
'slug' => 'buddypress',
'title' => __( 'BuddyPress', 'buddypress' ),
'icon' => 'buddicons-buddypress-logo',
),
) );
}
add_filter( 'block_categories', 'bp_block_category', 1, 2 );
......@@ -382,6 +382,11 @@ function bp_core_install_extended_profiles() {
if ( ! $wpdb->get_var( "SELECT id FROM {$bp_prefix}bp_xprofile_fields WHERE id = 1" ) ) {
$insert_sql[] = "INSERT INTO {$bp_prefix}bp_xprofile_fields ( group_id, parent_id, type, name, description, is_required, can_delete ) VALUES ( 1, 0, 'textbox', " . $wpdb->prepare( '%s', stripslashes( bp_get_option( 'bp-xprofile-fullname-field-name' ) ) ) . ", '', 1, 0 );";
// Make sure the custom visibility is disabled for the default field.
if ( ! $wpdb->get_var( "SELECT id FROM {$bp_prefix}bp_xprofile_meta WHERE id = 1" ) ) {
$insert_sql[] = "INSERT INTO {$bp_prefix}bp_xprofile_meta ( object_id, object_type, meta_key, meta_value ) VALUES ( 1, 'field', 'allow_custom_visibility', 'disabled' );";
}
}
dbDelta( $insert_sql );
......@@ -535,3 +540,49 @@ function bp_core_install_emails() {
*/
do_action( 'bp_core_install_emails' );
}
/**
* Install database tables for the Invitations API
*
* @since 5.0.0
*
* @uses bp_core_set_charset()
* @uses bp_core_get_table_prefix()
* @uses dbDelta()
*/
function bp_core_install_invitations() {
$sql = array();
$charset_collate = $GLOBALS['wpdb']->get_charset_collate();
$bp_prefix = bp_core_get_table_prefix();
$sql[] = "CREATE TABLE {$bp_prefix}bp_invitations (
id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
user_id bigint(20) NOT NULL,
inviter_id bigint(20) NOT NULL,
invitee_email varchar(100) DEFAULT NULL,
class varchar(120) NOT NULL,
item_id bigint(20) NOT NULL,
secondary_item_id bigint(20) DEFAULT NULL,
type varchar(12) NOT NULL DEFAULT 'invite',
content longtext DEFAULT '',
date_modified datetime NOT NULL,
invite_sent tinyint(1) NOT NULL DEFAULT '0',
accepted tinyint(1) NOT NULL DEFAULT '0',
KEY user_id (user_id),
KEY inviter_id (inviter_id),
KEY invitee_email (invitee_email),
KEY class (class),
KEY item_id (item_id),
KEY secondary_item_id (secondary_item_id),
KEY type (type),
KEY invite_sent (invite_sent),
KEY accepted (accepted)
) {$charset_collate};";
dbDelta( $sql );
/**
* Fires after BuddyPress adds the invitations table.
*
* @since 5.0.0
*/
do_action( 'bp_core_install_invitations' );
}
......@@ -488,3 +488,82 @@ function bp_core_admin_notice_repopulate_blogs_resume() {
echo '<div class="error"><p>' . __( 'It looks like you have more sites to record. Resume recording by checking the "Repopulate site tracking records" option.', 'buddypress' ) . '</p></div>';
}
add_action( 'network_admin_notices', 'bp_core_admin_notice_repopulate_blogs_resume' );
/**
* Add BuddyPress debug info to the WordPress Site Health info screen.
*
* @since 5.0.0
*
* @param array $debug_info The Site's debug info.
* @return array The Site's debug info, including the BuddyPress specific ones.
*/
function bp_core_admin_debug_information( $debug_info = array() ) {
global $wp_settings_fields;
$active_components = array_intersect_key( bp_core_get_components(), buddypress()->active_components );
$bp_settings = array();
foreach ( $wp_settings_fields['buddypress'] as $section => $settings ) {
$prefix = '';
$component_id = str_replace( 'bp_', '', $section );
if ( isset( $active_components[ $component_id ]['title'] ) ) {
$prefix = $active_components[ $component_id ]['title'] .': ';
}
foreach( $settings as $bp_setting ) {
$reverse = (
strpos( $bp_setting['id'], 'hide' ) !== false ||
strpos( $bp_setting['id'], 'restrict' ) !== false ||
strpos( $bp_setting['id'], 'disable' ) !== false
);
if ( ! isset( $bp_setting['id'] ) || '_bp_theme_package_id' === $bp_setting['id'] ) {
continue;
}
$bp_setting_value = bp_get_option( $bp_setting['id'] );
if ( '0' === $bp_setting_value || '1' === $bp_setting_value ) {
if ( ( $reverse && '0' === $bp_setting_value ) || ( ! $reverse && '1' === $bp_setting_value ) ) {
$bp_setting_value = __( 'Yes', 'buddypress' );
} else {
$bp_setting_value = __( 'No', 'buddypress' );
}
}
// Make sure to show the setting is reversed when site info is copied to clipboard.
$bp_settings_id = $bp_setting['id'];
if ( $reverse ) {
$bp_settings_id = '! ' . $bp_settings_id;
}
$bp_settings[ $bp_settings_id ] = array(
'label' => $prefix . $bp_setting['title'],
'value' => $bp_setting_value,
);
}
}
$debug_info['buddypress'] = array(
'label' => __( 'BuddyPress', 'buddypress' ),
'fields' => array_merge(
array(
'version' => array(
'label' => __( 'Version', 'buddypress' ),
'value' => bp_get_version(),
),
'active_components' => array(
'label' => __( 'Active components', 'buddypress' ),
'value' => implode( wp_list_pluck( $active_components, 'title' ), ', ' ),
),
'template_pack' => array(
'label' => __( 'Active template pack', 'buddypress' ),
'value' => bp_get_theme_compat_name() . ' ' . bp_get_theme_compat_version(),
),
),
$bp_settings
)
);
return $debug_info;
}
add_filter( 'debug_information', 'bp_core_admin_debug_information' );
......@@ -9,15 +9,12 @@ TABLE OF CONTENTS:
1.0 - Typography and colour
2.0 - Dashicons
3.0 - Elements
3.1 - Backdrop and container
3.2 - Modal footer
3.3 - Modal header
3.4 - Modal content
3.1 - Modal footer
3.2 - Modal content
4.0 - Content styles
4.1 - Backdrop and container
4.2 - Footer content
4.3 - Header content
4.4 - Content content
4.1 - Footer content
4.2 - Header content
4.3 - Content content
5.0 - Media
6.0 - Media Queries
6.1 - Desktop Medium
......@@ -32,48 +29,23 @@ TABLE OF CONTENTS:
--bp-hello-container-size: 15%;
}
#bp-hello-container a {
color: var(--bp-hello-color-primary);
.bp-hello-content p {
font-size: 16px;
}
#bp-hello-container a:hover {
transition: all 0.1s ease-in-out;
color: black;
.bp-hello-content ul,
.bp-hello-content ol {
list-style: inherit;
}
#bp-hello-container .bp-hello-header h1 {
line-height: 1.7;
font-size: 21px;
font-weight: 400;
}
.bp-hello-content p {
font-size: 16px;
.bp-hello-content h3 {
font-size: 1.1em;
font-weight: 500;
}
/*------------------------------------------------------------------------------
* 2.0 - Dashicons
*----------------------------------------------------------------------------*/
.bp-hello-close .button {
padding: 5px !important;
}
.bp-hello-close .close-modal:before {
content: "\f158";
color: #23282d;
/* wp toolbar */
font: 400 1.5em/1 dashicons;
speak: none;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
background-image: none !important;
}
.bp-hello-close .close-modal:focus:before, .bp-hello-close .close-modal:hover:before {
transition: all 0.1s ease-in-out;
color: var(--bp-hello-color-primary);
}
.bp-hello-social li a:before {
color: #23282d;
/* wp toolbar */
......@@ -97,41 +69,34 @@ TABLE OF CONTENTS:
content: "\f301";
}
/*------------------------------------------------------------------------------
* 3.0 - Elements
*----------------------------------------------------------------------------*/
/*
* 3.1 - Backdrop and container
*/
#bp-hello-backdrop {
position: fixed;
top: 0;
right: 0;
left: 0;
bottom: 0;
z-index: 9998;
display: none;
div.dashicons {
width: -webkit-fit-content;
width: fit-content;
}
#bp-hello-container {
position: fixed;
top: 0;
bottom: 80px;
z-index: 99999;
}
.bp-disable-scroll {
overflow: hidden;
div.dashicons.big {
font-size: 128px;
display: block;
color: var(--bp-hello-color-primary);
height: 128px;
width: 128px;
}
/*------------------------------------------------------------------------------
* 3.0 - Elements
*----------------------------------------------------------------------------*/
/*
* 3.2 - Modal footer
* 3.1 - Modal footer
*/
.bp-hello-footer {
#plugin-information-footer {
display: flex;
flex-wrap: wrap;
height: 58px;
max-height: 58px;
padding: 0 16px;
height: auto;
}
#plugin-information-footer .dashicons-heart {
color: #be3631;
}
.bp-hello-social-cta,
......@@ -156,92 +121,95 @@ TABLE OF CONTENTS:
}
/*
* 3.3 - Modal header
* 3.2 - Modal content
*/
.bp-hello-header {
height: 58px;
max-height: 58px;
#bp-hello-container {
display: none;
}
/*
* 3.4 - Modal content
*/
.bp-hello-content {
padding: 0 25px;
height: calc(100% - 58px);
overflow-y: auto;
-webkit-overflow-scrolling: touch;
padding-bottom: 20px;
}
/*------------------------------------------------------------------------------
* 4.0 - Content styles
*----------------------------------------------------------------------------*/
/*
* 4.1 - Backdrop and container
*/
#bp-hello-backdrop {
background-color: rgba(0, 0, 0, 0.8);
transition: opacity 0.15s ease-out;
#dynamic-content {
padding-bottom: 40px;
display: none;
}
#bp-hello-container {
background-color: white;
#dynamic-content.show {
display: block;
}
/*
* 4.2 - Footer content
*/
.bp-hello-footer {
border-radius: 0 0 3px 3px;
background-color: white;
border-top: 1px solid var(--bp-hello-color-secondary);
padding: 6px 25px;
.plugin-details-modal #TB_title {
/* stylelint-disable-line */
height: 0;
background: none;
border: none;
}
.bp-hello-footer p {
font-size: 15px;
#TB_window.plugin-details-modal.thickbox-loading:before {
/* stylelint-disable-line */
z-index: 10;
margin-top: 40px;
background-color: none;
}
.bp-hello-social-cta {
text-align: right;
.bp-hello-aligncenter * {
margin: 10px auto;
}
.bp-hello-social-links {
text-align: left;
.bp-hello-alignleft {
float: right;
}
.bp-hello-social li a {
text-decoration: none;
.bp-hello-alignleft:after {
content: "";
clear: right;
}
/*
* 4.3 - Header content
*/
.bp-hello-header {
padding: 6px 25px;
.bp-hello-alignright {
float: left;
}
.bp-hello-header h1 {
width: calc(100%