PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.71
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.71
1.2.74 1.2.73 1.2.72 1.2.71 1.2.70 1.2.69 1.2.68 1.2.67 1.2.66 1.2.65 1.2.64 1.2.63 trunk 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 All 174 releases
userswp / vendor / ayecode / wp-super-duper / hello-world.php

hello-world.php in UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP 1.2.71, at vendor/ayecode/wp-super-duper/hello-world.php

148 lines 4.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class SD_Hello_World extends WP_Super_Duper {
4
5
6 public $arguments;
7
8 /**
9 * Sets up the widgets name etc
10 */
11 public function __construct() {
12
13 $options = array(
14 'textdomain' => 'super-duper',
15 // textdomain of the plugin/theme (used to prefix the Gutenberg block)
16 'block-icon' => 'fas fa-globe-americas',
17 // Dash icon name for the block: https://developer.wordpress.org/resource/dashicons/#arrow-right
18 // OR font-awesome 5 class name: fas fa-globe-americas
19 'block-category' => 'widgets',
20 // the category for the block, 'common', 'formatting', 'layout', 'widgets', 'embed'.
21 'block-keywords' => "['hello','world']",
22 // used in the block search, MAX 3
23 'block-output' => array( // the block visual output elements as an array
24 // array(
25 // 'element' => 'p',
26 // 'title' => __( 'Placeholder', 'ayecode-connect' ),
27 // 'class' => '[%className%]',
28 // 'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%]
29 // )
30 array(
31 'element' => 'BlocksProps',
32 'inner_element' => 'p',
33 'blockProps' => array(
34 'className' => '[%WrapClass%]',
35 // 'content' => 'Hello: [%after_text%]'
36 // 'if_dangerouslySetInnerHTML' => '{__html: blockstrap_build_shape(props.attributes) }',
37 ),
38 'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%]
39
40
41 ),
42 ),
43 'block-wrap' => '', // You can specify the type of element to wrap the block `div` or `span` etc.. Or blank for no wrap at all.
44 'class_name' => __CLASS__,
45 // The calling class name
46 'base_id' => 'hello_world',
47 // this is used as the widget id and the shortcode id.
48 'name' => __( 'Hello World', 'ayecode-connect' ),
49 // the name of the widget/block
50 'widget_ops' => array(
51 'classname' => 'hello-world-class',
52 // widget class
53 'description' => esc_html__( 'This is an example that will take a text parameter and output it after `Hello:`.', 'ayecode-connect' ),
54 // widget description
55 ),
56 'no_wrap' => true, // This will prevent the widget being wrapped in the containing widget class div.
57 'arguments' => array( // these are the arguments that will be used in the widget, shortcode and block settings.
58 'after_text' => array( // this is the input name=''
59 'title' => __( 'Text after hello:', 'ayecode-connect' ),
60 // input title
61 'desc' => __( 'This is the text that will appear after `Hello:`.', 'ayecode-connect' ),
62 // input description
63 'type' => 'text',
64 // the type of input, test, select, checkbox etc.
65 'placeholder' => 'World',
66 // the input placeholder text.
67 'desc_tip' => true,
68 // if the input should show the widget description text as a tooltip.
69 'default' => 'World',
70 // the input default value.
71 'advanced' => false
72 // not yet implemented
73 ),
74 )
75 );
76
77 parent::__construct( $options );
78 }
79
80
81 /**
82 * This is the output function for the widget, shortcode and block (front end).
83 *
84 * @param array $args The arguments values.
85 * @param array $widget_args The widget arguments when used.
86 * @param string $content The shortcode content argument
87 *
88 * @return string
89 */
90 public function output( $args = array(), $widget_args = array(), $content = '' ) {
91
92 /**
93 * @var string $after_text
94 * @var string $another_input This is added by filter below.
95 */
96 extract( $args, EXTR_SKIP );
97
98 /*
99 * This value is added by filter so might not exist if filter is removed so we check.
100 */
101 if ( ! isset( $another_input ) ) {
102 $another_input = '';
103 }
104
105 return "Helllo: " . $after_text . "" . $another_input;
106
107 }
108
109 }
110
111 // register it.
112 add_action( 'widgets_init', function () {
113 register_widget( 'SD_Hello_World' );
114 } );
115
116
117 /**
118 * Extend the options via filter hook, this can be done via plugin/theme.
119 *
120 * @param $options
121 *
122 * @return mixed
123 */
124 function _my_extra_arguments( $options ) {
125
126 /*
127 * Add a new input option.
128 */
129 $options['arguments']['another_input'] = array(
130 'name' => 'another_input', // this is the input name=''
131 'title' => __( 'Another input:', 'ayecode-connect' ), // input title
132 'desc' => __( 'This is an input added via filter.', 'ayecode-connect' ), // input description
133 'type' => 'text', // the type of input, test, select, checkbox etc.
134 'placeholder' => 'Placeholder text', // the input placeholder text.
135 'desc_tip' => true, // if the input should show the widget description text as a tooltip.
136 'default' => '', // the input default value.
137 'advanced' => false // not yet implemented
138 );
139
140 /*
141 * Output the new option in the block output also.
142 */
143 $options['block-output']['element::p']['content'] = $options['block-output']['element::p']['content'] . " [%another_input%]";;
144
145 return $options;
146 }
147
148 //add_filter( 'wp_super_duper_options_hello_world', '_my_extra_arguments' );