Changeset 12999
- Timestamp:
- 07/14/2021 09:15:41 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 14 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Gruntfile.js
r12995 r12999 38 38 '!bp-groups/css/blocks/group.css', 39 39 '!bp-members/css/blocks/members.css', 40 '!bp-groups/css/blocks/groups.css' 40 '!bp-groups/css/blocks/groups.css', 41 '!bp-core/css/blocks/login-form.css' 41 42 ], 42 43 … … 148 149 src: ['bp-groups/sass/blocks/*.scss'], 149 150 dest: SOURCE_DIR + 'bp-groups/css/blocks/' 151 }, 152 core_blocks: { 153 cwd: SOURCE_DIR, 154 extDot: 'last', 155 expand: true, 156 ext: '.css', 157 flatten: true, 158 src: ['bp-core/sass/blocks/*.scss'], 159 dest: SOURCE_DIR + 'bp-core/css/blocks/' 150 160 } 151 161 }, -
trunk/src/bp-core/bp-core-blocks.php
r12998 r12999 211 211 } 212 212 add_filter( 'widget_block_dynamic_classname', 'bp_widget_block_dynamic_classname', 10, 2 ); 213 214 /** 215 * Create a link to the registration form for use on the bottom of the login form widget. 216 * 217 * @since 9.0.0 218 * 219 * @param string $content Content to display. Default empty. 220 * @param array $args Array of login form arguments. 221 * @return string HTML output. 222 */ 223 function bp_blocks_get_login_widget_registration_link( $content = '', $args = array() ) { 224 if ( isset( $args['form_id'] ) && 'bp-login-widget-form' === $args['form_id'] && bp_get_signup_allowed() ) { 225 $content .= sprintf( 226 '<p class="bp-login-widget-register-link"><a href="%1$s">%2$s</a></p>', 227 esc_url( bp_get_signup_page() ), 228 esc_html__( 'Register', 'buddypress' ) 229 ); 230 } 231 232 $action_output = ''; 233 if ( has_action( 'bp_login_widget_form' ) ) { 234 ob_start(); 235 /** 236 * Fires inside the display of the login widget form. 237 * 238 * @since 2.4.0 239 */ 240 do_action( 'bp_login_widget_form' ); 241 $action_output = ob_get_clean(); 242 } 243 244 if ( $action_output ) { 245 $content .= $action_output; 246 } 247 248 return $content; 249 } 250 251 /** 252 * Callback function to render the BP Login Form. 253 * 254 * @since 9.0.0 255 * 256 * @param array $attributes The block attributes. 257 * @return string HTML output. 258 */ 259 function bp_block_render_login_form_block( $attributes = array() ) { 260 $block_args = wp_parse_args( 261 $attributes, 262 array( 263 'title' => '', 264 ) 265 ); 266 267 $title = $block_args['title']; 268 269 $classnames = 'widget_bp_core_login_widget buddypress widget'; 270 $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classnames ) ); 271 272 $widget_content = ''; 273 274 if ( $title ) { 275 $widget_content .= sprintf( 276 '<h2 class="widget-title">%s</h2>', 277 esc_html( $title ) 278 ); 279 } 280 281 if ( is_user_logged_in() ) { 282 $action_output = ''; 283 if ( has_action( 'bp_before_login_widget_loggedin' ) ) { 284 ob_start(); 285 /** 286 * Fires before the display of widget content if logged in. 287 * 288 * @since 1.9.0 289 */ 290 do_action( 'bp_before_login_widget_loggedin' ); 291 $action_output = ob_get_clean(); 292 } 293 294 if ( $action_output ) { 295 $widget_content .= $action_output; 296 } 297 298 $widget_content .= sprintf( 299 '<div class="bp-login-widget-user-avatar"> 300 <a href="%1$s"> 301 %2$s 302 </a> 303 </div>', 304 bp_loggedin_user_domain(), 305 bp_get_loggedin_user_avatar( 306 array( 307 'type' => 'thumb', 308 'width' => 50, 309 'height' => 50, 310 ) 311 ) 312 ); 313 314 $widget_content .= sprintf( 315 '<div class="bp-login-widget-user-links"> 316 <div class="bp-login-widget-user-link">%1$s</div> 317 <div class="bp-login-widget-user-logout"><a class="logout" href="%2$s">%3$s</a></div> 318 </div>', 319 bp_core_get_userlink( bp_loggedin_user_id() ), 320 wp_logout_url( bp_get_requested_url() ), 321 __( 'Log Out', 'buddypress' ) 322 ); 323 324 $action_output = ''; 325 if ( has_action( 'bp_after_login_widget_loggedin' ) ) { 326 ob_start(); 327 /** 328 * Fires after the display of widget content if logged in. 329 * 330 * @since 1.9.0 331 */ 332 do_action( 'bp_after_login_widget_loggedin' ); 333 $action_output = ob_get_clean(); 334 } 335 336 if ( $action_output ) { 337 $widget_content .= $action_output; 338 } 339 } else { 340 $action_output = ''; 341 if ( has_action( 'bp_before_login_widget_loggedout' ) ) { 342 ob_start(); 343 /** 344 * Fires before the display of widget content if logged out. 345 * 346 * @since 1.9.0 347 */ 348 do_action( 'bp_before_login_widget_loggedout' ); 349 $action_output = ob_get_clean(); 350 } 351 352 if ( $action_output ) { 353 $widget_content .= $action_output; 354 } 355 356 add_filter( 'login_form_bottom', 'bp_blocks_get_login_widget_registration_link', 10, 2 ); 357 358 $widget_content .= wp_login_form( 359 array( 360 'echo' => false, 361 'form_id' => 'bp-login-widget-form', 362 'id_username' => 'bp-login-widget-user-login', 363 'label_username' => __( 'Username', 'buddypress' ), 364 'id_password' => 'bp-login-widget-user-pass', 365 'label_password' => __( 'Password', 'buddypress' ), 366 'id_remember' => 'bp-login-widget-rememberme', 367 'id_submit' => 'bp-login-widget-submit', 368 ) 369 ); 370 371 remove_filter( 'login_form_bottom', 'bp_blocks_get_login_widget_registration_link', 10, 2 ); 372 373 $action_output = ''; 374 if ( has_action( 'bp_after_login_widget_loggedout' ) ) { 375 ob_start(); 376 /** 377 * Fires after the display of widget content if logged out. 378 * 379 * @since 1.9.0 380 */ 381 do_action( 'bp_after_login_widget_loggedout' ); 382 $action_output = ob_get_clean(); 383 } 384 385 if ( $action_output ) { 386 $widget_content .= $action_output; 387 } 388 } 389 390 if ( ! did_action( 'dynamic_sidebar_before' ) ) { 391 return sprintf( 392 '<div %1$s>%2$s</div>', 393 $wrapper_attributes, 394 $widget_content 395 ); 396 } 397 398 return $widget_content; 399 } -
trunk/src/bp-core/classes/class-bp-component.php
r12998 r12999 235 235 */ 236 236 public function setup_globals( $args = array() ) { 237 238 /** Slugs ************************************************************239 */240 241 // If a WP directory page exists for the component, it should242 // be the default value of 'root_slug'.243 $default_root_slug = isset( buddypress()->pages->{$this->id}->slug ) ? buddypress()->pages->{$this->id}->slug : '';244 245 237 $r = wp_parse_args( $args, array( 246 238 'slug' => $this->id, 247 'root_slug' => $default_root_slug,239 'root_slug' => '', 248 240 'has_directory' => false, 249 241 'directory_title' => '', … … 255 247 ) ); 256 248 257 /** 258 * Filters the slug to be used for the permalink URI chunk after root. 259 * 260 * @since 1.5.0 261 * 262 * @param string $value Slug to use in permalink URI chunk. 263 */ 264 $this->slug = apply_filters( 'bp_' . $this->id . '_slug', $r['slug'] ); 265 266 /** 267 * Filters the slug used for root directory. 268 * 269 * @since 1.5.0 270 * 271 * @param string $value Root directory slug. 272 */ 273 $this->root_slug = apply_filters( 'bp_' . $this->id . '_root_slug', $r['root_slug'] ); 274 275 /** 276 * Filters the component's top-level directory if available. 277 * 278 * @since 1.5.0 279 * 280 * @param bool $value Whether or not there is a top-level directory. 281 */ 282 $this->has_directory = apply_filters( 'bp_' . $this->id . '_has_directory', $r['has_directory'] ); 283 284 /** 285 * Filters the component's directory title. 286 * 287 * @since 2.0.0 288 * 289 * @param string $value Title to use for the directory. 290 */ 291 $this->directory_title = apply_filters( 'bp_' . $this->id . '_directory_title', $r['directory_title'] ); 292 293 /** 294 * Filters the placeholder text for search inputs for component. 295 * 296 * @since 1.5.0 297 * 298 * @param string $value Name to use in search input placeholders. 299 */ 300 $this->search_string = apply_filters( 'bp_' . $this->id . '_search_string', $r['search_string'] ); 301 302 /** 303 * Filters the callable function that formats the component's notifications. 304 * 305 * @since 1.5.0 306 * 307 * @param string $value Function callback. 308 */ 309 $this->notification_callback = apply_filters( 'bp_' . $this->id . '_notification_callback', $r['notification_callback'] ); 310 311 // Set the global table names, if applicable. 312 if ( ! empty( $r['global_tables'] ) ) { 313 $this->register_global_tables( $r['global_tables'] ); 314 } 315 316 // Set the metadata table, if applicable. 317 if ( ! empty( $r['meta_tables'] ) ) { 318 $this->register_meta_tables( $r['meta_tables'] ); 249 /** Slugs ************************************************************ 250 */ 251 252 // For all Components except Core. 253 if ( 'core' !== $this->id ) { 254 /** 255 * If a WP directory page exists for the component, it should 256 * be the default value of 'root_slug'. 257 */ 258 if ( isset( buddypress()->pages->{$this->id}->slug ) ) { 259 $r['root_slug'] = buddypress()->pages->{$this->id}->slug; 260 } 261 262 /** 263 * Filters the slug to be used for the permalink URI chunk after root. 264 * 265 * @since 1.5.0 266 * 267 * @param string $value Slug to use in permalink URI chunk. 268 */ 269 $this->slug = apply_filters( 'bp_' . $this->id . '_slug', $r['slug'] ); 270 271 /** 272 * Filters the slug used for root directory. 273 * 274 * @since 1.5.0 275 * 276 * @param string $value Root directory slug. 277 */ 278 $this->root_slug = apply_filters( 'bp_' . $this->id . '_root_slug', $r['root_slug'] ); 279 280 /** 281 * Filters the component's top-level directory if available. 282 * 283 * @since 1.5.0 284 * 285 * @param bool $value Whether or not there is a top-level directory. 286 */ 287 $this->has_directory = apply_filters( 'bp_' . $this->id . '_has_directory', $r['has_directory'] ); 288 289 /** 290 * Filters the component's directory title. 291 * 292 * @since 2.0.0 293 * 294 * @param string $value Title to use for the directory. 295 */ 296 $this->directory_title = apply_filters( 'bp_' . $this->id . '_directory_title', $r['directory_title'] ); 297 298 /** 299 * Filters the placeholder text for search inputs for component. 300 * 301 * @since 1.5.0 302 * 303 * @param string $value Name to use in search input placeholders. 304 */ 305 $this->search_string = apply_filters( 'bp_' . $this->id . '_search_string', $r['search_string'] ); 306 307 /** 308 * Filters the callable function that formats the component's notifications. 309 * 310 * @since 1.5.0 311 * 312 * @param string $value Function callback. 313 */ 314 $this->notification_callback = apply_filters( 'bp_' . $this->id . '_notification_callback', $r['notification_callback'] ); 315 316 // Set the global table names, if applicable. 317 if ( ! empty( $r['global_tables'] ) ) { 318 $this->register_global_tables( $r['global_tables'] ); 319 } 320 321 // Set the metadata table, if applicable. 322 if ( ! empty( $r['meta_tables'] ) ) { 323 $this->register_meta_tables( $r['meta_tables'] ); 324 } 325 326 // Register this component in the loaded components array. 327 buddypress()->loaded_components[ $this->slug ] = $this->id; 319 328 } 320 329 … … 339 348 } 340 349 } 341 342 /** BuddyPress *******************************************************343 */344 345 // Register this component in the loaded components array.346 buddypress()->loaded_components[$this->slug] = $this->id;347 350 348 351 /** -
trunk/src/bp-core/classes/class-bp-core.php
r12994 r12999 290 290 291 291 // Is the logged in user is a mod for the current item? 292 bp_update_is_item_mod( false, 'core' ); 293 294 /** 295 * Fires at the end of the setup of bp-core globals setting. 296 * 297 * @since 1.1.0 298 */ 299 do_action( 'bp_core_setup_globals' ); 292 bp_update_is_item_mod( false, 'core' ); 293 294 parent::setup_globals( 295 array( 296 'block_globals' => array( 297 'bp/login-form' => array( 298 'widget_classnames' => array ( 'widget_bp_core_login_widget', 'buddypress' ), 299 ) 300 ) 301 ) 302 ); 300 303 } 301 304 … … 378 381 */ 379 382 public function blocks_init( $blocks = array() ) { 380 parent::blocks_init( array() ); 383 parent::blocks_init( 384 array( 385 'bp/login-form' => array( 386 'name' => 'bp/login-form', 387 'editor_script' => 'bp-login-form-block', 388 'editor_script_url' => plugins_url( 'js/blocks/login-form.js', dirname( __FILE__ ) ), 389 'editor_script_deps' => array( 390 'wp-blocks', 391 'wp-element', 392 'wp-components', 393 'wp-i18n', 394 'wp-block-editor', 395 'bp-block-components', 396 ), 397 'style' => 'bp-login-form-block', 398 'style_url' => plugins_url( 'css/blocks/login-form.css', dirname( __FILE__ ) ), 399 'attributes' => array( 400 'title' => array( 401 'type' => 'string', 402 'default' => '', 403 ), 404 ), 405 'render_callback' => 'bp_block_render_login_form_block', 406 ), 407 ) 408 ); 381 409 } 382 410 }
Note: See TracChangeset
for help on using the changeset viewer.