widoz / twig-wordpress Goto Github PK
View Code? Open in Web Editor NEWThe famous Twig Template for WordPress
License: GNU General Public License v2.0
The famous Twig Template for WordPress
License: GNU General Public License v2.0
Introduce a specific kses for images.
Take into account we have to support not only images but responsive images.
See gist for hint https://gist.github.com/widoz/2b0e7501fb4b86103e3e529339652952#file-ksesimage-php
The function will print the markup for a custom header.
Similar to paginate_comments_links()
(see #13) we could allow to pass the labels.
A wrapper would be great but not sure how to make the classes bem like.
See f10a5c8fab0b32e26cec245a42457aec8b372cf0
in wordpress-model
for more informations.
Do not specify the list name in the constant that reference the filter for the functions/escapers list.
Es.
Not FILTER_KSES_LIST
but FILTER_FUNCTION_LIST
because the name is already in the class.
Consider part of the deleted implementation from wordpress-model
<?php # -*- coding: utf-8 -*-
/*
* This file is part of the WordPress Theme Model package.
*
* (c) Guido Scialfa <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace WordPressModel\Model;
use Widoz\Bem\Factory;
use Widoz\Bem\Valuable;
/**
* Paginate Post Model
*/
final class PostPaginate implements FullFilledModel
{
public const FILTER_DATA = 'wordpressmodel.post_paginate';
public const FILTER_PAGINATE_LIST = 'wp_link_pages_link';
/**
* @inheritdoc
*/
public function data(): array
{
$bem = Factory::createServiceForStandard('pagination');
if (!$this->isMultipage()) {
/**
* Post Paginate Filter
*
* @param array $data The post paginate data
*/
return apply_filters(self::FILTER_DATA, []);
}
add_filter(
self::FILTER_PAGINATE_LIST,
[$this, 'makePaginationMarkupClassesBemLike'],
0
);
/**
* Post Paginate Filter
*
* @param array $data The post paginate data
*/
$data = apply_filters(self::FILTER_DATA, [
'container' => [
'attributes' => [
'class' => $bem,
],
],
'markup' => \wp_link_pages([
'echo' => 0,
'before' => $this->before($bem->value()),
'after' => $this->after(),
'link_before' => $this->linkBefore(),
]),
]);
remove_filter(
self::FILTER_PAGINATE_LIST,
[$this, 'makePaginationMarkupClassesBemLike'],
0
);
return $data;
}
/**
* @return mixed
*/
private function isMultipage(): bool
{
global $multipage;
return $multipage;
}
/**
* Make Pagination Attribute Class Bem Like
* Change the class attribute value with ones that provide bem like string.
*
* @param string $link
*
* @return string The filtered link
*/
public function makePaginationMarkupClassesBemLike(string $link): string
{
$bem = Factory::createServiceForStandard('pagination');
$link = '<li class="' . \sanitize_html_class($bem->forElement('item')) . '">' . $link . '</li>';
return $link;
}
/**
* @param Valuable $bem
* @return string
*/
private function before(Valuable $bem): string
{
return '<ul class="' . \sanitize_html_class($bem) . '">';
}
/**
* @return string
*/
private function after(): string
{
return '</ul>';
}
/**
* @return string
*/
private function linkBefore(): string
{
return \sprintf(
'<span class="screen-reader-text">%s</span>',
\esc_html_x('Page', 'pagination', 'wordpress-model')
);
}
}
Regarding get_comment_pages_count
may be a wrapper has_comment_pages
so we don't need to make the developer check agains get_comment_pages_count() > 1
everytime.
For paginate_comments_links
may be a wrapper would be better so we don't need to add custom configuration.
Or at least, let's just pass the labels such as:
paginate_comments_links(
esc_html__('Page', 'textdomain'),
esc_html__('Previous Comments', 'textdomain'),
esc_html__('Next Comments', 'textdomain')
)
sanitize_html_class
is often used as a function call within the class
property so, make sense to have it also as a filter not only as a function.
Since there is not way currently to define a function + a filter once, could be ok to include it together with the escapers
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.