Skip to content

Commit 3f7adf6

Browse files
committed
[DEV] lanzamiento 1.8
1 parent a093269 commit 3f7adf6

9 files changed

+337
-213
lines changed

antonella

Lines changed: 214 additions & 188 deletions
Large diffs are not rendered by default.

antonella-framework.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Plugin Name: Antonella Framework
55
Plugin URI:
66
Description:Another plugin developed on Antonella Framework for WP
7-
Version: 1.7
7+
Version: 1.8
88
Author: Carlos Herrera
99
Author URI:
1010
Framework: Antonella Framework for WP
@@ -24,7 +24,6 @@
2424
*
2525
* @return null
2626
*/
27-
define('NELLA_URL',__FILE__);
2827
$loader = require __DIR__ . '/vendor/autoload.php';
2928
$antonella= new Start;
3029

bitbucket-pipelines.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name":"cehojac/antonella-framework-for-wp",
3-
"version":"1.7.3",
3+
"version":"1.8.0",
44
"keywords": ["framework", "wordpress", "plugins"],
55
"prefer-stable": true,
66
"minimum-stability": "dev",

docker-compose.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
version: '3'
2+
3+
services:
4+
mysql:
5+
image: mariadb
6+
restart: always
7+
ports:
8+
- 8081:3306
9+
environment:
10+
MYSQL_USER: wordpress
11+
MYSQL_ROOT_PASSWORD: wordpress
12+
MYSQL_DATABASE: wordpress
13+
MYSQL_PASSWORD: wordpress
14+
15+
phpmyadmin:
16+
image: phpmyadmin/phpmyadmin
17+
ports:
18+
- 80:80
19+
environment:
20+
MYSQL_USERNAME: 'user'
21+
MYSQL_ROOT_PASSWORD: 'password'
22+
23+
wordpress:
24+
depends_on:
25+
- mysql
26+
image: wordpress:php8.0-apache
27+
ports:
28+
- 8080:80
29+
restart: always
30+
volumes:
31+
- ./:/var/www/html/wp-content/plugins/antonella-framework
32+
environment:
33+
WORDPRESS_DB_HOST: mysql:3306
34+
WORDPRESS_DB_USER: wordpress
35+
WORDPRESS_DB_PASSWORD: wordpress
36+
links:
37+
- mysql

src/Api.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace CH;
4+
use CH\Config;
5+
class Api
6+
{
7+
/*
8+
* Construct
9+
* @return void
10+
*/
11+
public function __construct()
12+
{
13+
14+
}
15+
/*
16+
* initial function. you can call your functions here
17+
* @return void
18+
*/
19+
public static function index()
20+
{
21+
$config = new Config;
22+
$apis = $config->api_endpoints_functions;
23+
if(count($apis)>0){
24+
foreach($apis as $api){
25+
if(isset($api[0])&&isset($api[1])&&isset($api[2])){
26+
\register_rest_route( $config->api_endpoint_name.'/v'.$config->api_endpoint_version, '/'.$api[0].'/(?P<id>\d+)', array(
27+
'methods' => $api[1],
28+
'callback' => $api[2],
29+
) );
30+
}
31+
}
32+
}
33+
34+
}
35+
}

src/Config.php

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,26 +41,39 @@ class Config
4141
* add_filter data functions
4242
* @input array
4343
* @example ['body_class','CH::function',10,2]
44-
* @example ['body_class',['CH','function'],10,2]
44+
* @example ['body_class',[__NAMESPACE__.'\ExampleController,'function'],10,2]
4545
*/
4646
public $add_filter=[
4747
];
4848
/**
4949
* add_action data functions
5050
* @input array
5151
* @example ['body_class','CH::function',10,2]
52-
* @example ['body_class',['CH','function'],10,2]
52+
* @example ['body_class',[__NAMESPACE__.'\ExampleController','function'],10,2]
5353
*/
5454
public $add_action=[
5555
];
5656
/**
5757
* add custom shortcodes
5858
* @input array
59-
* @example [['example','CH\ExampleController::example_shortcode']]
59+
* @example [['example','__NAMESPACE__.\ExampleController::example_shortcode']]
6060
*/
6161
public $shortcodes=[
62-
['example','CH\ExampleController::example_shortcode']
62+
// ['example',__NAMESPACE__'.\ExampleController::example_shortcode']
6363
];
64+
65+
/**
66+
* add APIs Endpoints
67+
* @param array
68+
* @example [['name','GET',__NAMESPACE__.'\apiController::index']]
69+
* @example route: /wp-json/my-plugin-endpoint/v1/name
70+
*/
71+
public $api_endpoint_name= "my-plugin-endpoint";
72+
public $api_endpoint_version=1;
73+
public $api_endpoints_functions=[
74+
// ['name','GET',__NAMESPACE__.'\ExampleController::example_api']
75+
];
76+
6477
/**
6578
* add Gutenberg's blocks
6679
*/
@@ -99,7 +112,7 @@ class Config
99112
"icon" => "antonella-icon.png",
100113
"slug" => "my-custom-page",
101114
]
102-
115+
103116
[
104117
"path" => ["page"],
105118
"name" => "My Custom Page",
@@ -202,7 +215,7 @@ class Config
202215
"rewrite" =>[],
203216
"capabilities" =>[]
204217
*/
205-
]
218+
]
206219
];
207220

208221
/**
@@ -213,5 +226,5 @@ class Config
213226
* @example public $widget = [__NAMESPACE__.'\YouClassWidget'] //only the class
214227
*/
215228
public $widgets=[];
216-
229+
217230
}

src/Hooks.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ public function __construct()
2121
*/
2222
public function registrer()
2323
{
24-
register_activation_hook( NELLA_URL, array(__NAMESPACE__.'\Install','index'));
25-
register_deactivation_hook( NELLA_URL, array(__NAMESPACE__.'\Desactivate','index') );
26-
register_uninstall_hook( NELLA_URL, __NAMESPACE__.'\Unistall::index' );
24+
register_activation_hook( __FILE__, array(__NAMESPACE__.'\Install','index'));
25+
register_deactivation_hook( __FILE__, array(__NAMESPACE__.'\Desactivate','index') );
26+
register_uninstall_hook( __FILE__, __NAMESPACE__.'\Unistall::index' );
2727
}
2828
/*
2929
* filter call
@@ -57,6 +57,9 @@ public function action($action)
5757
\add_action( 'admin_init', array(__NAMESPACE__.'\Admin\PageAdmin','index') );
5858
//INIT SECTION
5959
\add_action( 'init', array(__NAMESPACE__.'\Init','index'), 0 );
60+
//API SECION
61+
\add_action('rest_api_init',array(__NAMESPACE__.'\Api','index'),1);
62+
6063
//REQUEST SECTION ON FRONT
6164
// \add_action('parse_request', array(__NAMESPACE__.'\Request','index'),1);
6265
//REQUEST SECTION ON WP-ADMIN (aun por hacer)

src/apiController.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
namespace CH;
3+
4+
class apiController
5+
{
6+
7+
public function __construct()
8+
{
9+
10+
}
11+
public static function index($data){
12+
$posts = get_posts( array(
13+
'author' => $data['id'],
14+
) );
15+
16+
if ( empty( $posts ) ) {
17+
return null;
18+
}
19+
20+
return $posts[0]->post_title;
21+
}
22+
}
23+
//Make whit Antonella Framework

0 commit comments

Comments
 (0)