Skip to content

Commit

Permalink
Add new blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
polevaultweb committed Dec 29, 2022
1 parent ab123d2 commit d7765a2
Show file tree
Hide file tree
Showing 17 changed files with 335 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/index.js.map

Large diffs are not rendered by default.

45 changes: 45 additions & 0 deletions includes/classes/Blocks/LikeButton.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
/**
* Helper methods for the Like Button block.
*
* @package wpum-blocks
* @copyright Copyright (c) 2022, WP User Manager
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 0.1.0
*/

namespace WPUserManagerBlocks\Blocks;

// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;

/**
* Helper methods that handle registration and output of the password recovery block.
*/
class LikeButton extends AbstractBlock {

protected $name = 'like-button';
protected $shortcode_function = 'wpum_like_button';

protected function get_labels() {
return [
'title' => esc_html__( 'Like Button', 'wp-user-manager' ),
'description' => esc_html__( 'WP User Manager likes button.', 'wp-user-manager' ),
'keywords' => [
esc_html__( 'like', 'wp-user-manager' ),
esc_html__( 'vote', 'wp-user-manager' ),
],
'panel_settings' => esc_html__( 'Settings', 'wp-user-manager' ),
];
}

/**
* Retrieve the list of attributes.
*
* @return array
*/
protected function get_attributes() {
return [];
}

}
44 changes: 44 additions & 0 deletions includes/classes/Blocks/PrivateContent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* Helper methods for the Social Login Buttons block.
*
* @package wpum-blocks
* @copyright Copyright (c) 2022, WP User Manager
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 0.1.0
*/

namespace WPUserManagerBlocks\Blocks;

// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;

/**
* Helper methods that handle registration and output of the password recovery block.
*/
class PrivateContent extends AbstractBlock {

protected $name = 'private-content';
protected $shortcode_function = 'wpumpr_private_content';

protected function get_labels() {
return [
'title' => esc_html__( 'Private Content', 'wp-user-manager' ),
'description' => esc_html__( 'WP User Manager private user content.', 'wp-user-manager' ),
'keywords' => [
esc_html__( 'private content', 'wp-user-manager' ),
],
'panel_settings' => esc_html__( 'Settings', 'wp-user-manager' ),
];
}

/**
* Retrieve the list of attributes.
*
* @return array
*/
protected function get_attributes() {
return [];
}

}
47 changes: 47 additions & 0 deletions includes/classes/Blocks/SocialLoginButtons.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
/**
* Helper methods for the Social Login Buttons block.
*
* @package wpum-blocks
* @copyright Copyright (c) 2022, WP User Manager
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 0.1.0
*/

namespace WPUserManagerBlocks\Blocks;

// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;

/**
* Helper methods that handle registration and output of the password recovery block.
*/
class SocialLoginButtons extends AbstractBlock {

protected $name = 'social-login-buttons';
protected $shortcode_function = 'wpumsl_display_social_login_buttons';

protected function get_labels() {
return [
'title' => esc_html__( 'Social Login Buttons', 'wp-user-manager' ),
'description' => esc_html__( 'WP User Manager social login buttons.', 'wp-user-manager' ),
'keywords' => [
esc_html__( 'social login', 'wp-user-manager' ),
esc_html__( 'twitter', 'wp-user-manager' ),
esc_html__( 'facebook', 'wp-user-manager' ),
esc_html__( 'google', 'wp-user-manager' ),
],
'panel_settings' => esc_html__( 'Settings', 'wp-user-manager' ),
];
}

/**
* Retrieve the list of attributes.
*
* @return array
*/
protected function get_attributes() {
return [];
}

}
16 changes: 16 additions & 0 deletions includes/classes/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@

namespace WPUserManagerBlocks;

