| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 4 |
|
| 5 |
abstract class mrplan_TMrPlanPluginAbstract{ |
| 6 |
|
| 7 |
|
| 8 |
protected $path; |
| 9 |
|
| 10 |
protected $Plantilla; |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
protected $dir_plugin; |
| 15 |
|
| 16 |
|
| 17 |
protected $mensajes_error = array(); |
| 18 |
protected $mensajes_ok = array(); |
| 19 |
|
| 20 |
protected $HostServer = 'https://www.mrplan.es/'; |
| 21 |
|
| 22 |
protected function __construct(){ |
| 23 |
$this->path=plugin_dir_path( __FILE__ ) ; |
| 24 |
} |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
/** |
| 29 |
* Cargamos el Twig crgando los valores predefinidos |
| 30 |
* |
| 31 |
* @return array |
| 32 |
*/ |
| 33 |
protected function setPlantilla(){ |
| 34 |
|
| 35 |
if(!class_exists('Twig_Loader_Filesystem')){ |
| 36 |
require_once dirname(__FILE__).'/vendor/autoload.php'; |
| 37 |
} |
| 38 |
|
| 39 |
if(!class_exists('mrplan_Twig_MrPlan')){ |
| 40 |
require_once dirname(__FILE__).'/class.mrplan_Twig_MrPlan.php'; |
| 41 |
} |
| 42 |
$this->Plantilla = new mrplan_Twig_MrPlan(false, dirname(__FILE__).'/../'); |
| 43 |
$this->Plantilla->assign('dir_plugin', $this->dir_plugin); |
| 44 |
$this->Plantilla->assign('MRPLAN_PLUGIN_VERSION', MRPLAN_PLUGIN_VERSION); |
| 45 |
$this->Plantilla->assign('MRPLAN_WORDPRESS_VERSION', get_bloginfo('version')); |
| 46 |
$this->Plantilla->assign('MRPLAN_WORDPRESS_PERMANLINK', get_permalink(0)); |
| 47 |
|
| 48 |
$this->Plantilla->assign('mensajes_error', $this->mensajes_error); |
| 49 |
$this->Plantilla->assign('mensajes_ok', $this->mensajes_ok); |
| 50 |
$this->Plantilla->assign('HostServer', $this->HostServer); |
| 51 |
$this->Plantilla->assign('idiomas', $this->getIdiomas()); |
| 52 |
|
| 53 |
} |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
/** |
| 58 |
* Devolvemos el listado de idiomas de MisterPlan |
| 59 |
* |
| 60 |
* @return array |
| 61 |
*/ |
| 62 |
protected function getIdiomas(){ |
| 63 |
$idiomas = array(); |
| 64 |
|
| 65 |
$idiomas_texto = array( |
| 66 |
esc_html__('Spanish', 'misterplan'), |
| 67 |
esc_html__('English', 'misterplan'), |
| 68 |
esc_html__('Portuguese', 'misterplan'), |
| 69 |
esc_html__('French', 'misterplan'), |
| 70 |
esc_html__('Italian', 'misterplan'), |
| 71 |
esc_html__('German', 'misterplan'), |
| 72 |
esc_html__('Catalan', 'misterplan'), |
| 73 |
esc_html__('Galician', 'misterplan'), |
| 74 |
esc_html__('Basque', 'misterplan'), |
| 75 |
); |
| 76 |
|
| 77 |
for($i=0; $i<=8; $i++){ |
| 78 |
$idiomas[] = (object) [ |
| 79 |
'id_idioma' => $i, |
| 80 |
'nombre_idioma' => $idiomas_texto[$i] |
| 81 |
]; |
| 82 |
|
| 83 |
} |
| 84 |
return $idiomas; |
| 85 |
} |
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
/** |
| 90 |
* Devuelve los datos de un motor (si existe, si no devuelve null) |
| 91 |
* @param INteger identificador del motor |
| 92 |
* @return stdClass || NULL |
| 93 |
*/ |
| 94 |
protected function getMotor($id_motor){ |
| 95 |
$id_motor = (int) $id_motor; |
| 96 |
if(empty($id_motor)){ |
| 97 |
return null; |
| 98 |
} |
| 99 |
$motor = get_post($id_motor); |
| 100 |
if(is_null($motor)){ |
| 101 |
return null; |
| 102 |
} |
| 103 |
$motor->datos = json_decode($motor->post_content); |
| 104 |
$motor->id_motor = $motor->ID; |
| 105 |
return $motor; |
| 106 |
} |
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
protected function mostrar_error($texto){ |
| 112 |
return '<div id="mrplan-bootstrap" class="alert alert-danger" role="alert">'.$texto.'</div>'; |
| 113 |
} |
| 114 |
|
| 115 |
} |