Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PLANET-4626 Update composer dev dependencies to match blocks-plugins, #1005

Merged
merged 1 commit into from
Feb 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,26 @@ Available tasks
* `gulp watch` 'watches for changes in js or sccs and runs the minification tasks'
* `gulp git_hooks` 'copies repo's git hooks to local git repo'

## Code standards
We follow the [WordPress Coding Standards](https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/)

We use a custom [php codesniffer](https://github.com/squizlabs/PHP_CodeSniffer) ruleset which adds some rules over WordPress-Core, WordPress-Docs and WordPress-Extra rulesets.

[WordPress Coding Standards Rulesets](https://github.com/WordPress/WordPress-Coding-Standards)

[WordPress Coding Standards Wiki](https://github.com/WordPress/WordPress-Coding-Standards/wiki)

To run the [php codesniffer](https://github.com/squizlabs/PHP_CodeSniffer)

`$ vendor/bin/phpcs`
or
`$ composer sniffs`

To run the [php code beautifier and fixer](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Fixing-Errors-Automatically)

`$ vendor/bin/phpcbf`
or
`$ composer fixes`

## Contribute

Expand Down
10 changes: 5 additions & 5 deletions author.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@

if ( get_query_var( 'page' ) ) {
$templates = [ 'tease-author.twig' ];
$page = get_query_var( 'page' );
$post_args['paged'] = $page;
$page_num = get_query_var( 'page' );
$post_args['paged'] = $page_num;

$posts = new PostQuery( $post_args, 'P4_Post' );
foreach ( $posts as $post ) {
$context['post'] = $post;
$author_posts = new PostQuery( $post_args, 'P4_Post' );
foreach ( $author_posts as $author_post ) {
$context['post'] = $author_post;
Timber::render( $templates, $context );
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion classes/class-p4-campaign-exporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function single_post_export_bulk_action() {
}

$validated_posts = array_filter(
$_REQUEST['post'],
$_REQUEST['post'], // phpcs:ignore
function ( $element ) {
return filter_var( $element, FILTER_VALIDATE_INT );
}
Expand Down
29 changes: 14 additions & 15 deletions classes/class-p4-campaigns.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,15 @@ public function add_taxonomy_form_fields( $wp_tag ) {
'selected' => $redirect_page,
'name' => 'redirect_page',
];
$redirect_edit = '<a href="post.php?post=' . $redirect_page . '&action=edit" target="_blank">Edit</a>';

?>

<tr class="form-field edit-wrap">
<th>
<label><?php echo __( 'Redirect Page', 'planet4-master-theme-backend' ); ?></label>
<label><?php esc_html_e( 'Redirect Page', 'planet4-master-theme-backend' ); ?></label>
</th>
<td>
<?php wp_dropdown_pages( $dropdown_args ); ?> <?php echo $redirect_edit; ?>
<p class="description"><?php echo __( 'Leave this empty if you want to use the automated Tag page. Otherwise pick a page to redirect this Tag to.', 'planet4-master-theme-backend' ); ?></p>
<?php wp_dropdown_pages( array_map( 'esc_attr', $dropdown_args ) ); ?> <a href="post.php?post=<?php echo esc_attr( $redirect_page ); ?>&action=edit" target="_blank"><?php esc_html_e( 'Edit', 'planet4-master-theme-backend' ); ?></a>
<p class="description"><?php esc_html_e( 'Leave this empty if you want to use the automated Tag page. Otherwise pick a page to redirect this Tag to.', 'planet4-master-theme-backend' ); ?></p>
</td>
</tr>
<tr>
Expand Down Expand Up @@ -158,11 +156,11 @@ public function add_taxonomy_form_fields( $wp_tag ) {
</tr>
<tr class="form-field edit-wrap term-happypoint-opacity-wrap">
<th>
<label><?php echo __( 'Happy Point Opacity', 'planet4-master-theme-backend' ); ?></label>
<label><?php esc_html_e( 'Happy Point Opacity', 'planet4-master-theme-backend' ); ?></label>
</th>
<td>
<input type="number" name="happypoint_bg_opacity" id="happypoint_bg_opacity" class="happypoint-opacity-id field-id" value="<?php echo esc_attr( $happypoint_bg_opacity ); ?>" min="1" max="100"/>
<p class="description"><?php echo __( 'We use an overlay to fade the image back. Use a number between 1 and 100, the higher the number, the more faded the image will look. If you leave this empty, the default of 30 will be used.', 'planet4-master-theme-backend' ); ?></p>
<p class="description"><?php esc_html_e( 'We use an overlay to fade the image back. Use a number between 1 and 100, the higher the number, the more faded the image will look. If you leave this empty, the default of 30 will be used.', 'planet4-master-theme-backend' ); ?></p>
</td>
</tr>
<?php
Expand All @@ -175,9 +173,9 @@ public function add_taxonomy_form_fields( $wp_tag ) {
];
?>
<div class="form-field add-wrap">
<label><?php echo __( 'Redirect Page', 'planet4-master-theme-backend' ); ?></label>
<?php wp_dropdown_pages( $dropdown_args ); ?>
<p class="description"><?php echo __( 'Leave this empty if you want to use the automated Tag page. Otherwise pick a page to redirect this Tag to.', 'planet4-master-theme-backend' ); ?></p>
<label><?php esc_html_e( 'Redirect Page', 'planet4-master-theme-backend' ); ?></label>
<?php wp_dropdown_pages( $dropdown_args ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<p class="description"><?php esc_html_e( 'Leave this empty if you want to use the automated Tag page. Otherwise pick a page to redirect this Tag to.', 'planet4-master-theme-backend' ); ?></p>
</div>
<div class="form-field add-wrap term-image-wrap">
<label><?php esc_html_e( 'Image', 'planet4-master-theme-backend' ); ?></label>
Expand All @@ -201,7 +199,8 @@ public function add_taxonomy_form_fields( $wp_tag ) {
*/
public function save_taxonomy_meta( $term_id ) {
// Save the selected page types for this campaign.
$selected_page_types = $_POST['p4_page_type'] ?? [];
$selected_page_types = $_POST['p4_page_type'] ?? []; // phpcs:ignore

if ( $this->validate_page_types( $selected_page_types ) ) {
update_term_meta( $term_id, 'selected_page_types', $selected_page_types );
}
Expand Down Expand Up @@ -267,7 +266,7 @@ public function save_taxonomy_meta( $term_id ) {
];

$covers_block2_attributes = [
'title' => __( 'Publications', 'planet4-blocks' ),
'title' => __( 'Publications', 'planet4-master-theme-backend' ),
'tags' => [ $term_id ],
'posts' => [],
'post_types' => [ 62 ],
Expand All @@ -289,12 +288,12 @@ public function save_taxonomy_meta( $term_id ) {

' . $this->make_gutenberg_comment( 'planet4-blocks/happypoint', $happypoint_block_attributes );

$my_post = array(
$my_post = [
'post_title' => '#' . $tag_data->name,
'post_content' => $post_content,
'post_status' => 'publish',
'post_type' => 'page',
);
];

// Insert the post into the database.
$tag_page_id = wp_insert_post( $my_post );
Expand Down Expand Up @@ -421,7 +420,7 @@ public function enqueue_admin_assets() {
if ( ! is_admin() || strpos( get_current_screen()->taxonomy, $this->taxonomy ) === false ) {
return;
}
wp_register_script( $this->taxonomy, get_template_directory_uri() . "/admin/js/$this->taxonomy.js", [ 'jquery' ], null, true );
wp_register_script( $this->taxonomy, get_template_directory_uri() . "/admin/js/$this->taxonomy.js", [ 'jquery' ], '0.1', true );
wp_localize_script( $this->taxonomy, 'localizations', $this->localizations );
wp_enqueue_script( $this->taxonomy );
wp_enqueue_media();
Expand Down
16 changes: 9 additions & 7 deletions classes/class-p4-custom-taxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,10 +378,12 @@ public function save_taxonomy_page_type( $post_id, $post ) {

// Allow p4-page-type to be set from edit post and quick edit pages.
// Make sure there's input.
// phpcs:disable WordPress.Security.NonceVerification.Missing
if ( isset( $_POST[ self::TAXONOMY ] ) && 'post' === $post->post_type &&
filter_var( $_POST[ self::TAXONOMY ], FILTER_VALIDATE_INT ) ) {
filter_var( wp_unslash( $_POST[ self::TAXONOMY ] ), FILTER_VALIDATE_INT ) ) {

$selected = get_term_by( 'id', intval( $_POST[ self::TAXONOMY ] ), self::TAXONOMY ); // Input var okay.
$selected = get_term_by( 'id', intval( $_POST[ self::TAXONOMY ] ), self::TAXONOMY );
// phpcs:enable
if ( false !== $selected && ! is_wp_error( $selected ) ) {
// Save post type.
wp_set_post_terms( $post_id, [ $selected->term_id ], self::TAXONOMY );
Expand Down Expand Up @@ -428,16 +430,16 @@ public function filter_posts_by_page_type( $post_type, $which ) {

// Display filter HTML.
?>
<select name="<?php echo self::TAXONOMY; ?>" id="<?php echo self::TAXONOMY; ?>" class="postform">
<option value=""><?php echo __( 'All Post Types', 'planet4-master-theme-backend' ); ?></option>
<select name="<?php echo esc_attr( self::TAXONOMY ); ?>" id="<?php echo esc_attr( self::TAXONOMY ); ?>" class="postform">
<option value=""><?php echo esc_html__( 'All Post Types', 'planet4-master-theme-backend' ); ?></option>

<?php
foreach ( $terms as $term ) {
printf(
'<option value="%1$s" %2$s>%3$s</option>',
$term->slug,
( ( isset( $_GET[ self::TAXONOMY ] ) && ( $_GET[ self::TAXONOMY ] == $term->slug ) ) ? ' selected="selected"' : '' ),
$term->name
esc_html( $term->slug ),
( ( isset( $_GET[ self::TAXONOMY ] ) && ( $_GET[ self::TAXONOMY ] === $term->slug ) ) ? ' selected="selected"' : '' ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended
esc_html( $term->name )
);
}
?>
Expand Down
10 changes: 5 additions & 5 deletions classes/class-p4-master-site.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public function login_redirect() {
}

if ( $_SERVER['HTTP_HOST'] !== $_SERVER['SERVER_NAME'] ) {
if ( wp_redirect( str_replace( $_SERVER['HTTP_HOST'], $_SERVER['SERVER_NAME'], get_admin_url() ) ) ) {
if ( wp_safe_redirect( str_replace( sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) ), sanitize_text_field( wp_unslash( $_SERVER['SERVER_NAME'] ) ), get_admin_url() ) ) ) {
exit;
}
}
Expand All @@ -212,7 +212,7 @@ public function add_login_logo_url_title() {
* Sets a custom stylesheet for the login page.
*/
public function add_login_stylesheet() {
wp_enqueue_style( 'custom-login', $this->theme_dir . '/style-login.css' );
wp_enqueue_style( 'custom-login', $this->theme_dir . '/style-login.css', [], '0.1' );
}

/**
Expand Down Expand Up @@ -279,7 +279,7 @@ public function allowedEditors() {
/**
* Load translations for master theme
*/
function p4_master_theme_setup() {
public function p4_master_theme_setup() {
$domains = [
'planet4-master-theme',
'planet4-master-theme-backend',
Expand Down Expand Up @@ -555,7 +555,7 @@ public function view_meta_box_search( $post ) {
$weight = get_post_meta( $post->ID, 'weight', true );
$options = get_option( 'planet4_options' );

echo '<label for="my_meta_box_text">' . esc_html__( 'Weight', 'planet4-master-theme-backend' ) . ' (1-' . P4_Search::DEFAULT_MAX_WEIGHT . ')</label>
echo '<label for="my_meta_box_text">' . esc_html__( 'Weight', 'planet4-master-theme-backend' ) . ' (1-' . esc_attr( P4_Search::DEFAULT_MAX_WEIGHT ) . ')</label>
<input id="weight" type="text" name="weight" value="' . esc_attr( $weight ) . '" />';
?><script>
$ = jQuery;
Expand Down Expand Up @@ -762,7 +762,7 @@ private function render_partial( $path, $args = [] ) {
if ( ! empty( $args ) ) {
extract( $args ); // phpcs:ignore
}
include( locate_template( $path . '.php' ) );
include locate_template( $path . '.php' );
}

/**
Expand Down
24 changes: 12 additions & 12 deletions classes/class-p4-post-campaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private function hooks() {
*/
public function register_campaigns_cpt() {

$labels = array(
$labels = [
'name' => _x( 'Campaigns', 'post type general name', 'planet4-master-theme-backend' ),
'singular_name' => _x( 'Campaign', 'post type singular name', 'planet4-master-theme-backend' ),
'menu_name' => _x( 'Campaigns', 'admin menu', 'planet4-master-theme-backend' ),
Expand All @@ -55,9 +55,9 @@ public function register_campaigns_cpt() {
'parent_item_colon' => __( 'Parent Campaigns:', 'planet4-master-theme-backend' ),
'not_found' => __( 'No campaigns found.', 'planet4-master-theme-backend' ),
'not_found_in_trash' => __( 'No campaigns found in Trash.', 'planet4-master-theme-backend' ),
);
];

$args = array(
$args = [
'labels' => $labels,
'description' => __( 'Campaigns', 'planet4-master-theme-backend' ),
'public' => true,
Expand All @@ -83,7 +83,7 @@ public function register_campaigns_cpt() {
// Required to expose meta fields in the REST API.
'custom-fields',
],
);
];

register_post_type( self::POST_TYPE, $args );

Expand Down Expand Up @@ -171,7 +171,7 @@ public function register_campaigns_metaboxes() {
* Load assets.
*/
public function enqueue_admin_assets() {
wp_register_style( 'cmb-style', get_template_directory_uri() . '/admin/css/campaign.css' );
wp_register_style( 'cmb-style', get_template_directory_uri() . '/admin/css/campaign.css', [], '0.1' );
wp_enqueue_style( 'cmb-style' );
}

Expand All @@ -196,7 +196,7 @@ public function cmb2_render_sidebar_link_field_callback(
href="#" onclick="openSidebar()"
id="new_sidebar_link">
<?php
echo __( 'Design settings moved to a new sidebar.', 'planet4-master-theme-backend' )
esc_html_e( 'Design settings moved to a new sidebar.', 'planet4-master-theme-backend' )
?>
</a>
<script>
Expand Down Expand Up @@ -232,14 +232,14 @@ public function cmb2_render_footer_icon_link_field_callback( $field, $value, $ob
<?php
echo wp_kses(
$field_type->input(
array(
[
'class' => 'cmb-type-text-medium',
'name' => esc_attr( $field_type->_name( '[url]' ) ),
'id' => esc_attr( $field_type->_id( '_url' ) ),
'type' => 'text',
'value' => esc_url( $value['url'] ),
'placeholder' => __( 'Footer item link', 'planet4-master-theme-backend' ),
)
]
),
[
'input' => [
Expand All @@ -259,14 +259,14 @@ public function cmb2_render_footer_icon_link_field_callback( $field, $value, $ob
<?php
echo wp_kses(
$field_type->input(
array(
[
'class' => 'cmb-type-text-medium',
'name' => esc_attr( $field_type->_name( '[icon]' ) ),
'id' => esc_attr( $field_type->_id( '_icon' ) ),
'type' => 'text',
'value' => $value['icon'],
'placeholder' => __( 'Footer icon name', 'planet4-master-theme-backend' ),
)
]
),
[
'input' => [
Expand Down Expand Up @@ -350,8 +350,8 @@ public static function css_vars( array $meta ): array {
$footer_theme = $meta['campaign_footer_theme'] ?? null;

if ( 'white' === $footer_theme ) {
$default_footer_links_color = $meta['campaign_nav_color'] ?: '#1A1A1A';
$footer_links_color = $meta['footer_links_color'] ?: $default_footer_links_color;
$default_footer_links_color = $meta['campaign_nav_color'] ? $meta['campaign_nav_color'] : '#1A1A1A';
Inwerpsel marked this conversation as resolved.
Show resolved Hide resolved
$footer_links_color = $meta['footer_links_color'] ? $meta['footer_links_color'] : $default_footer_links_color;
$footer_color = '#FFFFFF';
} else {
$footer_links_color = 'dark' === ( $meta['campaign_logo_color'] ?? null ) ? '#1A1A1A' : '#FFFFFF';
Expand Down
10 changes: 6 additions & 4 deletions classes/class-p4-post-report-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ private function hooks() {
*
* @return mixed
*/
function add_posts_param_to_endpoint( $args, $request ) {
public function add_posts_param_to_endpoint( $args, $request ) {
if ( ! isset( $request['before'] ) && ! isset( $request['after'] ) ) {
return $args;
}
Expand All @@ -61,7 +61,7 @@ function add_posts_param_to_endpoint( $args, $request ) {
/**
* Add post report submenu item.
*/
function add_posts_report_admin_menu_item() {
public function add_posts_report_admin_menu_item() {
add_posts_page(
__( 'Posts Report', 'planet4-master-theme-backend' ),
__( 'Posts Report', 'planet4-master-theme-backend' ),
Expand All @@ -78,7 +78,7 @@ function add_posts_report_admin_menu_item() {
*
* @return mixed
*/
function filter_post_params_endpoint( $query_params ) {
public function filter_post_params_endpoint( $query_params ) {
$query_params['date_query_column'] = [
'description' => __( 'The date query column.', 'planet4-master-theme-backend' ),
'type' => 'string',
Expand Down Expand Up @@ -116,7 +116,9 @@ public function render_posts_report_page() {
wp_enqueue_script( 'posts-report' );
wp_register_style(
'jquery-ui-datepicker',
'https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/themes/overcast/jquery-ui.min.css'
'https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/themes/overcast/jquery-ui.min.css',
[],
'0.1'
);
wp_enqueue_style( 'jquery-ui-datepicker' );
include dirname( __FILE__ ) . '/../posts-report.php';
Expand Down
4 changes: 2 additions & 2 deletions classes/class-p4-post.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,11 +363,11 @@ public function share_meta() {
}
}

$social_meta = array(
$social_meta = [
'title' => $og_title,
'description' => $og_description,
'link' => $link,
);
];

return $social_meta;
}
Expand Down
4 changes: 2 additions & 2 deletions classes/class-p4-search.php
Original file line number Diff line number Diff line change
Expand Up @@ -855,8 +855,8 @@ public function enqueue_public_assets() {
*/
private function prepare_keys_for_cache( $query_string, $group, $subgroup ) {
$cache_key_set = new stdClass();
$cache_key_set->key = urlencode( $query_string );
$cache_key_set->group = urlencode( $group ) . ':' . urlencode( $subgroup );
$cache_key_set->key = rawurlencode( $query_string );
$cache_key_set->group = rawurlencode( $group ) . ':' . rawurlencode( $subgroup );

return $cache_key_set;
}
Expand Down
Loading