use ACP\Search\Helper\Sql\Comparison\Like;
use WPUserManagerBlocks\Blocks\AccountPage;
use WPUserManagerBlocks\Blocks\LikeButton;
use WPUserManagerBlocks\Blocks\LoginForm;
use WPUserManagerBlocks\Blocks\LoginLink;
use WPUserManagerBlocks\Blocks\LogoutLink;
use WPUserManagerBlocks\Blocks\PasswordRecoveryForm;
use WPUserManagerBlocks\Blocks\PrivateContent;
use WPUserManagerBlocks\Blocks\ProfileCard;
use WPUserManagerBlocks\Blocks\ProfilePage;
use WPUserManagerBlocks\Blocks\RecentlyRegisteredUsers;
use WPUserManagerBlocks\Blocks\RegistrationForm;
use WPUserManagerBlocks\Blocks\SocialLoginButtons;
use WPUserManagerBlocks\Blocks\UserDirectory;
use WPUserManagerBlocks\Blocks\GroupDirectory;
use WPUserManagerBlocks\Blocks\PostForm;
Expand Down Expand Up @@ -61,6 +65,18 @@ public function register() {
if ( class_exists( 'WPUM_Frontend_Posting' ) ) {
( new PostForm() )->register();
}

if ( class_exists( 'WPUM_Likes' ) ) {
( new LikeButton() )->register();
}

if ( class_exists( 'WPUM_Social_Login' ) ) {
( new SocialLoginButtons() )->register();
}

if ( class_exists( 'WPUM_Private_Content' ) ) {
( new PrivateContent() )->register();
}
}

/**
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
"homepage": "https://wpusermanager.com",
"author": "https://wpusermanager.com",
"description": "WP User Manager component that registers custom blocks.",
"license": "GPLv2+",
"license": "GPL-2.0-or-later",
"repository": {
"type": "git",
"url": "https://github.com/WPUserManager/wpum-blocks/"
},
"scripts": {
"build": "wp-scripts build",
"check-engines": "wp-scripts check-engines",
Expand Down
16 changes: 16 additions & 0 deletions src/blocks/block-like-button/edit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const { __ } = wp.i18n;
const { serverSideRender } = wp;

const el = wp.element.createElement;

let blockName = "like-button";

// Build the editor settings.
export default function(props) {
return [
el(serverSideRender, {
block: "wpum/" + blockName,
attributes: props.attributes
})
];
}
14 changes: 14 additions & 0 deletions src/blocks/block-like-button/icon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* WordPress dependencies
*/

const { Path, SVG } = wp.components;

export default (
<svg xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 512 512">
<g id="like-button" fill="#1361FF" fill-rule="nonzero">
<path d="M313.4 32.9c26 5.2 42.9 30.5 37.7 56.5l-2.3 11.4c-5.3 26.7-15.1 52.1-28.8 75.2H464c26.5 0 48 21.5 48 48c0 25.3-19.5 46-44.3 47.9c7.7 8.5 12.3 19.8 12.3 32.1c0 23.4-16.8 42.9-38.9 47.1c4.4 7.2 6.9 15.8 6.9 24.9c0 21.3-13.9 39.4-33.1 45.6c.7 3.3 1.1 6.8 1.1 10.4c0 26.5-21.5 48-48 48H294.5c-19 0-37.5-5.6-53.3-16.1l-38.5-25.7C176 420.4 160 390.4 160 358.3V320 272 247.1c0-29.2 13.3-56.7 36-75l7.4-5.9c26.5-21.2 44.6-51 51.2-84.2l2.3-11.4c5.2-26 30.5-42.9 56.5-37.7zM32 192H96c17.7 0 32 14.3 32 32V448c0 17.7-14.3 32-32 32H32c-17.7 0-32-14.3-32-32V224c0-17.7 14.3-32 32-32z"/>
</g>
</svg>
);
28 changes: 28 additions & 0 deletions src/blocks/block-like-button/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Listings query block.
*/

const { __ } = wp.i18n;
const { registerBlockType } = wp.blocks;

// Import block editor settings
import EditBlock from './edit';
import icon from "./icon";

let blockName = 'like-button';

// Register the block.
registerBlockType( 'wpum/' + blockName, {
title: wpum_blocks.blocks[blockName].labels.title,
description: wpum_blocks.blocks[blockName].labels.description,
icon,
category: 'wpum',
keywords: wpum_blocks.blocks[blockName].labels.keywords,
attributes: wpum_blocks.blocks[blockName].attributes,

edit: EditBlock,

save() {
return null;
}
});
16 changes: 16 additions & 0 deletions src/blocks/block-private-content/edit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const { __ } = wp.i18n;
const { serverSideRender } = wp;

const el = wp.element.createElement;

let blockName = "private-content";

// Build the editor settings.
export default function(props) {
return [
el(serverSideRender, {
block: "wpum/" + blockName,
attributes: props.attributes
})
];
}
14 changes: 14 additions & 0 deletions src/blocks/block-private-content/icon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* WordPress dependencies
*/

const { Path, SVG } = wp.components;

