├── index.php ├── languages ├── elementor-custom-shapes-fr_FR.mo ├── elementor-custom-shapes.pot └── elementor-custom-shapes-fr_FR.po ├── README.md ├── includes ├── admin.php └── register-cpt.php ├── plugin.php └── elementor-custom-shapes.php /index.php: -------------------------------------------------------------------------------- 1 | \n" 10 | "Language-Team: Your Team \n" 11 | "Report-Msgid-Bugs-To: Translator Name \n" 12 | "MIME-Version: 1.0\n" 13 | "Content-Type: text/plain; charset=UTF-8\n" 14 | "Content-Transfer-Encoding: 8bit\n" 15 | "Plural-Forms: nplurals=2; plural=n != 1;\n" 16 | "X-Textdomain-Support: yes" 17 | "X-Generator: Poedit 1.6.4\n" 18 | "X-Poedit-SourceCharset: UTF-8\n" 19 | "X-Poedit-KeywordsList: __;_e;esc_html_e;esc_html_x:1,2c;esc_html__;esc_attr_e;esc_attr_x:1,2c;esc_attr__;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;_x:1,2c;_n:1,2;_n_noop:1,2;__ngettext:1,2;__ngettext_noop:1,2;_c,_nc:4c,1,2;\n" 20 | "X-Poedit-Basepath: ../\n" 21 | "X-Poedit-SearchPath-0: .\n" 22 | "X-Poedit-Language: English\n" 23 | "X-Poedit-Country: UNITED STATES\n" 24 | "X-Poedit-Bookmarks: \n" 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Elementor Custom Shapes 2 | WordPress plugin that allows you to add custom shapes dividers to the Elementor page builder. 3 | 4 | ## Prerequistes : 5 | - Elementor version >= 2.1.0 activated 6 | 7 | ## Installation instructions 8 | - Upload and activate Elementor Custom Shapes plugin 9 | - Go to Elementor > Custom Shapes menu 10 | - Publish a new Custom Shape : a title and an SVG file as a post thumbnail 11 | - Your new shape will be available in Elementor Sections > Style > Shape divider select 12 | 13 | ## :warning: Important notes 14 | - You need to allow SVG upload on your WordPress website, for example with the plugin [Safe SVG](https://fr.wordpress.org/plugins/safe-svg/) 15 | - Your SVG files need to be cleaned up (no IDs, no styles), you can use [SVGOMG](https://jakearchibald.github.io/svgomg/) for that 16 | - SVG paths must have CSS class "elementor-shape-fill" 17 | - "Invert" setting is not supported for custom shapes created with this plugin. If you need a shape inverted, create a second custom shapes with the same SVG but inverted. Please read : https://github.com/MarieComet/elementor-custom-shapes/issues/1#issuecomment-1024631273 18 | 19 | ## SVG example 20 | Below an SVG code example: 21 | ``` 22 | 23 | 24 | 25 | ``` 26 | -------------------------------------------------------------------------------- /includes/admin.php: -------------------------------------------------------------------------------- 1 | post_type ) { 71 | return; 72 | } 73 | echo '

' . sprintf( '%s: %s', __( 'Custom Shape', 'elementor-custom-shapes' ), esc_url( 'https://github.com/MarieComet/elementor-custom-shapes#installation-instructions' ), __( 'Read instructions', 'elementor-custom-shapes' ) ) . '

