PluginProbe
Leyka / 3.17
Leyka v3.17
3.32.3 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.6.1 2.3.7 2.3.8 2.3.9 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1 3.10 3.11 3.11.1 3.12 3.13 3.14 3.15 3.16 3.17 All 89 releases
leyka / extensions / example / leyka-class-example-extension.php

leyka-class-example-extension.php in Leyka 3.17, at extensions/example/leyka-class-example-extension.php

111 lines 6.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if( !defined('WPINC') ) die;
2 /**
3 * Leyka Extension: Example extension
4 * Version: 0.1a
5 * Author: Author name
6 * Author URI: https://some-author.org
7 * Debug only: 1
8 **/
9
10 class Leyka_Example_Extension extends Leyka_Extension {
11
12 protected static $_instance;
13
14 protected function _set_attributes() {
15
16 $this->_id = 'example'; // Must be a unique string, like "example-ext"
17 $this->_title = 'Пример расширения'; // A human-readable title, like "Extension Example"
18
19 // A human-readable short description (for backoffice extensions list page):
20 $this->_description = 'Это небольшое описание расширения, символов на 100-130. Оказалось, придумать осмысленный текст сама по себе задачка не из лёгки�
21 .';
22
23 // A human-readable full description (for backoffice extensions list page):
24 $this->_full_description = 'Это более подробное описание расширения, символов на 150-300. Например, вот такое длинное, как эта строка.';
25
26 // A human-readable description (for backoffice extension settings page):
27 $this->_settings_description = 'Это текст с описанием или комментарием работы расширения, который выводится на странице настроек расширения в административном разделе Лейки. Текст может быть довольно длинным, но мы рекомендуем помнить, что молчание - золото. А лаконичность - так вообще платина; лучше только телепатия.';
28
29 // A human-readable description of how to enable the main feature (for backoffice extension settings page):
30 $this->_connection_description = '<p><strong>В этом месте можно вывести краткое описание использования некоторой функции</strong></p>
31 <p>Например, вы можете использовать функцию «раз-два-три» так:</p>
32 <code>[some_shortcode param1="Какая-то надпись"]</code>
33 <br>Ваш текст<br>
34 <code>[/some_shortcode]</code>';
35
36 // $this->_user_docs_link = '//your-site.org/extension-manual'; // Extension user manual page URL
37 $this->_has_wizard = false;
38 $this->_has_color_options = true;
39
40 }
41
42 protected function _set_options_defaults() {
43
44 $this->_options = apply_filters('leyka_'.$this->_id.'_extension_options', array(
45 $this->_id.'_text_req' => array(
46 'type' => 'text',
47 'title' => 'Обязательное текстовое поле',
48 'comment' => 'Комментарий к полю. Может отсутствовать - при этом символ комментария к полю не выводится.',
49 'required' => true,
50 'placeholder' => 'Подсказка для заполнения поля',
51 'description' => 'Пояснение к полю выше. Может отсутствовать.',
52 ),
53 $this->_id.'_text_non_req' => array(
54 'type' => 'text',
55 'title' => 'Необязательное текстовое поле',
56 // 'comment' => 'Комментарий к полю. Может отсутствовать - при этом символ комментария к полю не выводится.',
57 'required' => false,
58 'placeholder' => 'Подсказка для заполнения поля',
59 ),
60 $this->_id.'_textarea_non_req' => array(
61 'type' => 'textarea',
62 'title' => 'Необязательный многострочный текст',
63 'comment' => 'Комментарий к полю',
64 'required' => false,
65 ),
66 $this->_id.'_test_contained_options_1' => array(
67 'type' => 'container',
68 'entries' => array(
69 $this->_id.'_some_color' => array(
70 'type' => 'colorpicker',
71 'title' => 'Цвет для вывода',
72 'description' => 'Рекомендуем красивый цвет',
73 'default' => '#123456',
74 ),
75 $this->_id.'_some_number' => array(
76 'type' => 'number',
77 'title' => 'Некоторое число процентов',
78 'required' => true,
79 'default' => 25.7,
80 'min' => 0.0,
81 'max' => 100.0,
82 'step' => 0.1,
83 ),
84 $this->_id.'_checkbox' => array(
85 'type' => 'checkbox',
86 'default' => true,
87 'title' => 'Галочка',
88 'description' => 'Отметьте, чтобы галочка оказалась проставленной',
89 'comment' => 'Комментарий к полю-галочке.',
90 // 'short_format' => true,
91 ),
92 ),
93 ),
94 ));
95
96 }
97
98 /** Will be called only if the Extension is active. */
99 protected function _initialize_active() {
100 }
101
102 /** Will be called everytime the Extension is loading into the plugin (i.e. always). */
103 protected function _initialize_always() {
104 }
105
106 }
107
108 function leyka_add_extension_test_1() { // Use named function to leave a possibility to remove/replace it on the hook
109 leyka()->add_extension(Leyka_Example_Extension::get_instance());
110 }
111 add_action('leyka_init_actions', 'leyka_add_extension_test_1');