GithubHelp home page GithubHelp logo

wpbp / wordpress-plugin-boilerplate-powered Goto Github PK

View Code? Open in Web Editor NEW
765.0 28.0 113.0 2.39 MB

Wordpress Plugin Boilerplate but Powered with examples and a generator!

Home Page: https://wpbp.github.io/

License: GNU General Public License v3.0

JavaScript 0.89% PHP 98.89% Shell 0.08% SCSS 0.14%
php wordpress wordpress-plugin-boilerplate boilerplate hacktoberfest

wordpress-plugin-boilerplate-powered's People

Contributors

alecrust avatar ayoolatj avatar charmoney avatar deshack avatar erikyo avatar eugeniopetulla avatar jlzaratec avatar jmarceli avatar lucasdemea avatar martijnengler avatar mikeill avatar mte90 avatar overclokk avatar ryvix avatar szepeviktor avatar xdamman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wordpress-plugin-boilerplate-powered's Issues

Parse error: syntax error, unexpected ... runtime-created function on line 1

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"

Pluggable Functions

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.

Add thumbnail in cpt list

// 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' );

Retrieve Optios Page values

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!

File not exist on Windows

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

Failed opening required wp-contextual-help.php

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).

Move to a composer 5.2 compatible system

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:

  • Replace all the library with composer package system
  • For the library that not exist as composer package or repo leave like that

Text at top of my-first-try.php plugin file

This is the exact code in the header comments on the main my-first-try.php file as generated by YO

with this in the file my plugin would not install and as a consequence not activate

  • @Wordpress-Plugin

  • My First Try: @todo

  • Plugin URI: @todo

  • Description: @todo

  • Version: 0.0.1

  • Author: Peter

    This is what I changed it to to be able to load it into my wordpress site

    I was then able to install and activate

  • @Wordpress-Plugin

  • 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

Fix per i metodi del plugin ceceppa multilingua

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.

fake_page throws error

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?

[snippet] Add the cpt in the search

<?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');

Improve Pn_Debug performance

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;

Cloning submodules fails

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.

pll__ in get_string doesn't work if my plugin call it before Polylang set it

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

call_user_func_array() expects parameter 1 to be a valid callback

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

Anonymous function in includes/language.php

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 );
    }
}

Custom column in CPT

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;
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.