Skip to content

Instantly share code, notes, and snippets.

View ramiy's full-sized avatar

Rami Yushuvaev ramiy

View GitHub Profile
@ramiy
ramiy / elementor-widget.php
Last active February 12, 2018 10:40
Assign an Elementor Widget to a Category
public function get_categories() {
return [ 'theme-elements' ];
}
@ramiy
ramiy / element.php
Created February 12, 2018 00:59
Start Controls Section
$this->start_controls_section(
'section_title',
[
'label' => __( 'Section Title', 'text-domain' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
@ramiy
ramiy / controls.php
Last active February 12, 2018 00:28
Add new Elementor Tab
Controls_Manager::add_tab(
'new-tab',
__( 'New Tab', 'text-domain' )
);
@ramiy
ramiy / gist:a6cee932a2e52b43d7a591edfaf2a7da
Last active February 8, 2018 21:12
Add new Elementor Widget Category
function add_elementor_widget_categories() {
\Elementor\Plugin::instance()->elements_manager->add_category(
'theme-elements',
[
'title' => __( 'Theme Elements', 'text-domain' ),
'icon' => 'fa fa-plug',
],
2 // position
);
@ramiy
ramiy / file.php
Last active February 16, 2018 09:48
Preventing data leaks in WordPress Plugins
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
@ramiy
ramiy / file.php
Last active February 16, 2018 09:48
Check for required PHP version
public function admin_notice_minimum_php_version() {
if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
$message = sprintf(
/* translators: 1: Plugin Name 2: PHP 3: Required PHP version */
esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'text-domain' ),
'<strong>' . esc_html__( 'Plugin Name', 'text-domain' ) . '</strong>',
'<strong>' . esc_html__( 'PHP', 'text-domain' ) . '</strong>',
'5.4'
@ramiy
ramiy / file.php
Last active February 16, 2018 09:48
Check for required Elementor version
public function admin_notice_minimum_elementor_version() {
if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
$message = sprintf(
/* translators: 1: Plugin Name 2: Elementor 3: Required Elementor version */
esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'text-domain' ),
'<strong>' . esc_html__( 'Plugin Name', 'text-domain' ) . '</strong>',
'<strong>' . esc_html__( 'Elementor', 'text-domain' ) . '</strong>',
'2.0.0'
@ramiy
ramiy / file.php
Last active February 16, 2021 06:15
Check if Elementor is installed and activated
public function admin_notice_missing_main_plugin() {
if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
$message = sprintf(
/* translators: 1: Plugin Name 2: Elementor */
esc_html__( '"%1$s" requires "%2$s" to be installed and activated.', 'text-domain' ),
'<strong>' . esc_html__( 'Plugin Name', 'text-domain' ) . '</strong>',
'<strong>' . esc_html__( 'Elementor', 'text-domain' ) . '</strong>'
);
@ramiy
ramiy / Change
Last active August 29, 2015 14:23
<?php
// Current
public function get_values() {
foreach ( $this->tabs as $tab => $settings ) {
foreach ( $settings['fields'] as $fields ) {
foreach ( (array)$fields as $f ) {
if ( isset( $f['name'] ) )
$this->parameters[$f['name']] = $this->get_value($f);
elseif($f['type'] == 'selects' && isset($f['selects'])) {