Skip to content

Commit

Permalink
Version 1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
rilwis committed Sep 12, 2024
1 parent 892a3b6 commit 0b48289
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ tests export-ignore
.gitattributes export-ignore
.gitignore export-ignore
*.json export-ignore
phpcs.xml export-ignore
*.md export-ignore
80 changes: 80 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0"?>
<ruleset name="eLightUp WordPress Coding Standards">
<!-- See https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml -->
<!-- See https://github.com/WordPress/WordPress-Coding-Standards -->
<!-- See https://github.com/PHPCompatibility/PHPCompatibilityWP -->

<!--
#############################################################################
COMMAND LINE ARGUMENTS
https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml
#############################################################################
-->

<!-- Pass some flags to PHPCS:
p flag: Show progress of the run.
s flag: Show sniff codes in all reports.
-->
<arg value="ps"/>


<!-- Check up to 8 files simultaneously. -->
<arg name="parallel" value="8"/>

<!-- Check PHP files only. JavaScript and CSS files are checked separately using the @wordpress/scripts package. -->
<arg name="extensions" value="php"/>

<!-- Check all files in this directory and the directories below it. -->
<file>.</file>

<!-- Exclude patterns. -->
<exclude-pattern>/vendor/*</exclude-pattern>
<exclude-pattern>/.github/*</exclude-pattern>

<rule ref="WordPress">
<!-- Use PSR-4 naming -->
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase" />
<exclude name="WordPress.Files.FileName.InvalidClassFileName" />

<!-- Only comment when neccessary -->
<exclude name="Squiz.Commenting.FileComment.Missing" />
<exclude name="Squiz.Commenting.FileComment.MissingPackageTag" />
<exclude name="Squiz.Commenting.ClassComment.Missing" />
<exclude name="Squiz.Commenting.FunctionComment.Missing" />
<exclude name="Squiz.Commenting.FunctionComment.MissingParamTag" />
<exclude name="Squiz.Commenting.VariableComment.Missing" />
<exclude name="Squiz.Commenting.InlineComment.InvalidEndChar" />

<!-- Write shorter -->
<exclude name="Universal.Arrays.DisallowShortArraySyntax.Found" />
<exclude name="Generic.Arrays.DisallowShortArraySyntax.Found" />
<exclude name="Generic.PHP.DisallowShortOpenTag.EchoFound" />
<exclude name="Generic.Commenting.DocComment.SpacingBeforeTags" />
<exclude name="Squiz.PHP.EmbeddedPhp.NoSemicolon" />
<exclude name="WordPress.Classes.ClassInstantiation.MissingParenthesis" />
<exclude name="Universal.Operators.DisallowShortTernary.Found" />
<exclude name="WordPress.PHP.DisallowShortTernary.Found" />
<exclude name="PSR12.Classes.ClassInstantiation.MissingParentheses" />

<!-- Optional -->
<exclude name="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket" />
<exclude name="PEAR.Functions.FunctionCallSignature.CloseBracketLine" />
<exclude name="PEAR.Functions.FunctionCallSignature.MultipleArguments" />
<exclude name="WordPress.PHP.YodaConditions.NotYoda" />
</rule>

<rule ref="Generic.Arrays.DisallowLongArraySyntax" />

<!-- Set the minimum supported WP version. This is used by several sniffs.
The minimum version set here should be in line with the minimum WP version
as set in the "Requires at least" tag in the readme.txt file. -->
<config name="minimum_supported_wp_version" value="5.9"/>

<!--
#############################################################################
USE THE PHPCompatibility RULESET
#############################################################################
-->
<config name="testVersion" value="7.0-"/>
<rule ref="PHPCompatibilityWP"/>
</ruleset>
19 changes: 16 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
=== Meta Box Text Limiter ===
Contributors: metabox, rilwis
Contributors: metabox, rilwis, paracetamol27
Donate link: https://metabox.io
Tags: custom fields, meta box, text limit
Requires at least: 5.9
Tested up to: 6.4.3
Stable tag: 1.2.0
Tested up to: 6.6.2
Stable tag: 1.2.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand All @@ -28,6 +28,16 @@ To start using text limiter, just add the following parameters to `text`, `texta
- [Github repo](https://github.com/wpmetabox/meta-box-text-limiter)
- [View other extensions](https://metabox.io/plugins/)

### You might also like

If you like this plugin, you might also like our other WordPress products:

- [Slim SEO](https://wpslimseo.com) - A fast, lightweight and full-featured SEO plugin for WordPress with minimal configuration.
- [Slim SEO Schema](https://wpslimseo.com/products/slim-seo-schema/) - An advanced, powerful and flexible plugin to add schemas to WordPress.
- [Slim SEO Link Manager](https://wpslimseo.com/products/slim-seo-link-manager/) - Build internal link easier in WordPress with real-time reports.
- [GretaThemes](https://gretathemes.com) - Free and premium WordPress themes that clean, simple and just work.
- [Auto Listings](https://wpautolistings.com) - A car sale and dealership plugin for WordPress.

== Installation ==

You need to install [Meta Box](https://metabox.io) plugin first
Expand All @@ -54,6 +64,9 @@ To start using text limiter, just add the following parameters to `text` or `tex

== Changelog ==

= 1.2.1 - 2024-09-12 =
- Do not count HTML tags

= 1.2.0 - 2024-03-14 =
- Add support for WYSIWYG field
- Update the style
Expand Down
25 changes: 11 additions & 14 deletions text-limiter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@
/**
* Plugin Name: Meta Box Text Limiter
* Plugin URI: https://metabox.io/plugins/meta-box-text-limiter/
* Description: Limit number of characters or words entered for text and textarea fields.
* Version: 1.2.0
* Description: Limit number of characters or words entered for text, textarea, and wysiwyg fields.
* Version: 1.2.1
* Author: MetaBox.io
* Author URI: https://metabox.io
*
* @package Meta Box
* @subpackage Meta Box Text Limiter
*/

