wpbp / wordpress-plugin-boilerplate-powered Goto Github PK
View Code? Open in Web Editor NEWWordpress Plugin Boilerplate but Powered with examples and a generator!
Home Page: https://wpbp.github.io/
License: GNU General Public License v3.0
Wordpress Plugin Boilerplate but Powered with examples and a generator!
Home Page: https://wpbp.github.io/
License: GNU General Public License v3.0
Ciao Daniele,
problema riscontrato con la funzione register_string per il supporto al multilingua e il plugin Ceceppa
Parse error: syntax error, unexpected ',', expecting '&' or variable (T_VARIABLE) in E:\xampp\htdocs\italystrap\wp-content\plugins\italy-cookie-choices\includes\functions-italy-cookie-choices-lang.php(57) : runtime-created function on line 1
Mi si presenta se uso più di 3 o 4 volte la funzione mentre sanitizzo gli input, se la uso solo meno di 3 o 4 non si presenta l'errore, visto che il mio plugin prevede PHP >= 5.3 ho usato una funzione anonima:
add_filter( 'cml_my_translations', function ( $groups, $plugin_name_human_format ){
$plugin_name_human_format_replaced = str_replace( ' ', '-', $plugin_name_human_format );
CMLTranslations:add( $string_name, $value, $plugin_name_human_format );
$groups[$plugin_name_human_format_replaced] = $plugin_name_human_format;
return $groups;
} );
Se vuoi provarlo anche tu puoi usare la 2.3.4 https://github.com/ItalyCookieChoices/italy-cookie-choices/releases
Altra cosa strana è che non vedo le stringhe da tradurre in "le mie traduzioni"
Ticket for track the upgrade of CMB
https://github.com/WebDevStudios/CMB2
Sarebbe utile mettere un controllo per le funzioni in caso vengano utilizzate in altri plugin, ci stavo pensando mentre facevo un controllo sulle funzioni per il multilingua che ho quindi messo in una if per evitare eventuali conflitti con altri plugin sviluppati usando il tuo codice, un po' il problema che si è creato con composer.
// Based on https://github.com/synapticism/ubik-admin/blob/master/ubik-admin/ubik-admin-post-list-thumbs.php
function ubik_admin_posts_columns( $defaults ) {
$defaults['featured_image'] = __( 'Thumb', 'ubik' );
return $defaults;
}
function ubik_admin_posts_custom_columns( $column_name, $id ) {
if ( $column_name === 'featured_image' )
echo the_post_thumbnail( array( 60, 60 ) );
}
function ubik_admin_posts_columns_style() {
?>
<style type="text/css">
.column-featured_image {
width: 60px;
}
td.column-featured_image {
text-align: center;
}
</style>
<?php
}
add_filter( 'manage_posts_columns', 'ubik_admin_posts_columns', 5);
add_action( 'manage_posts_custom_column', 'ubik_admin_posts_custom_columns', 5, 2);
add_action( 'admin_head-edit.php', 'ubik_admin_posts_columns_style' );
Hi, congrats for this great plugin starter, i am using it and cannot find the way to get the demo options page values.
Do i need to code my own function to get the values or is it included? I cannot find it.
Thank you very much!
Integrate SASS with grunt and compass for the developer
It created a *.json file but did not create and files what so ever
When I created a directory under wp-content/plugins
yeoman generator complained about a directory being there
Not sure what I am doing wrong
There is an Error
ENOENT, no such file or directory then it calls for a plugin directory which is not being created
File: `/public/includes/requirements.php'
Called by: WordPress_Requirement::message()
The method WordPress_Requirement::getWordPressVersion()
is called, but not defined.
The DocBlock @return
comment for PHP_Extension_Requirement::check()
indicates that that method returns an array, while it returns a boolean.
Fatal error: require_once()
: Failed opening required '/[path]/wp-content/plugins/[plugin-slug]/admin/includes/WP-Contextual-Help/wp-contextual-help.php' (include_path='.:/usr/share/php:/usr/share/pear') in /[path]/wp-content/plugins/[plugin-slug]/admin/class-[plugin-slug]-admin.php on line 104
Raised generating the plugin with the latest generator and the 'dev' option. What follows are the settings passed to the generator:
[?] Which resources your public site needs? JS, CSS
[?] Which resources your plugin needs?
[?] Does your plugin need an admin page? Yes
[?] Which library your plugin needs? WP-Contextual-Help, Language function support (WPML/Ceceppa Multilingua/Polylang)
[?] Which snippet your plugin needs? Debug system (Debug Bar support), Add body class, wp_localize_script for PHP var to JS, Custom action, Custom filter
[?] Do you need an initialized git repo? Yes
[?] Do you want clean the folders? Yes
The only content of admin/includes/WP-Contextual-Help/ is the file index.php (automatically inserted by the generator).
The actual code have the powerful to load the libraries that use only on specific areas: admin, public and both.
Composer instead have an autoload system that avoid this but is different from the actual solution and few libraries don't exist as packagist package or repo.
Roadmap:
This is the exact code in the header comments on the main my-first-try.php file as generated by YO
My First Try: @todo
Plugin URI: @todo
Description: @todo
Version: 0.0.1
This is what I changed it to to be able to load it into my wordpress site
Plugin Name: My First Try
Plugin URI: www.com
Description: a bunch of stuff
Version: 0.0.1
Author: Peter
OR
Am I doing something wrong
I just answered the YO Generator questions
Ciao Daniele,
ho riscontrato alcuni problemi con il plugin Ceceppa a cui ho trovato anche la soluzione provvisoria che ti passo, il problema era che non venivano stampate le traduzioni nel front-end e non venivano neanche registrate sul DB, visto che ci sono diverse modifiche prima di passarti il file preferisco indicartele qui:
Comincio dalla fine:
Riga 102
return CMLTranslations::get( CMLLanguage::get_current_id(), strtolower( $string_name ), str_replace( ' ', '-', $plugin_name_human_format, $true ) );
Ho aggiunto strlower perchè viene usato nel metodo per registrare la stringa nel db (fatto vari var_dump), in questo modo viene regolarmente stampata la stringa nel front-end (nel back-end nessun problema) visto che è case sensitive.
Riga 81
CMLTranslations::delete( $plugin_name_human_format );
Con il metodo CMLTranslations::add e CMLTranslations:get usi $plugin_name_human_format
non $plugin_name_human_format_replaced
.
E ora veniamo alla parte grossa, alla riga 52 sfrutti il filtro cml_my_translations
che però al salvataggio delle opzioni (nel mio caso il plugin dei cookie) non viene eseguito e quindi ciccia, non salva le stringhe, poi hai dimenticato i : nel metodo e manca anche la funzione str_replace sulla variabile $plugin_name_human_format
, qui il metodo corretto:
CMLTranslations::add( $string_name, $value, str_replace( ' ', '-', $plugin_name_human_format ) );
Penso sia meglio però fare il check se esiste la classe e non il filtro, ma non ho ancora provato se funziona anche così.
Ora rimane solo dove mettere la lista delle stringhe nel back-end, al momento l'unica soluzione è creare una funzione esterna e appendersi al filtro:
function cml_icc_strings( $groups ) {
$groups[ "Italy-Cookie-Choices" ] = "Italy Cookie Choices";
return $groups;
}
add_filter( 'cml_my_translations', 'cml_icc_strings' );
Però rimane il problema di passare il parametro del nome del plugin, questa era solo una funzione per fare un test che ha funzionato.
Intanto sistemo meglio il mio file, vedi tu cosa fare.
When browsing to the page created with the fake page class, i get the following error:
Undefined property: stdClass::$post_type in /wp-includes/query.php
Notice: Undefined offset: -1604600763 in /wp-includes/query.php on line 3708
am i using it wrong?
<?php
function filter_search($query) {
if ($query->is_search) {
$query->set('post_type', array('post', 'your-custom-type'));
};
return $query;
};
add_filter('pre_get_posts', 'filter_search');
You can improve Pn_Debug class performances a little bit by switching the capabilities and WP_DEBUG
checks.
Current check:
if ( ! current_user_can( 'manage_options' ) || ! WP_DEBUG )
return;
Since WP_DEBUG
is a constant, thus replaced with its own value at compile time, you can short circuit the conditional and avoid a function call when WP_DEBUG is false.
if ( ! WP_DEBUG || ! current_user_can( 'manage_options' ) )
return;
git -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=sourcetree submodule update --init --recursive
Cloning into 'plugin-name/admin/includes/CMB2-Shortcode'...
Permission denied (publickey).
fatal: Could not read from remote repository.
is this a github issue or my authentication?
i´m new to submodules, help is appreciated. thanks.
Fix text domain with only the slug.
Te lo scrivo in italiano che faccio prima, la funzione get_string non ritorna la stringa tradotta se è richiamata prima che questa venga settata da Polylang, se ti viene in mente una soluzione bene, se no comunque ci lavoro io e poi te la passo.
Un esempio veloce, stessa istanza, in __construct non becca la stringa di pll, in una funzione appesa a wp_footer la becca senza problemi. (Il plugin è Italy Cookie Choices, forse anche perché viene caricato in ordine alfabetico?)
Al max setto la variabile in una funzione e la appendo prima di wp_footer
Actually the boilerplate have a snippet for add capabilities but don't create new roles.
With #49 will be not needed anymore
Got the generator to work on a mac and was able to genrate full set of files
Finally got it loaded into a localhost wamp install
Was able to successfully install plugin
Got the following two(2) errors when trying to activate plugin
(1)
Warning: call_user_func_array() expects parameter 1 to be a valid callback, class 'My_First_Try_Admin' not found in C:\wamp\www\website.com\wp-includes\plugin.php on line 496
(2)
Fatal error: Class 'Plugin_Name' not found in C:\wamp\www\website.com\wp-content\plugins\my-first-try\includes\widgets\sample.php on line 8
Evaluate that integration https://github.com/Freemius/wordpress-sdk
Maybe only of the sdk without the code that is generated from the freemius dashboard.
The anonymous function in language.php was causing an error for a user of a plugin I created using this boilerplate. The error came from line 36 which includes: add_filter( 'cml_my_translations' ...
Here is how I fixed the code:
function register_string( $plugin_name_human_format, $string_name, $value ) {
if ( function_exists( 'icl_register_string' ) ) {
icl_register_string( $plugin_name_human_format, $string_name, $value );
} elseif ( has_filter( 'cml_my_translations' ) ) {
add_filter( 'cml_my_translations', create_function( "$groups, $plugin_name_human_format","
$plugin_name_human_format_replaced = str_replace( ' ', '-', $plugin_name_human_format );
CMLTranslations:add( $string_name, $value, $plugin_name_human_format );
$groups[$plugin_name_human_format_replaced] = $plugin_name_human_format;
return $groups;"
) );
} elseif ( function_exists( 'pll_register_string' ) ) {
$plugin_name_human_format_replaced = str_replace( ' ', '-', $plugin_name_human_format );
pll_register_string( $plugin_name_human_format_replaced, $string_name );
}
}
Example code
add_action( 'manage_edit-wedding-item_columns', array( $this, 'wedding_columns' ) );
add_action( 'manage_wedding-item_posts_custom_column', array( $this, 'wedding_custom_columns' ), 10, 2 );
function wedding_custom_columns( $column, $post_id ) {
switch ( $column ) {
case 'import' :
$elements = get_post_meta( $post_id, 'wedding_list-group', true );
$total = 0;
foreach ( $elements as $value ) {
$total += floatval( str_replace( ',', '.', str_replace( '.', '', $value[ 'import' ] ) ) );
}
echo '€ ' . str_replace( '.', ',', $total );
break;
case 'user' :
$user = p2p_type( 'user_to_wedding-item' )->set_direction( 'from' )->get_connected( $post_id );
echo $user->results[0]->data->user_login;
break;
default :
break;
}
}
public function wedding_columns( $columns ) {
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => __( 'Lista' ),
'import' => __( 'Importo' ),
'user' => __( 'Utente' ),
'date' => __( 'Data' )
);
return $columns;
}
Or something similar
The function need to support also only the slug.
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.