Skip to content

Commit

Permalink
Merge pull request #20 from mototeam/sprint16
Browse files Browse the repository at this point in the history
= 1.6.1, Jul 1 2020 =
* Fixed an issue with Rank Math WordPress SEO plugin.
* Fixed an issue in Contact Form block.
* Fixed an issue with text in Video Popup block.
* Fixed an issue with pagination and offset options for all post-based blocks.
  • Loading branch information
mototeam authored Jul 1, 2020
2 parents 5d79c75 + 4cc827a commit 49decec
Show file tree
Hide file tree
Showing 29 changed files with 407 additions and 144 deletions.
2 changes: 1 addition & 1 deletion getwid.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Getwid
* Plugin URI: https://motopress.com/products/getwid/
* Description: Extra Gutenberg blocks for building seamless and aesthetic websites in the WordPress block editor.
* Version: 1.6.0
* Version: 1.6.1
* Author: MotoPress
* Author URI: https://motopress.com/
* License: GPLv2 or later
Expand Down
1 change: 1 addition & 0 deletions includes/blocks-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public function includeBlocks() {
'contact-form',
'mailchimp',
'content-timeline',
'table'
);

// load and register main blocks
Expand Down
3 changes: 2 additions & 1 deletion includes/blocks/contact-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public function render_captcha_block( $attributes ) {
'site_key' => $site_key
);

$result = '';
if ( $site_key ) {

wp_enqueue_script( 'recaptcha', 'https://www.google.com/recaptcha/api.js?render=explicit&hl=en' );
Expand Down Expand Up @@ -197,7 +198,7 @@ private function send_mail( $data ) {
$headers = array( 'Reply-To: ' . $name . ' <' . $email . '>' );
}

$response = getwid()->getMailer()->send( $to, $subject, $body, $headers );
$response = getwid()->mailer()->send( $to, $subject, $body, $headers );

if ( $response ) {
wp_send_json_success(
Expand Down
11 changes: 9 additions & 2 deletions includes/blocks/custom-post-type.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public function render_callback( $attributes, $content ) {

//Custom Post Type
$query_args = [];
getwid_build_custom_post_type_query( $query_args, $attributes );
getwid_build_custom_post_type_query( $query_args, $attributes );

$q = new \WP_Query( $query_args );
//Custom Post Type
Expand Down Expand Up @@ -226,9 +226,16 @@ public function render_callback( $attributes, $content ) {
<h2 class="screen-reader-text"><?php __('Posts navigation', 'getwid') ?></h2>
<div class="nav-links">
<?php
$total_pages = $q->max_num_pages;

if ($attributes['offset'] != 0){
$total_rows = max( 0, $q->found_posts - $attributes['offset'] );
$total_pages = ceil( $total_rows / $attributes['postsToShow'] );
}

$pagination_args = array(
'base' => str_replace( 999999999, '%#%', esc_url( get_pagenum_link( 999999999 ) ) ),
'total' => $q->max_num_pages,
'total' => $total_pages,
'current' => max( 1, get_query_var( 'paged' ) ),
'format' => '?paged=%#%',
'show_all' => false,
Expand Down
8 changes: 8 additions & 0 deletions includes/blocks/table-of-contents.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ public function __construct() {
'getwid/table-of-contents'
);

/**
* Rank Math ToC Plugins List.
*/
add_filter( 'rank_math/researches/toc_plugins', function( $toc_plugins ) {
$toc_plugins['getwid/getwid.php'] = 'Getwid';
return $toc_plugins;
});

}

public function getLabel() {
Expand Down
25 changes: 25 additions & 0 deletions includes/blocks/table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Getwid\Blocks;

class Table extends \Getwid\Blocks\AbstractBlock {

protected static $blockName = 'getwid/table';

public function __construct() {

parent::__construct( self::$blockName );

register_block_type(
'getwid/table'
);
}

public function getLabel() {
return __( 'Table', 'getwid' );
}
}

getwid()->blocksManager()->addBlock(
new \Getwid\Blocks\Table()
);
10 changes: 7 additions & 3 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,10 @@ function getwid_build_custom_post_type_query(&$query_args = [], $attributes, $op

$query_args = array(
'posts_per_page' => $attributes['postsToShow'],
'offset' => $attributes['offset'],
'ignore_sticky_posts' => 1,
'post_status' => 'publish',
'order' => $attributes['order'],
'orderby' => $attributes['orderBy'],
'orderby' => $attributes['orderBy'],
);

if ( isset($attributes['ignoreSticky']) ){
Expand All @@ -244,7 +243,12 @@ function getwid_build_custom_post_type_query(&$query_args = [], $attributes, $op
$paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;
if ( isset($attributes['pagination']) && $attributes['pagination'] ){
$query_args['paged'] = $paged;
}
}

if ($attributes['offset'] != 0){
$offset = ( $paged - 1 ) * $attributes['postsToShow'] + $attributes['offset'];
$query_args['offset'] = $offset;
}

}

Expand Down
Loading

0 comments on commit 49decec

Please sign in to comment.