'; 74 | } -------------------------------------------------------------------------------- /plugin.php: -------------------------------------------------------------------------------- 1 | 'ele_custom_shapes', 46 | 'posts_per_page' => 50, //safe 47 | 'post_status' => 'publish', 48 | ] ); 49 | $additional_shapes = []; 50 | if ( $shapes_cpt->have_posts() ) { 51 | while ( $shapes_cpt->have_posts() ) { 52 | $shapes_cpt->the_post(); 53 | global $post; 54 | $shape_thumbnail_id = get_post_thumbnail_id( $post->ID ); 55 | if ( !empty( $shape_thumbnail_id ) ) { 56 | $shape_thumbnail_path = get_attached_file( $shape_thumbnail_id ); 57 | $shape_thumbnail_url = wp_get_attachment_url( $shape_thumbnail_id ); 58 | if ( $shape_thumbnail_path && $shape_thumbnail_url && $post->post_name && $post->post_title ) { 59 | $additional_shapes[ $post->post_name ] = [ 60 | 'title' => $post->post_title, 61 | 'path' => $shape_thumbnail_path, // used in front 62 | 'url' => $shape_thumbnail_url, // used in editor 63 | 'has_flip' => true, 64 | 'has_negative' => false 65 | ]; 66 | 67 | } 68 | } 69 | } 70 | wp_reset_postdata(); 71 | } 72 | return $additional_shapes; 73 | } 74 | 75 | /** 76 | * Register custom Shapes 77 | * 78 | * @since 0.0.1 79 | * @access public 80 | */ 81 | public function register_custom_shapes( $additional_shapes ) { 82 | $additional_shapes = $this->get_custom_shapes(); 83 | return $additional_shapes; 84 | } 85 | 86 | /** 87 | * Plugin class constructor 88 | * 89 | * Register plugin action hooks and filters 90 | * 91 | * @since 0.0.1 92 | * @access public 93 | */ 94 | public function __construct() { 95 | require_once( __DIR__ . '/includes/register-cpt.php' ); 96 | if ( is_admin() ) { 97 | require_once( __DIR__ . '/includes/admin.php' ); 98 | } 99 | add_action( 'elementor/shapes/additional_shapes', [ $this, 'register_custom_shapes' ] ); 100 | } 101 | } 102 | // Instantiate Plugin Class 103 | Plugin::instance(); -------------------------------------------------------------------------------- /includes/register-cpt.php: -------------------------------------------------------------------------------- 1 | _x( 'Custom shapes', 'Post Type General Name', 'elementor-custom-shapes' ), 13 | 'singular_name' => _x( 'Custom shape', 'Post Type Singular Name', 'elementor-custom-shapes' ), 14 | 'menu_name' => __( 'Custom shapes', 'elementor-custom-shapes' ), 15 | 'name_admin_bar' => __( 'Custom shape', 'elementor-custom-shapes' ), 16 | 'archives' => __( 'Item Archives', 'elementor-custom-shapes' ), 17 | 'attributes' => __( 'Item Attributes', 'elementor-custom-shapes' ), 18 | 'parent_item_colon' => __( 'Parent Item:', 'elementor-custom-shapes' ), 19 | 'all_items' => __( 'All Items', 'elementor-custom-shapes' ), 20 | 'add_new_item' => __( 'Add New Item', 'elementor-custom-shapes' ), 21 | 'add_new' => __( 'Add New', 'elementor-custom-shapes' ), 22 | 'new_item' => __( 'New Item', 'elementor-custom-shapes' ), 23 | 'edit_item' => __( 'Edit Item', 'elementor-custom-shapes' ), 24 | 'update_item' => __( 'Update Item', 'elementor-custom-shapes' ), 25 | 'view_item' => __( 'View Item', 'elementor-custom-shapes' ), 26 | 'view_items' => __( 'View Items', 'elementor-custom-shapes' ), 27 | 'search_items' => __( 'Search Item', 'elementor-custom-shapes' ), 28 | 'not_found' => __( 'Not found', 'elementor-custom-shapes' ), 29 | 'not_found_in_trash' => __( 'Not found in Trash', 'elementor-custom-shapes' ), 30 | 'featured_image' => __( 'Featured Image', 'elementor-custom-shapes' ), 31 | 'set_featured_image' => __( 'Set featured image', 'elementor-custom-shapes' ), 32 | 'remove_featured_image' => __( 'Remove featured image', 'elementor-custom-shapes' ), 33 | 'use_featured_image' => __( 'Use as featured image', 'elementor-custom-shapes' ), 34 | 'insert_into_item' => __( 'Insert into item', 'elementor-custom-shapes' ), 35 | 'uploaded_to_this_item' => __( 'Uploaded to this item', 'elementor-custom-shapes' ), 36 | 'items_list' => __( 'Items list', 'elementor-custom-shapes' ), 37 | 'items_list_navigation' => __( 'Items list navigation', 'elementor-custom-shapes' ), 38 | 'filter_items_list' => __( 'Filter items list', 'elementor-custom-shapes' ), 39 | ); 40 | $args = array( 41 | 'label' => __( 'Custom shape', 'elementor-custom-shapes' ), 42 | 'description' => __( 'Custom shapes', 'elementor-custom-shapes' ), 43 | 'labels' => $labels, 44 | 'supports' => array( 'title', 'thumbnail' ), 45 | 'hierarchical' => false, 46 | 'public' => false, 47 | 'show_ui' => true, 48 | 'show_in_menu' => false, 49 | 'show_in_admin_bar' => false, 50 | 'show_in_nav_menus' => false, 51 | 'can_export' => true, 52 | 'has_archive' => false, 53 | 'exclude_from_search' => true, 54 | 'publicly_queryable' => false, 55 | 'capability_type' => 'post', 56 | ); 57 | register_post_type( 'ele_custom_shapes', $args ); 58 | 59 | } 60 | add_action( 'init', 'ecs_register_cpt', 0 ); -------------------------------------------------------------------------------- /languages/elementor-custom-shapes-fr_FR.po: -------------------------------------------------------------------------------- 1 | # Blank WordPress Pot 2 | # Copyright 2014 ... 3 | # This file is distributed under the GNU General Public License v3 or later. 4 | msgid "" 5 | msgstr "" 6 | "Project-Id-Version: Blank WordPress Pot v1.0.0\n" 7 | "Report-Msgid-Bugs-To: Translator Name \n" 8 | "POT-Creation-Date: 2019-10-20 08:34+0200\n" 9 | "PO-Revision-Date: \n" 10 | "Last-Translator: \n" 11 | "Language-Team: Your Team \n" 12 | "Language: fr_FR\n" 13 | "MIME-Version: 1.0\n" 14 | "Content-Type: text/plain; charset=UTF-8\n" 15 | "Content-Transfer-Encoding: 8bit\n" 16 | "Plural-Forms: nplurals=2; plural=(n > 1);\n" 17 | "X-Textdomain-Support: yesX-Generator: Poedit 1.6.4\n" 18 | "X-Poedit-SourceCharset: UTF-8\n" 19 | "X-Poedit-KeywordsList: __;_e;esc_html_e;esc_html_x:1,2c;esc_html__;" 20 | "esc_attr_e;esc_attr_x:1,2c;esc_attr__;_ex:1,2c;_nx:4c,1,2;" 21 | "_nx_noop:4c,1,2;_x:1,2c;_n:1,2;_n_noop:1,2;__ngettext:1,2;" 22 | "__ngettext_noop:1,2;_c,_nc:4c,1,2\n" 23 | "X-Poedit-Basepath: ..\n" 24 | "X-Generator: Poedit 2.0.6\n" 25 | "X-Poedit-SearchPath-0: .\n" 26 | 27 | #: elementor-custom-shapes.php:103 28 | #, php-format 29 | msgid "\"%1$s\" requires \"%2$s\" to be installed and activated." 30 | msgstr "\"%1$s\" requiert \"%2$s\" pour être installée et activée." 31 | 32 | #: elementor-custom-shapes.php:104 elementor-custom-shapes.php:124 33 | #: elementor-custom-shapes.php:145 34 | msgid "Elementor Custom Shapes" 35 | msgstr "Elementor Custom Shapes" 36 | 37 | #: elementor-custom-shapes.php:105 elementor-custom-shapes.php:125 38 | msgid "Elementor" 39 | msgstr "Elementor" 40 | 41 | #: elementor-custom-shapes.php:123 elementor-custom-shapes.php:144 42 | #, php-format 43 | msgid "\"%1$s\" requires \"%2$s\" version %3$s or greater." 44 | msgstr "\"%1$s\" requiert \"%2$s\" en version %3$s ou supérieure." 45 | 46 | #: elementor-custom-shapes.php:146 47 | msgid "PHP" 48 | msgstr "PHP" 49 | 50 | #: includes/admin.php:21 51 | msgctxt "Elementor Custom Shapes" 52 | msgid "Custom Shapes" 53 | msgstr "Formes personnalisées" 54 | 55 | #: includes/admin.php:73 56 | msgid "Custom Shape" 57 | msgstr "Forme personnalisée" 58 | 59 | #: includes/admin.php:73 60 | msgid "Read instructions" 61 | msgstr "Lire les instructions" 62 | 63 | #: includes/register-cpt.php:12 64 | msgctxt "Post Type General Name" 65 | msgid "Custom shapes" 66 | msgstr "Formes personnalisées" 67 | 68 | #: includes/register-cpt.php:13 69 | msgctxt "Post Type Singular Name" 70 | msgid "Custom shape" 71 | msgstr "Forme personnalisée" 72 | 73 | #: includes/register-cpt.php:14 includes/register-cpt.php:42 74 | msgid "Custom shapes" 75 | msgstr "Formes personnalisées" 76 | 77 | #: includes/register-cpt.php:15 includes/register-cpt.php:41 78 | msgid "Custom shape" 79 | msgstr "Forme personnalisée" 80 | 81 | #: includes/register-cpt.php:16 82 | msgid "Item Archives" 83 | msgstr "Archives" 84 | 85 | #: includes/register-cpt.php:17 86 | msgid "Item Attributes" 87 | msgstr "Attributs" 88 | 89 | #: includes/register-cpt.php:18 90 | msgid "Parent Item:" 91 | msgstr "Parent:" 92 | 93 | #: includes/register-cpt.php:19 94 | msgid "All Items" 95 | msgstr "Tous les éléments" 96 | 97 | #: includes/register-cpt.php:20 98 | msgid "Add New Item" 99 | msgstr "Ajouter un nouvel élément" 100 | 101 | #: includes/register-cpt.php:21 102 | msgid "Add New" 103 | msgstr "Ajouter" 104 | 105 | #: includes/register-cpt.php:22 106 | msgid "New Item" 107 | msgstr "Nouvel élément" 108 | 109 | #: includes/register-cpt.php:23 110 | msgid "Edit Item" 111 | msgstr "Modifier l'élément" 112 | 113 | #: includes/register-cpt.php:24 114 | msgid "Update Item" 115 | msgstr "Mettre à jour l'élément" 116 | 117 | #: includes/register-cpt.php:25 118 | msgid "View Item" 119 | msgstr "Voir l'élément" 120 | 121 | #: includes/register-cpt.php:26 122 | msgid "View Items" 123 | msgstr "Voir les éléments" 124 | 125 | #: includes/register-cpt.php:27 126 | msgid "Search Item" 127 | msgstr "Rechercher" 128 | 129 | #: includes/register-cpt.php:28 130 | msgid "Not found" 131 | msgstr "Non trouvé" 132 | 133 | #: includes/register-cpt.php:29 134 | msgid "Not found in Trash" 135 | msgstr "Non trouvé dans la corbeille" 136 | 137 | #: includes/register-cpt.php:30 138 | msgid "Featured Image" 139 | msgstr "Image mise en avant" 140 | 141 | #: includes/register-cpt.php:31 142 | msgid "Set featured image" 143 | msgstr "Définir l'image mise en avant" 144 | 145 | #: includes/register-cpt.php:32 146 | msgid "Remove featured image" 147 | msgstr "Retirer l'image mise en avant" 148 | 149 | #: includes/register-cpt.php:33 150 | msgid "Use as featured image" 151 | msgstr "Utiliser comme image mise en avant" 152 | 153 | #: includes/register-cpt.php:34 154 | msgid "Insert into item" 155 | msgstr "Insérer dans l'élément" 156 | 157 | #: includes/register-cpt.php:35 158 | msgid "Uploaded to this item" 159 | msgstr "Téléversé sur cet élément" 160 | 161 | #: includes/register-cpt.php:36 162 | msgid "Items list" 163 | msgstr "Liste des éléments" 164 | 165 | #: includes/register-cpt.php:37 166 | msgid "Items list navigation" 167 | msgstr "Navigation de la liste des éléments" 168 | 169 | #: includes/register-cpt.php:38 170 | msgid "Filter items list" 171 | msgstr "Filtrer la liste des éléments" 172 | -------------------------------------------------------------------------------- /elementor-custom-shapes.php: -------------------------------------------------------------------------------- 1 | =' ) ) { 78 | add_action( 'admin_notices', array( $this, 'admin_notice_minimum_elementor_version' ) ); 79 | return; 80 | } 81 | // Check for required PHP version 82 | if ( version_compare( PHP_VERSION, self::MINIMUM_PHP_VERSION, '<' ) ) { 83 | add_action( 'admin_notices', array( $this, 'admin_notice_minimum_php_version' ) ); 84 | return; 85 | } 86 | // Once we get here, We have passed all validation checks so we can safely include our plugin 87 | require_once( 'plugin.php' ); 88 | } 89 | /** 90 | * Admin notice 91 | * 92 | * Warning when the site doesn't have Elementor installed or activated. 93 | * 94 | * @since 1.0.0 95 | * @access public 96 | */ 97 | public function admin_notice_missing_main_plugin() { 98 | if ( isset( $_GET['activate'] ) ) { 99 | unset( $_GET['activate'] ); 100 | } 101 | $message = sprintf( 102 | /* translators: 1: Plugin name 2: Elementor */ 103 | esc_html__( '"%1$s" requires "%2$s" to be installed and activated.', 'elementor-custom-shapes' ), 104 | '' . esc_html__( 'Elementor Custom Shapes', 'elementor-custom-shapes' ) . '', 105 | '' . esc_html__( 'Elementor', 'elementor-custom-shapes' ) . '' 106 | ); 107 | printf( '