export default (
<svg xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 512 512">
<g id="private-content" fill="#1361FF" fill-rule="nonzero">
<path d="M256 0c4.6 0 9.2 1 13.4 2.9L457.7 82.8c22 9.3 38.4 31 38.3 57.2c-.5 99.2-41.3 280.7-213.7 363.2c-16.7 8-36.1 8-52.8 0C57.3 420.7 16.5 239.2 16 140c-.1-26.2 16.3-47.9 38.3-57.2L242.7 2.9C246.8 1 251.4 0 256 0z"/>
</g>
</svg>
);
28 changes: 28 additions & 0 deletions src/blocks/block-private-content/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Listings query block.
*/

const { __ } = wp.i18n;
const { registerBlockType } = wp.blocks;

// Import block editor settings
import EditBlock from './edit';
import icon from "./icon";

let blockName = 'private-content';

// Register the block.
registerBlockType( 'wpum/' + blockName, {
title: wpum_blocks.blocks[blockName].labels.title,
description: wpum_blocks.blocks[blockName].labels.description,
icon,
category: 'wpum',
keywords: wpum_blocks.blocks[blockName].labels.keywords,
attributes: wpum_blocks.blocks[blockName].attributes,

edit: EditBlock,

save() {
return null;
}
});
16 changes: 16 additions & 0 deletions src/blocks/block-social-login-buttons/edit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const { __ } = wp.i18n;
const { serverSideRender } = wp;

const el = wp.element.createElement;

let blockName = "social-login-buttons";

// Build the editor settings.
export default function(props) {
return [
el(serverSideRender, {
block: "wpum/" + blockName,
attributes: props.attributes
})
];
}
13 changes: 13 additions & 0 deletions src/blocks/block-social-login-buttons/icon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* WordPress dependencies
*/

const { Path, SVG } = wp.components;

export default (
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30">
<g id="social-login-buttons" fill="#1361FF" fill-rule="nonzero">
<path d="M28,6.937c-0.957,0.425-1.985,0.711-3.064,0.84c1.102-0.66,1.947-1.705,2.345-2.951c-1.03,0.611-2.172,1.055-3.388,1.295 c-0.973-1.037-2.359-1.685-3.893-1.685c-2.946,0-5.334,2.389-5.334,5.334c0,0.418,0.048,0.826,0.138,1.215 c-4.433-0.222-8.363-2.346-10.995-5.574C3.351,6.199,3.088,7.115,3.088,8.094c0,1.85,0.941,3.483,2.372,4.439 c-0.874-0.028-1.697-0.268-2.416-0.667c0,0.023,0,0.044,0,0.067c0,2.585,1.838,4.741,4.279,5.23 c-0.447,0.122-0.919,0.187-1.406,0.187c-0.343,0-0.678-0.034-1.003-0.095c0.679,2.119,2.649,3.662,4.983,3.705 c-1.825,1.431-4.125,2.284-6.625,2.284c-0.43,0-0.855-0.025-1.273-0.075c2.361,1.513,5.164,2.396,8.177,2.396 c9.812,0,15.176-8.128,15.176-15.177c0-0.231-0.005-0.461-0.015-0.69C26.38,8.945,27.285,8.006,28,6.937z"/>
</g>
</svg>
);
28 changes: 28 additions & 0 deletions src/blocks/block-social-login-buttons/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Social Login query block.
*/

const { __ } = wp.i18n;
const { registerBlockType } = wp.blocks;

// Import block editor settings
import EditBlock from './edit';
import icon from "./icon";

let blockName = 'social-login-buttons';

// Register the block.
registerBlockType( 'wpum/' + blockName, {
title: wpum_blocks.blocks[blockName].labels.title,
description: wpum_blocks.blocks[blockName].labels.description,
icon,
category: 'wpum',
keywords: wpum_blocks.blocks[blockName].labels.keywords,
attributes: wpum_blocks.blocks[blockName].attributes,

edit: EditBlock,

save() {
return null;
}
});
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import "./blocks/block-registration-form/index.js";
import "./blocks/block-user-directory/index.js";
import "./blocks/block-post-form/index.js";
import "./blocks/block-group-directory/index.js";
import "./blocks/block-like-button/index.js";
import "./blocks/block-social-login-buttons/index.js";
import "./blocks/block-private-content/index.js";
import "./style.scss";

// Setup custom icon for the WPUM blocks category.
Expand Down

0 comments on commit d7765a2

Please sign in to comment.