if ( ! class_exists( 'MB_Text_Limiter' ) ) {
Expand All @@ -18,24 +15,24 @@ class MB_Text_Limiter {
*
* @var array
*/
protected $types = array( 'text', 'textarea', 'wysiwyg' );
protected $types = [ 'text', 'textarea', 'wysiwyg' ];

public function init() {
add_action( 'rwmb_before', array( $this, 'register' ) );
add_action( 'rwmb_before', [ $this, 'register' ] );

// Change the output of fields with limit.
add_filter( 'rwmb_get_value', array( $this, 'get_value' ), 10, 2 );
add_filter( 'rwmb_the_value', array( $this, 'get_value' ), 10, 2 );
add_filter( 'rwmb_get_value', [ $this, 'get_value' ], 10, 2 );
add_filter( 'rwmb_the_value', [ $this, 'get_value' ], 10, 2 );

add_action( 'rwmb_enqueue_scripts', array( $this, 'enqueue' ) );
add_action( 'rwmb_enqueue_scripts', [ $this, 'enqueue' ] );
}

/**
* Register hook to change the output of text/textarea fields.
*/
public function register() {
foreach ( $this->types as $type ) {
add_filter( "rwmb_{$type}_html", array( $this, 'show' ), 10, 2 );
add_filter( "rwmb_{$type}_html", [ $this, 'show' ], 10, 2 );
}
}

Expand Down Expand Up @@ -97,10 +94,10 @@ public function get_value( $value, $field ) {

public function enqueue() {
// Use helper function to get correct URL to current folder, which can be used in themes/plugins.
list( , $url ) = RWMB_Loader::get_path( dirname( __FILE__ ) );
list( , $url ) = RWMB_Loader::get_path( __DIR__ );

wp_enqueue_style( 'text-limiter', $url . 'text-limiter.css' );
wp_enqueue_script( 'text-limiter', $url . 'text-limiter.js', array( 'jquery' ), '', true );
wp_enqueue_style( 'text-limiter', $url . 'text-limiter.css', [], filemtime( __DIR__ . '/text-limiter.css' ) );
wp_enqueue_script( 'text-limiter', $url . 'text-limiter.js', [ 'jquery' ], filemtime( __DIR__ . '/text-limiter.js' ), true );
}
}

Expand Down

0 comments on commit 0b48289

Please sign in to comment.