1. Go to this page and download the library: Download upflex/mixup library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
upflex / mixup example snippets
>
>
> namespace BaseWp\Front;
>
> use UPFlex\MixUp\Core\Base;
>
> class Assets extends Base
> {
> public function __construct()
> {
> add_action('wp_enqueue_scripts', [self::class, 'styles']);
> add_filter('meu_plugin_priority', [self::class, 'getPriority']);
> }
>
> public static function getPriority() : int
> {
> return 10;
> }
>
> public static function styles()
> {
> wp_enqueue_style('meu_plugin', 'style.css');
> }
> }
>
>
>
> namespace BaseWp\Front;
>
> use UPFlex\MixUp\Core\Base;
> use UPFlex\MixUp\Utils\Fields\Sanitize;
>
> class Contact extends Base
> {
> use Sanitize;
>
> public function __construct()
> {
> add_action('wp_ajax_meu_plugin_send_message', [self::class, 'send']);
> add_action('wp_ajax_nopriv_meu_plugin_send_message', [self::class, 'send']);
> }
>
> public function send()
> {
> $fields = self::getFields('get'); # Recupera campos $_GET
>
> if(!empty($fields['my_email'])) {
> return wp_send_json_success();
> }
>
> return wp_send_json_error();
> }
>
> # Método obrigatório
> protected static function setFields(): array
> {
> # Informa os campos e seus tipos
> return [
> 'name',
> 'my_email' => 'email',
> ];
> }
> }
>