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

Filters #1995

Open
wants to merge 45 commits into
base: develop
Choose a base branch
from
Open

Filters #1995

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
8facda3
new: Made te fields optional for update blocks/popups/layouts
alecszaharia Nov 24, 2021
87d0a52
new: html changes in page.html.twig
alecszaharia Dec 1, 2021
eebc0dc
new: Added title and tags for block/layouts/popups
alecszaharia Dec 1, 2021
d98397a
new: Added filter to be able to change the story rewrite slug
alecszaharia Dec 6, 2021
e798158
fix: decode the htmlentity encoded title and tags
alecszaharia Dec 7, 2021
e9e2a81
new: Added ignore dc placeholder
alecszaharia Jan 17, 2022
09b908b
new: Added simple post aware and fixed few placeholders
alecszaharia Jan 19, 2022
09a8f09
Upodated editor build branch
Feb 20, 2021
37123d8
Added post action to delete the context folder
alecszaharia Feb 21, 2021
e52b461
fix: Added additional data about the post in editor config.
alecszaharia Jun 10, 2021
e5cde63
feat: Filters for post loops
alecszaharia Oct 9, 2020
af20e5c
....
alecszaharia Apr 2, 2021
1555133
...
alecszaharia Apr 28, 2021
59de4d0
feat: added nested filters
alecszaharia Apr 29, 2021
6afee0b
fix: changes after rebase
alecszaharia Jul 29, 2021
1781bb0
...
alecszaharia Oct 27, 2021
a93a177
fix: placehodersContent action
alecszaharia Nov 29, 2021
9a531c5
fix: fixed get placeholders content action
alecszaharia Nov 29, 2021
0e2a9d3
new: filter placeholder content ...
alecszaharia Feb 14, 2022
daa0c4b
new: filter placeholder content
alecszaharia Feb 15, 2022
9f0a8ac
fix: made the filter placeholder content action public
alecszaharia Feb 17, 2022
a901419
fix: fixed the content parsed for filter placeholders
alecszaharia Feb 17, 2022
541471a
fix: added page placeholders in context
alecszaharia May 18, 2022
a2dee09
fix: added placeholders in context
alecszaharia May 19, 2022
71dd5a1
fix: optimized dynamic content processor
alecszaharia May 20, 2022
c30e6b3
...
alecszaharia May 23, 2022
7b5ada3
fix: dynamic content processor
alecszaharia May 23, 2022
1494fa2
fix: dynamic content processor
alecszaharia May 23, 2022
97de8fe
fix: compile page when asking for a placeholder html
alecszaharia Jun 9, 2022
e1e4270
fix: small fix when wrong placeholder id is required
alecszaharia Jun 13, 2022
d93b931
fix: use $_REQUEST instead if $_POST
alecszaharia Jun 23, 2022
88c3cd9
Fix: #19185 - Fix condition modal editor by global rules
ViorelEremia Jul 26, 2022
a8ceccd
fix: filter refactoring
alecszaharia Aug 9, 2022
a781d41
fix: Config values in dev mode 2
alecszaharia Sep 22, 2022
ebb6337
fix: Context factor
alecszaharia Oct 7, 2022
377ddca
fix: small fixes after rebase.
alecszaharia Jul 18, 2023
7fea1b9
fix: added filters in module groups
alecszaharia Jul 19, 2023
e07f801
fix: added a new method in context to find by name and id
alecszaharia Aug 1, 2023
1cedf09
fix: removed notion of -tag and -pag logic from api
alecszaharia Aug 3, 2023
daba9c3
new: added filter placeholders url in config.
alecszaharia Aug 23, 2023
3c1ed7c
new: added editor client config filter
alecszaharia Sep 21, 2023
4a41c94
Filters From Api
GunkaArtur Oct 11, 2023
0579de4
moved to API from editor
GunkaArtur Aug 23, 2023
fd78f37
fixes for filters sources
GunkaArtur Apr 11, 2024
a9e2a2f
fix: brizy_filter_placeholders_content action
alecszaharia Apr 18, 2024
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
8 changes: 4 additions & 4 deletions .github/.build-env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
BUILD_ENVIRONMENT=develop
FREE_BRANCH=develop
PRO_BRANCH=develop
EDITOR_BRANCH=dev
BUILD_ENVIRONMENT=master
FREE_BRANCH=master
PRO_BRANCH=master
EDITOR_BRANCH=master
10 changes: 9 additions & 1 deletion admin/abstract-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ protected function verifyNonce( $action ) {
}
}

