Skip to content

Commit

Permalink
Version 0.0.2 preparations
Browse files Browse the repository at this point in the history
  • Loading branch information
bahiirwa committed May 29, 2020
1 parent b8accbc commit ae4f0c0
Show file tree
Hide file tree
Showing 17 changed files with 217 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages
Empty file modified .vscode/launch.json
100644 → 100755
Empty file.
1 change: 1 addition & 0 deletions .vscodeignore
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.vscode-test/**
.gitignore
vsc-extension-quickstart.md
packages
Empty file modified CHANGELOG.md
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
Binary file removed elementor-snippets-0.0.1.vsix
Binary file not shown.
Empty file modified images/elementor-logo.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified images/elementor-site-logo.webp
100644 → 100755
Empty file.
Empty file modified images/elementor-work.gif
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 9 additions & 1 deletion package.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,21 @@
"language": "php",
"path": "./snippets/controls.json"
},
{
"language": "js",
"path": "./snippets/hooks/js.json"
},
{
"language": "php",
"path": "./snippets/hooks.json"
"path": "./snippets/hooks/php.json"
},
{
"language": "php",
"path": "./snippets/categories.json"
},
{
"language": "php",
"path": "./snippets/functions.json"
}
]
}
Expand Down
Empty file modified snippets/categories.json
100644 → 100755
Empty file.
Empty file modified snippets/controls.json
100644 → 100755
Empty file.
77 changes: 77 additions & 0 deletions snippets/functions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"el_fx_elementor_load_plugin_textdomain": {
"prefix": "el_fx_elementor_load_plugin_textdomain",
"body": [
"elementor_load_plugin_textdomain()"
],
"description": [
"Returns (void). Function: Load gettext translate for Elementor text domain.",
"",
"Source: elementor.php"
]
},
"el_fx_elementor_fail_wp_version": {
"prefix": "el_fx_elementor_fail_wp_version",
"body": [
"elementor_fail_wp_version()"
],
"description": [
"Returns (void). Function: Elementor admin notice for minimum WordPress version.",
"",
"Description: Warning when the site doesn’t have the minimum required WordPress version.",
"",
"Source: elementor.php"
]
},
"el_fx_elementor_fail_php_version": {
"prefix": "el_fx_elementor_fail_php_version",
"body": [
"elementor_fail_php_version()"
],
"description": [
"Returns (void). Function: Elementor admin notice for minimum PHP version.",
"",
"Description: Warning when the site doesn’t have the minimum required PHP version.",
"",
"Source: elementor.php"
]
},
"el_fx_bfi_wp_image_editor": {
"prefix": "el_fx_bfi_wp_image_editor",
"body": [
"bfi_wp_image_editor( $editorArray )"
],
"description": [
"Source: includes/libraries/bfi-thumb/bfi-thumb.php",
"",
"Uses: includes/libraries/bfi-thumb/bfi-thumb.php: BFI_Class_Factory::getNewestVersion()"
]
},
"el_fx_bfi_image_downsize": {
"prefix": "el_fx_bfi_image_downsize",
"body": [
"bfi_image_downsize( $out, $id, $size )"
],
"description": [
"Source: includes/libraries/bfi-thumb/bfi-thumb.php: bfi_thumb()",
"Uses: includes/libraries/bfi-thumb/bfi-thumb.php: BFI_Class_Factory::getNewestVersion()",
"",
"Used By: includes/libraries/bfi-thumb/bfi-thumb.php: bfi_image_downsize()",
""
]
},
"el_fx_bfi_thumb": {
"prefix": "el_fx_bfi_thumb",
"body": [
"bfi_thumb( $url, $params = array(), $single = true )"
],
"description": "Source: includes/libraries/bfi-thumb/bfi-thumb.php"
},
"el_fx_bfi_image_resize_dimensions": {
"prefix": "el_fx_bfi_image_resize_dimensions",
"body": [
"bfi_image_resize_dimensions( $payload, $orig_w, $orig_h, $dest_w, $dest_h, $crop = false )"
],
"description": "Source: includes/libraries/bfi-thumb/bfi-thumb.php"
}
}
67 changes: 67 additions & 0 deletions snippets/hooks/js.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"el_hook_scroll_top_distance": {
"prefix": "el_hook_scroll_top_distance",
"body": [
"jQuery( function( $ ) {",
"// Add space for Elementor Menu Anchor link",
"if ( window.elementorFrontend ) {",
"elementorFrontend.hooks.addFilter( 'frontend/handlers/menu_anchor/scroll_top_distance', function( scrollTop ) {",
"return scrollTop - ${1:30};",
"} );",
"}",
"} );"
],
"description": [
"Argument: scrollTop, Type: integer",
"",
"Frontend Filter: Applied to the Menu Anchor widget, set a custom top distance. The default scrollTop. It takes only the WordPress Admin Bar in account."
]
},
"el_hook_init": {
"prefix": "el_hook_init",
"body": [
"elementorFrontend.hooks.addAction( 'init', function() {",
"// Do something that is based on the elementorFrontend object.",
"} );"
],
"description": [
"Argument: none",
"",
"Frontend Actions: Elementor frontend is loaded."
]
},
"el_hook_global": {
"prefix": "el_hook_global",
"body": [
"elementorFrontend.hooks.addAction( 'frontend/element_ready/global', function( $scope ) {",
"if ( $scope.data( 'shake' ) ){",
"$scope.shake();",
"}",
"} );"
],
"description": [
"Argument: $scope - The current element wrapped with jQuery",
"",
"Argument: $ -The jQuery instance",
"",
"frontend/element_ready/global Runs on every element (includes sections and columns) when it’s ready"
]
},
"el_hook_widget": {
"prefix": "el_hook_widget",
"body": [
"elementorFrontend.hooks.addAction( 'frontend/element_ready/widget', function( $scope ) {",
"if ( $scope.data( 'shake' ) ){",
"$scope.shake();",
"}",
"} );"
],
"description": [
"Argument: $scope - The current element wrapped with jQuery",
"",
"Argument: $ -The jQuery instance",
"",
"frontend/element_ready/widget Runs on every widget when it’s ready."
]
}
}
File renamed without changes.
62 changes: 62 additions & 0 deletions snippets/main-class.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,39 @@
],
"description": "The constructor should load localization functionality and initiate the plugin. The init process should check for basic requirements and then then run the plugin logic. Note that If one of the basic plugin requirements fails the plugin logic won’t run."
},
"el_main_php_version_elementor": {
"prefix": "el_main_php_version_elementor",
"body": [
"const MINIMUM_PHP_VERSION = '${1:7.0}';",
"",
"public function init() {",
"",
"// Check for required PHP version",
"if ( version_compare( PHP_VERSION, self::MINIMUM_PHP_VERSION, '<' ) ) {",
"add_action( 'admin_notices', [ $this, 'admin_notice_minimum_php_version' ] );",
"return;",
"}",
"",
"}",
"",
"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.', 'elementor-test-extension' ),",
"'<strong>' . esc_html__( '${2:Elementor Test Extension}', '${6:elementor-test-extension}' ) . '</strong>',",
"'<strong>' . esc_html__( '${3:Elementor}', '${6:elementor-test-extension}' ) . '</strong>',",
"self::MINIMUM_PHP_VERSION",
");",
"",
"printf( '<div class=\"notice notice-warning is-dismissible\"><p>%1$s</p></div>', $message );",
"",
"}"
],
"description": "Elementor extensions should also check for minimum required PHP version. Keep in mind that Elementor has it’s own minimum required PHP version, the extension should use a greater PHP version than the one Elementor is using. You need to check the minimum required PHP version before loading the main functionality."
},
"el_main_if_elementor": {
"prefix": "el_main_if_elementor",
"body": [
Expand Down Expand Up @@ -166,6 +199,35 @@
"}"
],
"description": "Registering Custom Scripts. Other widgets need custom JS to run, in those cases we need to register scripts with the elementor/frontend/after_register_scripts hook"
},
"el_main_widgets_register": {
"prefix": "el_main_widgets_register",
"body": [
"public function init() {",
"",
"// Include plugin files",
"$this->includes();",
"",
"// Register widgets",
"add_action( 'elementor/widgets/widgets_registered', [ $this, '${1:widget_scripts}' ] );",
"",
"}",
"",
"public function includes() {",
"",
"require_once( __DIR__ . '/widgets/${2:test-widget-1}.php' );",
"require_once( __DIR__ . '/widgets/${3:test-widget-2}.php' );",
"",
"}",
"",
"public function register_widgets() {",
"",
"\\Elementor\\Plugin::instance()->widgets_manager->register_widget_type( new \\${4:Elementor_Test_Widget1}() );",
"\\Elementor\\Plugin::instance()->widgets_manager->register_widget_type( new \\${5:Elementor_Test_Widget2}() );",
"",
"}"
],
"description": "Registering New Widgets. To add a new widget to Elementor we need to register the widget class using the widget manager. It’s a pretty simple process, it is done using the elementor/widgets/widgets_registered action."
}

}
Empty file modified vsc-extension-quickstart.md
100644 → 100755
Empty file.

0 comments on commit ae4f0c0

Please sign in to comment.