%1$s

', $message ); 108 | } 109 | /** 110 | * Admin notice 111 | * 112 | * Warning when the site doesn't have a minimum required Elementor version. 113 | * 114 | * @since 1.0.0 115 | * @access public 116 | */ 117 | public function admin_notice_minimum_elementor_version() { 118 | if ( isset( $_GET['activate'] ) ) { 119 | unset( $_GET['activate'] ); 120 | } 121 | $message = sprintf( 122 | /* translators: 1: Plugin name 2: Elementor 3: Required Elementor version */ 123 | esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'elementor-custom-shapes' ), 124 | '' . esc_html__( 'Elementor Custom Shapes', 'elementor-custom-shapes' ) . '', 125 | '' . esc_html__( 'Elementor', 'elementor-custom-shapes' ) . '', 126 | self::MINIMUM_ELEMENTOR_VERSION 127 | ); 128 | printf( '

%1$s

', $message ); 129 | } 130 | /** 131 | * Admin notice 132 | * 133 | * Warning when the site doesn't have a minimum required PHP version. 134 | * 135 | * @since 1.0.0 136 | * @access public 137 | */ 138 | public function admin_notice_minimum_php_version() { 139 | if ( isset( $_GET['activate'] ) ) { 140 | unset( $_GET['activate'] ); 141 | } 142 | $message = sprintf( 143 | /* translators: 1: Plugin name 2: PHP 3: Required PHP version */ 144 | esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'elementor-custom-shapes' ), 145 | '' . esc_html__( 'Elementor Custom Shapes', 'elementor-custom-shapes' ) . '', 146 | '' . esc_html__( 'PHP', 'elementor-custom-shapes' ) . '', 147 | self::MINIMUM_PHP_VERSION 148 | ); 149 | printf( '

%1$s

', $message ); 150 | } 151 | } 152 | // Instantiate Elementor_Custom_Shapes. 153 | new Elementor_Custom_Shapes(); --------------------------------------------------------------------------------