protected function addAjaxAction($action,$callable) {
add_action( 'wp_ajax_' . Brizy_Editor::prefix($action), $callable );
}

protected function addNoPrivAjaxAction($action,$callable) {
add_action( 'wp_ajax_nopriv_' . Brizy_Editor::prefix($action), $callable );
}

/**
* @param int|string $name
*
Expand Down Expand Up @@ -67,4 +75,4 @@ protected function error( $code, $message ) {
protected function success( $data ) {
wp_send_json_success( $data );
}
}
}
121 changes: 61 additions & 60 deletions admin/blocks/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ public function actionDownloadBlocks() {
$items = array_filter( $items );

if ( count( $items ) == 0 ) {
$this->error( 404, __( 'There are no blocks to be archived', 'brizy' ) );
}
$this->error( 404, __( 'There are no blocks to be archived', 'brizy'));
}

$fontManager = new Brizy_Admin_Fonts_Manager();
$zip = new Brizy_Editor_Zip_Archiver(
Expand Down Expand Up @@ -235,18 +235,15 @@ public function actionCreateGlobalBlock() {

if ( $status == 'publish' && is_null( $compiledData ) ) {
$this->error( 400, "The compiled data is missing" );
}

$bockManager = new Brizy_Admin_Blocks_Manager( Brizy_Admin_Blocks_Main::CP_GLOBAL );
}$bockManager = new Brizy_Admin_Blocks_Manager(Brizy_Admin_Blocks_Main::CP_GLOBAL);

/**
* @var Brizy_Editor_Block $block ;
*/
$block = $bockManager->createEntity( $this->param( 'uid' ), $status );
$block->setMeta( stripslashes( $this->param( 'meta' ) ) );
$block->set_editor_data( $editorData );
$block->set_needs_compile( true );
$block->setHtml( $html );
* @var Brizy_Editor_Block $block;
*/
$block = $bockManager->createEntity($this->param('uid'), $status);
$block->setMeta(stripslashes($this->param('meta')));
$block->set_editor_data($editorData);
$block->set_needs_compile(true);$block->setHtml( $html );

if ( $status == 'publish' && $compiledData ) {

Expand All @@ -256,7 +253,7 @@ public function actionCreateGlobalBlock() {
$this->error( 400, "The compiled data is invalid" );
}

$block->set_encoded_compiled_html( $compiled['html'] );
$block->set_encoded_compiled_html( $compiled['html'] );
$block->set_compiled_scripts( [
'free' => $compiled['assets']['freeScripts'],
'pro' => ( isset( $compiled['assets']['proScripts'] ) ? $compiled['assets']['proScripts'] : [] ),
Expand All @@ -272,14 +269,15 @@ public function actionCreateGlobalBlock() {
}

if ( $this->param( 'tags' ) ) {
$block->setTags( stripslashes( $this->param( 'tags' ) ) );
}

if ( $position ) {
$block->setPosition(
Brizy_Editor_BlockPosition::createFromSerializedData( get_object_vars( json_decode( $position ) ) )
);
}
$block->setTags(stripslashes($this->param('tags')));
}

if ($position) {
$block->setPosition(
Brizy_Editor_BlockPosition::createFromSerializedData(get_object_vars(json_decode($position)))
);
}

// rules
if ( $rulesData ) {
Expand Down Expand Up @@ -428,8 +426,8 @@ public function actionUpdateGlobalBlocks() {
}
}

$bockManager = new Brizy_Admin_Blocks_Manager( Brizy_Admin_Blocks_Main::CP_GLOBAL );
$blocks = $bockManager->getEntity( (array) $this->param( 'uid' ) );
$bockManager = new Brizy_Admin_Blocks_Manager(Brizy_Admin_Blocks_Main::CP_GLOBAL);
$blocks = $bockManager->getEntity((array)$this->param('uid'));

foreach ( (array) $this->param( 'uid' ) as $i => $uid ) {

Expand Down Expand Up @@ -519,13 +517,15 @@ public function actionUpdateGlobalBlocks() {

$block->save();

do_action( 'brizy_global_block_updated', $block );
}
}
do_action('brizy_global_block_updated', $block);

}
}

