Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/02/2024 01:16:13 AM (2 years ago)
Author:
espellcaste
Message:

WPCS: Part VI: miscellaneous fixes for some of the files of the core component.

Follow-up to [13883], [13886], [13887], [13888], and [13891]

See #9164 and #7228

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-customizer-email.php

    r13878 r13892  
    2323        }
    2424
    25         $wp_customize->add_panel( 'bp_mailtpl', array(
    26                 'description' => __( 'Customize the appearance of emails sent by BuddyPress.', 'buddypress' ),
    27                 'title'       => _x( 'BuddyPress Emails', 'screen heading', 'buddypress' ),
    28         ) );
     25        $wp_customize->add_panel(
     26                'bp_mailtpl',
     27                array(
     28                        'description' => __( 'Customize the appearance of emails sent by BuddyPress.', 'buddypress' ),
     29                        'title'       => _x( 'BuddyPress Emails', 'screen heading', 'buddypress' ),
     30                )
     31        );
    2932
    3033        $sections = bp_email_get_customizer_sections();
     
    126129         * @param array $sections Email Customizer sections to add.
    127130         */
    128         return apply_filters( 'bp_email_get_customizer_sections', array(
    129                 'section_bp_mailtpl_header' => array(
    130                         'capability' => 'bp_moderate',
    131                         'panel'      => 'bp_mailtpl',
    132                         'title'      => _x( 'Header', 'email', 'buddypress' ),
    133                 ),
    134                 'section_bp_mailtpl_body' => array(
    135                         'capability' => 'bp_moderate',
    136                         'panel'      => 'bp_mailtpl',
    137                         'title'      => _x( 'Body', 'email', 'buddypress' ),
    138                 ),
    139                 'section_bp_mailtpl_footer' => array(
    140                         'capability' => 'bp_moderate',
    141                         'panel'      => 'bp_mailtpl',
    142                         'title'      => _x( 'Footer', 'email', 'buddypress' ),
    143                 ),
    144         ) );
     131        return apply_filters(
     132                'bp_email_get_customizer_sections',
     133                array(
     134                        'section_bp_mailtpl_header' => array(
     135                                'capability' => 'bp_moderate',
     136                                'panel'      => 'bp_mailtpl',
     137                                'title'      => _x( 'Header', 'email', 'buddypress' ),
     138                        ),
     139                        'section_bp_mailtpl_body'   => array(
     140                                'capability' => 'bp_moderate',
     141                                'panel'      => 'bp_mailtpl',
     142                                'title'      => _x( 'Body', 'email', 'buddypress' ),
     143                        ),
     144                        'section_bp_mailtpl_footer' => array(
     145                                'capability' => 'bp_moderate',
     146                                'panel'      => 'bp_mailtpl',
     147                                'title'      => _x( 'Footer', 'email', 'buddypress' ),
     148                        ),
     149                )
     150        );
    145151}
    146152
     
    162168         * @param array $settings Email Customizer settings to add.
    163169         */
    164         return apply_filters( 'bp_email_get_customizer_settings', array(
    165                 'bp_email_options[email_bg]' => array(
    166                         'capability'        => 'bp_moderate',
    167                         'default'           => $defaults['email_bg'],
    168                         'sanitize_callback' => 'sanitize_hex_color',
    169                         'transport'         => 'postMessage',
    170                         'type'              => 'option',
    171                 ),
    172                 'bp_email_options[header_bg]' => array(
    173                         'capability'        => 'bp_moderate',
    174                         'default'           => $defaults['header_bg'],
    175                         'sanitize_callback' => 'sanitize_hex_color',
    176                         'transport'         => 'postMessage',
    177                         'type'              => 'option',
    178                 ),
    179                 'bp_email_options[header_text_size]' => array(
    180                         'capability'        => 'bp_moderate',
    181                         'default'           => $defaults['header_text_size'],
    182                         'sanitize_callback' => 'absint',
    183                         'transport'         => 'postMessage',
    184                         'type'              => 'option',
    185                 ),
    186                 'bp_email_options[header_text_color]' => array(
    187                         'capability'        => 'bp_moderate',
    188                         'default'           => $defaults['header_text_color'],
    189                         'sanitize_callback' => 'sanitize_hex_color',
    190                         'transport'         => 'postMessage',
    191                         'type'              => 'option',
    192                 ),
    193                 'bp_email_options[highlight_color]' => array(
    194                         'capability'        => 'bp_moderate',
    195                         'default'           => $defaults['highlight_color'],
    196                         'sanitize_callback' => 'sanitize_hex_color',
    197                         'transport'         => 'postMessage',
    198                         'type'              => 'option',
    199                 ),
    200                 'bp_email_options[body_bg]' => array(
    201                         'capability'        => 'bp_moderate',
    202                         'default'           => $defaults['body_bg'],
    203                         'sanitize_callback' => 'sanitize_hex_color',
    204                         'transport'         => 'postMessage',
    205                         'type'              => 'option',
    206                 ),
    207                 'bp_email_options[body_text_size]' => array(
    208                         'capability'        => 'bp_moderate',
    209                         'default'           => $defaults['body_text_size'],
    210                         'sanitize_callback' => 'absint',
    211                         'transport'         => 'postMessage',
    212                         'type'              => 'option',
    213                 ),
    214                 'bp_email_options[body_text_color]' => array(
    215                         'capability'        => 'bp_moderate',
    216                         'default'           => $defaults['body_text_color'],
    217                         'sanitize_callback' => 'sanitize_hex_color',
    218                         'transport'         => 'postMessage',
    219                         'type'              => 'option',
    220                 ),
    221                 'bp_email_options[footer_text]' => array(
    222                         'capability'        => 'bp_moderate',
    223                         'default'           => $defaults['footer_text'],
    224                         'sanitize_callback' => 'wp_filter_post_kses',
    225                         'transport'         => 'postMessage',
    226                         'type'              => 'option',
    227                 ),
    228                 'bp_email_options[footer_bg]' => array(
    229                         'capability'        => 'bp_moderate',
    230                         'default'           => $defaults['footer_bg'],
    231                         'sanitize_callback' => 'sanitize_hex_color',
    232                         'transport'         => 'postMessage',
    233                         'type'              => 'option',
    234                 ),
    235                 'bp_email_options[footer_text_size]' => array(
    236                         'capability'        => 'bp_moderate',
    237                         'default'           => $defaults['footer_text_size'],
    238                         'sanitize_callback' => 'absint',
    239                         'transport'         => 'postMessage',
    240                         'type'              => 'option',
    241                 ),
    242                 'bp_email_options[footer_text_color]' => array(
    243                         'capability'        => 'bp_moderate',
    244                         'default'           => $defaults['footer_text_color'],
    245                         'sanitize_callback' => 'sanitize_hex_color',
    246                         'transport'         => 'postMessage',
    247                         'type'              => 'option',
    248                 ),
    249         ) );
     170        return apply_filters(
     171                'bp_email_get_customizer_settings',
     172                array(
     173                        'bp_email_options[email_bg]'          => array(
     174                                'capability'        => 'bp_moderate',
     175                                'default'           => $defaults['email_bg'],
     176                                'sanitize_callback' => 'sanitize_hex_color',
     177                                'transport'         => 'postMessage',
     178                                'type'              => 'option',
     179                        ),
     180                        'bp_email_options[header_bg]'         => array(
     181                                'capability'        => 'bp_moderate',
     182                                'default'           => $defaults['header_bg'],
     183                                'sanitize_callback' => 'sanitize_hex_color',
     184                                'transport'         => 'postMessage',
     185                                'type'              => 'option',
     186                        ),
     187                        'bp_email_options[header_text_size]'  => array(
     188                                'capability'        => 'bp_moderate',
     189                                'default'           => $defaults['header_text_size'],
     190                                'sanitize_callback' => 'absint',
     191                                'transport'         => 'postMessage',
     192                                'type'              => 'option',
     193                        ),
     194                        'bp_email_options[header_text_color]' => array(
     195                                'capability'        => 'bp_moderate',
     196                                'default'           => $defaults['header_text_color'],
     197                                'sanitize_callback' => 'sanitize_hex_color',
     198                                'transport'         => 'postMessage',
     199                                'type'              => 'option',
     200                        ),
     201                        'bp_email_options[highlight_color]'   => array(
     202                                'capability'        => 'bp_moderate',
     203                                'default'           => $defaults['highlight_color'],
     204                                'sanitize_callback' => 'sanitize_hex_color',
     205                                'transport'         => 'postMessage',
     206                                'type'              => 'option',
     207                        ),
     208                        'bp_email_options[body_bg]'           => array(
     209                                'capability'        => 'bp_moderate',
     210                                'default'           => $defaults['body_bg'],
     211                                'sanitize_callback' => 'sanitize_hex_color',
     212                                'transport'         => 'postMessage',
     213                                'type'              => 'option',
     214                        ),
     215                        'bp_email_options[body_text_size]'    => array(
     216                                'capability'        => 'bp_moderate',
     217                                'default'           => $defaults['body_text_size'],
     218                                'sanitize_callback' => 'absint',
     219                                'transport'         => 'postMessage',
     220                                'type'              => 'option',
     221                        ),
     222                        'bp_email_options[body_text_color]'   => array(
     223                                'capability'        => 'bp_moderate',
     224                                'default'           => $defaults['body_text_color'],
     225                                'sanitize_callback' => 'sanitize_hex_color',
     226                                'transport'         => 'postMessage',
     227                                'type'              => 'option',
     228                        ),
     229                        'bp_email_options[footer_text]'       => array(
     230                                'capability'        => 'bp_moderate',
     231                                'default'           => $defaults['footer_text'],
     232                                'sanitize_callback' => 'wp_filter_post_kses',
     233                                'transport'         => 'postMessage',
     234                                'type'              => 'option',
     235                        ),
     236                        'bp_email_options[footer_bg]'         => array(
     237                                'capability'        => 'bp_moderate',
     238                                'default'           => $defaults['footer_bg'],
     239                                'sanitize_callback' => 'sanitize_hex_color',
     240                                'transport'         => 'postMessage',
     241                                'type'              => 'option',
     242                        ),
     243                        'bp_email_options[footer_text_size]'  => array(
     244                                'capability'        => 'bp_moderate',
     245                                'default'           => $defaults['footer_text_size'],
     246                                'sanitize_callback' => 'absint',
     247                                'transport'         => 'postMessage',
     248                                'type'              => 'option',
     249                        ),
     250                        'bp_email_options[footer_text_color]' => array(
     251                                'capability'        => 'bp_moderate',
     252                                'default'           => $defaults['footer_text_color'],
     253                                'sanitize_callback' => 'sanitize_hex_color',
     254                                'transport'         => 'postMessage',
     255                                'type'              => 'option',
     256                        ),
     257                )
     258        );
    250259}
    251260
     
    266275         * @param array $controls Email Customizer controls to add.
    267276         */
    268         return apply_filters( 'bp_email_get_customizer_controls', array(
    269                 'bp_mailtpl_email_bg' => array(
    270                         'class'    => 'WP_Customize_Color_Control',
    271                         'label'    => __( 'Email background color', 'buddypress' ),
    272                         'section'  => 'section_bp_mailtpl_header',
    273                         'settings' => 'bp_email_options[email_bg]',
    274                 ),
    275 
    276                 'bp_mailtpl_header_bg' => array(
    277                         'class'    => 'WP_Customize_Color_Control',
    278                         'label'    => __( 'Header background color', 'buddypress' ),
    279                         'section'  => 'section_bp_mailtpl_header',
    280                         'settings' => 'bp_email_options[header_bg]',
    281                 ),
    282 
    283                 'bp_mailtpl_highlight_color' => array(
    284                         'class'       => 'WP_Customize_Color_Control',
    285                         'description' => __( 'Applied to links and other decorative areas.', 'buddypress' ),
    286                         'label'       => __( 'Highlight color', 'buddypress' ),
    287                         'section'     => 'section_bp_mailtpl_header',
    288                         'settings'    => 'bp_email_options[highlight_color]',
    289                 ),
    290 
    291                 'bp_mailtpl_header_text_color' => array(
    292                         'class'    => 'WP_Customize_Color_Control',
    293                         'label'    => __( 'Text color', 'buddypress' ),
    294                         'section'  => 'section_bp_mailtpl_header',
    295                         'settings' => 'bp_email_options[header_text_color]',
    296                 ),
    297 
    298                 'bp_mailtpl_header_text_size' => array(
    299                         'class'    => 'BP_Customizer_Control_Range',
    300                         'label'    => __( 'Text size', 'buddypress' ),
    301                         'section'  => 'section_bp_mailtpl_header',
    302                         'settings' => 'bp_email_options[header_text_size]',
    303 
    304                         'input_attrs' => array(
    305                                 'max'  => 100,
    306                                 'min'  => 1,
    307                                 'step' => 1,
    308                         ),
    309                 ),
    310 
    311 
    312                 'bp_mailtpl_body_bg' => array(
    313                         'class'    => 'WP_Customize_Color_Control',
    314                         'label'    => __( 'Background color', 'buddypress' ),
    315                         'section'  => 'section_bp_mailtpl_body',
    316                         'settings' => 'bp_email_options[body_bg]',
    317                 ),
    318 
    319 
    320                 'bp_mailtpl_body_text_color' => array(
    321                         'class'    => 'WP_Customize_Color_Control',
    322                         'label'    => __( 'Text color', 'buddypress' ),
    323                         'section'  => 'section_bp_mailtpl_body',
    324                         'settings' => 'bp_email_options[body_text_color]',
    325                 ),
    326 
    327                 'bp_mailtpl_body_text_size' => array(
    328                         'class'    => 'BP_Customizer_Control_Range',
    329                         'label'    => __( 'Text size', 'buddypress' ),
    330                         'section'  => 'section_bp_mailtpl_body',
    331                         'settings' => 'bp_email_options[body_text_size]',
    332 
    333                         'input_attrs' => array(
    334                                 'max'  => 24,
    335                                 'min'  => 8,
    336                                 'step' => 1,
    337                         ),
    338                 ),
    339 
    340 
    341                 'bp_mailtpl_footer_text' => array(
    342                         'class'       => 'WP_Customize_Control',
    343                         'description' => __('Change the email footer here', 'buddypress' ),
    344                         'label'       => __( 'Footer text', 'buddypress' ),
    345                         'section'     => 'section_bp_mailtpl_footer',
    346                         'settings'    => 'bp_email_options[footer_text]',
    347                         'type'        => 'textarea',
    348                 ),
    349 
    350                 'bp_mailtpl_footer_bg' => array(
    351                         'class'    => 'WP_Customize_Color_Control',
    352                         'label'    => __( 'Background color', 'buddypress' ),
    353                         'section'  => 'section_bp_mailtpl_footer',
    354                         'settings' => 'bp_email_options[footer_bg]',
    355                 ),
    356 
    357                 'bp_mailtpl_footer_text_color' => array(
    358                         'class'    => 'WP_Customize_Color_Control',
    359                         'label'    => __( 'Text color', 'buddypress' ),
    360                         'section'  => 'section_bp_mailtpl_footer',
    361                         'settings' => 'bp_email_options[footer_text_color]',
    362                 ),
    363 
    364                 'bp_mailtpl_footer_text_size' => array(
    365                         'class'    => 'BP_Customizer_Control_Range',
    366                         'label'    => __( 'Text size', 'buddypress' ),
    367                         'section'  => 'section_bp_mailtpl_footer',
    368                         'settings' => 'bp_email_options[footer_text_size]',
    369 
    370                         'input_attrs' => array(
    371                                 'max'  => 24,
    372                                 'min'  => 8,
    373                                 'step' => 1,
    374                         ),
    375                 ),
    376         ) );
     277        return apply_filters(
     278                'bp_email_get_customizer_controls',
     279                array(
     280                        'bp_mailtpl_email_bg'          => array(
     281                                'class'    => 'WP_Customize_Color_Control',
     282                                'label'    => __( 'Email background color', 'buddypress' ),
     283                                'section'  => 'section_bp_mailtpl_header',
     284                                'settings' => 'bp_email_options[email_bg]',
     285                        ),
     286
     287                        'bp_mailtpl_header_bg'         => array(
     288                                'class'    => 'WP_Customize_Color_Control',
     289                                'label'    => __( 'Header background color', 'buddypress' ),
     290                                'section'  => 'section_bp_mailtpl_header',
     291                                'settings' => 'bp_email_options[header_bg]',
     292                        ),
     293
     294                        'bp_mailtpl_highlight_color'   => array(
     295                                'class'       => 'WP_Customize_Color_Control',
     296                                'description' => __( 'Applied to links and other decorative areas.', 'buddypress' ),
     297                                'label'       => __( 'Highlight color', 'buddypress' ),
     298                                'section'     => 'section_bp_mailtpl_header',
     299                                'settings'    => 'bp_email_options[highlight_color]',
     300                        ),
     301
     302                        'bp_mailtpl_header_text_color' => array(
     303                                'class'    => 'WP_Customize_Color_Control',
     304                                'label'    => __( 'Text color', 'buddypress' ),
     305                                'section'  => 'section_bp_mailtpl_header',
     306                                'settings' => 'bp_email_options[header_text_color]',
     307                        ),
     308
     309                        'bp_mailtpl_header_text_size'  => array(
     310                                'class'       => 'BP_Customizer_Control_Range',
     311                                'label'       => __( 'Text size', 'buddypress' ),
     312                                'section'     => 'section_bp_mailtpl_header',
     313                                'settings'    => 'bp_email_options[header_text_size]',
     314
     315                                'input_attrs' => array(
     316                                        'max'  => 100,
     317                                        'min'  => 1,
     318                                        'step' => 1,
     319                                ),
     320                        ),
     321
     322                        'bp_mailtpl_body_bg'           => array(
     323                                'class'    => 'WP_Customize_Color_Control',
     324                                'label'    => __( 'Background color', 'buddypress' ),
     325                                'section'  => 'section_bp_mailtpl_body',
     326                                'settings' => 'bp_email_options[body_bg]',
     327                        ),
     328
     329                        'bp_mailtpl_body_text_color'  => array(
     330                                'class'    => 'WP_Customize_Color_Control',
     331                                'label'    => __( 'Text color', 'buddypress' ),
     332                                'section'  => 'section_bp_mailtpl_body',
     333                                'settings' => 'bp_email_options[body_text_color]',
     334                        ),
     335
     336                        'bp_mailtpl_body_text_size'    => array(
     337                                'class'       => 'BP_Customizer_Control_Range',
     338                                'label'       => __( 'Text size', 'buddypress' ),
     339                                'section'     => 'section_bp_mailtpl_body',
     340                                'settings'    => 'bp_email_options[body_text_size]',
     341
     342                                'input_attrs' => array(
     343                                        'max'  => 24,
     344                                        'min'  => 8,
     345                                        'step' => 1,
     346                                ),
     347                        ),
     348
     349                        'bp_mailtpl_footer_text'       => array(
     350                                'class'       => 'WP_Customize_Control',
     351                                'description' => __( 'Change the email footer here', 'buddypress' ),
     352                                'label'       => __( 'Footer text', 'buddypress' ),
     353                                'section'     => 'section_bp_mailtpl_footer',
     354                                'settings'    => 'bp_email_options[footer_text]',
     355                                'type'        => 'textarea',
     356                        ),
     357
     358                        'bp_mailtpl_footer_bg'         => array(
     359                                'class'    => 'WP_Customize_Color_Control',
     360                                'label'    => __( 'Background color', 'buddypress' ),
     361                                'section'  => 'section_bp_mailtpl_footer',
     362                                'settings' => 'bp_email_options[footer_bg]',
     363                        ),
     364
     365                        'bp_mailtpl_footer_text_color' => array(
     366                                'class'    => 'WP_Customize_Color_Control',
     367                                'label'    => __( 'Text color', 'buddypress' ),
     368                                'section'  => 'section_bp_mailtpl_footer',
     369                                'settings' => 'bp_email_options[footer_text_color]',
     370                        ),
     371
     372                        'bp_mailtpl_footer_text_size'  => array(
     373                                'class'       => 'BP_Customizer_Control_Range',
     374                                'label'       => __( 'Text size', 'buddypress' ),
     375                                'section'     => 'section_bp_mailtpl_footer',
     376                                'settings'    => 'bp_email_options[footer_text_size]',
     377
     378                                'input_attrs' => array(
     379                                        'max'  => 24,
     380                                        'min'  => 8,
     381                                        'step' => 1,
     382                                ),
     383                        ),
     384                )
     385        );
    377386}
    378387
     
    391400        }
    392401
    393         $email = get_posts( array(
    394                 'fields'           => 'ids',
    395                 'orderby'          => 'rand',
    396                 'post_status'      => 'publish',
    397                 'post_type'        => bp_get_email_post_type(),
    398                 'posts_per_page'   => 1,
    399                 'suppress_filters' => false,
    400         ) );
     402        $email = get_posts(
     403                array(
     404                        'fields'           => 'ids',
     405                        'orderby'          => 'rand',
     406                        'post_status'      => 'publish',
     407                        'post_type'        => bp_get_email_post_type(),
     408                        'posts_per_page'   => 1,
     409                        'suppress_filters' => false,
     410                )
     411        );
    401412
    402413        $preview_url = admin_url();
Note: See TracChangeset for help on using the changeset viewer.