do_action( 'brizy_global_data_updated' );

$this->success( [] );

$this->success([]);

} catch ( Exception $exception ) {
$this->error( 400, $exception->getMessage() );
Expand Down Expand Up @@ -554,24 +554,25 @@ public function actionDeleteGlobalBlock() {
public function actionGetSavedBlocks() {
$this->verifyNonce( self::nonce );

try {
$fields = $this->param( 'fields' ) ? $this->param( 'fields' ) : [];
$bockManager = new Brizy_Admin_Blocks_Manager( Brizy_Admin_Blocks_Main::CP_SAVED );
$blocks = $bockManager->getEntities( [
'paged' => (int) ( $this->param( 'page' ) ?: 1 ),
'posts_per_page' => (int) ( $this->param( 'count' ) ?: - 1 ),
'order' => $this->param( 'order' ) ?: 'ASC',
'orderby' => $this->param( 'orderby' ) ?: 'ID',
] );
$blocks = apply_filters( 'brizy_get_saved_blocks',
$bockManager->createResponseForEntities( $blocks, $fields ),
$fields,
$bockManager );
$this->success( $blocks );
} catch ( Exception $exception ) {
$this->error( 400, $exception->getMessage() );
}
}
try {
$fields = $this->param('fields') ? $this->param('fields') : [];
$bockManager = new Brizy_Admin_Blocks_Manager(Brizy_Admin_Blocks_Main::CP_SAVED);
$blocks = $bockManager->getEntities([
'paged' => (int)($this->param('page') ?: 1),
'posts_per_page' => (int)($this->param('count') ?: -1),
'order' => $this->param('order') ?: 'ASC',
'orderby' => $this->param('orderby') ?: 'ID',
]);$blocks = apply_filters(
'brizy_get_saved_blocks',
$bockManager->createResponseForEntities($blocks, $fields),
$fields,
$bockManager
);
$this->success($blocks);
} catch (Exception $exception) {
$this->error(400, $exception->getMessage());
}
}

public function actionGetSavedBlockByUid() {
$this->verifyNonce( self::nonce );
Expand Down Expand Up @@ -618,20 +619,20 @@ public function actionCreateSavedBlock() {
$this->error( 400, 'Invalid media data provided' );
}

try {
$bockManager = new Brizy_Admin_Blocks_Manager( Brizy_Admin_Blocks_Main::CP_SAVED );
$block = $bockManager->createEntity( $this->param( 'uid' ) );
$block->setMedia( stripslashes( $this->param( 'media' ) ) );
$block->setMeta( stripslashes( $this->param( 'meta' ) ) );
try {
$bockManager = new Brizy_Admin_Blocks_Manager(Brizy_Admin_Blocks_Main::CP_SAVED);
$block = $bockManager->createEntity($this->param('uid'));
$block->setMedia(stripslashes($this->param('media')));
$block->setMeta(stripslashes($this->param('meta')));

if ( $this->param( 'title' ) ) {
if($this->param('title')){
$block->setTitle( stripslashes( $this->param( 'title' ) ) );
}
if ( $this->param( 'tags' ) ) {
$block->setTags( stripslashes( $this->param( 'tags' ) ) );
}
$block->setTags(stripslashes($this->param('tags')));
}

$block->set_editor_data( $this->sanitizeJson(stripslashes( $this->param( 'data' ) ) ));
$block->set_editor_data( $this->sanitizeJson(stripslashes( $this->param( 'data' ) ) ));
$block->set_needs_compile( true );
//$block->setCloudUpdateRequired( true );
$block->save();
Expand Down Expand Up @@ -688,13 +689,13 @@ public function actionUpdateSavedBlock() {
}


if ( (int) $this->param( 'is_autosave' ) ) {
$block->save( 1 );
} else {
$block->save();
do_action( 'brizy_saved_block_updated', $block );
do_action( 'brizy_global_data_updated' );
}
if ((int)$this->param('is_autosave')) {
$block->save(1);
} else {
$block->save();
do_action('brizy_saved_block_updated', $block);
do_action('brizy_global_data_updated');
}

Brizy_Editor_Block::cleanClassCache();

Expand Down
2 changes: 1 addition & 1 deletion admin/blocks/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ private function findReferencedInPage($wpPost)
return [];
}

$context = Brizy_Content_ContextFactory::createContext(Brizy_Editor_Project::get(), $wpPost);
$context = Brizy_Content_ContextFactory::createContext(Brizy_Editor_Project::get(), $wpPost->getWpPost());
$placeholderProvider = new Brizy_Content_Providers_GlobalBlockProvider($context);

$extractor = new \BrizyPlaceholders\Extractor($placeholderProvider);
Expand Down
53 changes: 28 additions & 25 deletions admin/layouts/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ protected function getRequestNonce()

protected function initializeApiActions()
{
$pref = 'wp_ajax_' . Brizy_Editor::prefix();
add_action($pref . self::DOWNLOAD_LAYOUTS, array($this, 'actionDownloadLayouts'));
add_action($pref . self::GET_LAYOUT_BY_UID_ACTION, array($this, 'actionGetLayoutByUid'));
add_action($pref . self::GET_LAYOUTS_ACTION, array($this, 'actionGetLayouts'));
add_action($pref . self::CREATE_LAYOUT_ACTION, array($this, 'actionCreateLayout'));
add_action($pref . self::UPDATE_LAYOUT_ACTION, array($this, 'actionUpdateLayout'));
add_action($pref . self::DELETE_LAYOUT_ACTION, array($this, 'actionDeleteLayout'));
$pref = 'wp_ajax_'.Brizy_Editor::prefix();
add_action($pref.self::DOWNLOAD_LAYOUTS, array($this, 'actionDownloadLayouts'));
add_action($pref.self::GET_LAYOUT_BY_UID_ACTION, array($this, 'actionGetLayoutByUid'));
add_action($pref.self::GET_LAYOUTS_ACTION, array($this, 'actionGetLayouts'));
add_action($pref.self::CREATE_LAYOUT_ACTION, array($this, 'actionCreateLayout'));
add_action($pref.self::UPDATE_LAYOUT_ACTION, array($this, 'actionUpdateLayout'));
add_action($pref.self::DELETE_LAYOUT_ACTION, array($this, 'actionDeleteLayout'));
}

public function actionDownloadLayouts()
Expand Down Expand Up @@ -77,26 +77,26 @@ public function actionDownloadLayouts()

return null;
}, $explode);
$items = array_filter($items);
$items = array_filter($items);
if (count($items) == 0) {
$this->error(404, __('There are no layouts to be archived'));
}

$zipPath = "Layout-" . date(DATE_ATOM) . ".zip";
$zipPath = "Layout-".date(DATE_ATOM).".zip";
$fontManager = new Brizy_Admin_Fonts_Manager();
$zip = new Brizy_Editor_Zip_Archiver(
$zip = new Brizy_Editor_Zip_Archiver(
Brizy_Editor_Project::get(),
$fontManager,
BRIZY_SYNC_VERSION
);
$zipPath = $zip->createZip($items, $zipPath);
$zipPath = $zip->createZip($items, $zipPath);

header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private", false);
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"" . basename($zipPath) . "\";");
header("Content-Disposition: attachment; filename=\"".basename($zipPath)."\";");
header("Content-Transfer-Encoding: binary");

echo file_get_contents($zipPath);
Expand Down Expand Up @@ -143,18 +143,19 @@ public function actionGetLayouts()
$layoutManager = new Brizy_Admin_Layouts_Manager();

$fields = $this->param('fields') ? $this->param('fields') : [];
$layouts = $layoutManager->getEntities(
[

$layouts = $layoutManager->getEntities([
'paged' => (int)($this->param('page') ?: 1),
'posts_per_page' => (int)($this->param('count') ?: -1),
'order' => $this->param('order') ?: 'ASC',
'orderby' => $this->param('orderby') ?: 'ID'
]
);
$layouts = apply_filters('brizy_get_layouts',
]);
$layouts = apply_filters(
'brizy_get_layouts',
$layoutManager->createResponseForEntities($layouts, $fields),
$fields,
$layoutManager);
$layoutManager
);
$this->success($layouts);

} catch (Exception $exception) {
Expand Down Expand Up @@ -201,16 +202,18 @@ public function actionCreateLayout()
$layout->set_editor_data($editorData);
$layout->set_needs_compile(true);

if ($this->param('title')) {
$layout->setTitle(stripslashes($this->param('title')));
}
if($this->param('title'))
{
$layout->setTitle(stripslashes($this->param('title')));
}

if ($this->param('tags')) {
$layout->setTags(stripslashes($this->param('tags')));
}
if($this->param('tags'))
{
$layout->setTags(stripslashes($this->param('tags')));
}


//$layout->setCloudUpdateRequired( true );
//$layout->setCloudUpdateRequired( true );
$layout->setDataVersion(1);
$layout->save();

Expand Down
1 change: 0 additions & 1 deletion admin/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,6 @@ private function enable_brizy_for_post( $p ) {
wp_update_post( $p );
}
do_action( 'brizy_before_enabled_for_post', $p );

$post->enable_editor();
$post->set_template( Brizy_Config::BRIZY_BLANK_TEMPLATE_FILE_NAME );
$post->set_plugin_version( BRIZY_VERSION );
Expand Down
4 changes: 2 additions & 2 deletions admin/rules/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ public function getGroupList() {

$groups = [];

if ( $templateType == 'single' || $templateType == 'single_product' || $context == 'popup-rules' || $context == 'global-block-rules' ) {
if ($templateType == 'single' || $templateType == 'single_product' || $context == 'popup-rules' || $context == 'global-block-rules' ) {
$groups[] = array(
'title' => 'Main Content',
'value' => Brizy_Admin_Rule::POSTS,
Expand All @@ -360,7 +360,7 @@ public function getGroupList() {
) : null;
}

if ( $templateType == 'archive' || $templateType == 'product_archive' || $context == 'popup-rules' || $context == 'global-block-rules' ) {
if ($templateType == 'archive' || $templateType == 'product_archive' || $context == 'popup-rules' || $context == 'global-block-rules' ) {

$archiveItems = array_map( $closure, $this->getArchivesList( Brizy_Admin_Rule::ARCHIVE, $templateType ) );
$taxonomyItems = array_map( $closure, $this->getTaxonomyList( Brizy_Admin_Rule::TAXONOMY, $templateType ) );
Expand Down
2 changes: 1 addition & 1 deletion admin/stories/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static public function registerCustomPosts()
'public' => true,
'description' => __bt( 'brizy', 'Brizy' ) . ' ' . __( 'stories', 'brizy' ) . '.',
'show_in_menu' => Brizy_Admin_Settings::menu_slug(),
'rewrite' => [ 'slug' => self::CP_STORY ],
'rewrite' => [ 'slug' => apply_filters('brizy_story_rewrite_slug',self::CP_STORY) ],
'capability_type' => 'page',
'exclude_from_search' => true,
'supports' => [ 'title', 'post_content', 'revisions' ],
Expand Down
2 changes: 1 addition & 1 deletion brizy.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,4 @@ function brizy_load_text_domain()
load_plugin_textdomain('brizy', false, dirname(plugin_basename(__FILE__)).'/languages');
}

new Brizy_Compatibilities_Init();
new Brizy_Compatibilities_Init();
2 changes: 1 addition & 1 deletion compatibilities/polylang.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class Brizy_Compatibilities_Polylang {

public function __construct() {
add_action( 'brizy_post_loop_args', [ $this, 'post_loop_args' ] );
add_filter( 'brizy_post_loop_args', [ $this, 'post_loop_args' ] );
add_filter( 'pll_home_url_white_list', [ $this, 'home_url_white_list' ] );
}

Expand Down
Loading