Coder Social home page Coder Social logo

rtcamp / wp-menu-custom-fields Goto Github PK

View Code? Open in Web Editor NEW
16.0 32.0 5.0 42.69 MB

An example of custom fields for menu in WordPress 5.4+

Home Page: https://wordpress.org/plugins/wp-menu-custom-fields/

JavaScript 37.50% PHP 22.17% SCSS 2.59% TypeScript 37.74%
wordpress wordpress-plugin navigation-menu menu

wp-menu-custom-fields's Introduction

WP Menu Custom Fields - v1.1

Project Status: Active โ€“ The project has reached a stable, usable state and is being actively developed.

This plugin adds custom fields on menu item's edit screen of wp-admin.

Author: rtCamp

Contributors: rtcamp, sid177, kiranpotphode, devikvekariya, vaishuagola27, deepaklalwani, alvitazwar052, pradeep1308, shreyasikhar26, gagan0123

Tags: Navigation Menu, Navigation Menu Custom Fields

Requires at least: 5.4

Tested up to: 6.0.3

Requires PHP version: 7.0

Stable tag: 1.1

License: GPLv2 or later (of course!)

License URI: http://www.gnu.org/licenses/gpl-2.0.html

Description

This plugin adds custom fields on Appearance -> Menus page of wp-admin (see screenshots) and supports only 1-level menu configuration. It uses wp_nav_menu_item_custom_fields hook added in WordPress 5.4 release to add custom fields. Below is the list of custom fields added by this plugin.

  • Custom text
  • Image selection with link and caption
  • Shortcode with caption
  • Custom HTML with tinyMCE editor

Notes:

  • This plugin works with default themes. In order to use it with custom themes, please add the necessary styling in your theme/child theme to override the plugin's CSS.
  • The custom fields from this plugin should be used in the submenu for well-structured and responsive UI.
  • Currently, this plugin is not supported with FSE themes.

Installation

  1. Extract the zip file.
  2. Upload it to the /wp-content/plugins/ directory in your WordPress installation.
  3. Activate the WP Menu Custom Fields from your Plugins page.

Usage

  1. After installing and activating this plugin, goto Appearance -> Menus of your WordPress admin. Create a menu if you haven't already and add menu items according to your need.
  2. When you expand any menu item, you'll see the custom fields added here (see screenshots). You can see Custom Field and Select Feature options.
  3. Along with Custom Text field, you can choose to use either Image, Shortcode or Custom HTML feature for a particular menu item.
  4. You can click on the option you want to use and the input fields of that option will be visible.

Using Custom Text field

  • You can enter any text here and it'll be displayed with this menu item.
  • This field can be used by all menu items along with any other feature.

Using Image

  • By clicking on Select Image button, WordPress' media gallery window will be opened up. You can choose 1 image from already uploaded images or you can upload a new one and select that.
  • The selected image will be shown below Select Image button after you select and close the media gallery window.
  • To remove already selected image, click on Select Image button and deselect the already selected image. You can change the selected image by selecting any other image.
  • You can enter a URL in Image Link text field. On front-end, clicking on the image will lead to this URL.
  • You can enter a caption text in Image Caption field and it'll be displayed below the image on the front-end.

Using Shortcode

  • You can add a shortcode in Shortcode field. We've added some stylings to handle WordPress' default [video] and [audio] shortcode.
  • You can enter a caption text in Shortcode Caption field and it'll be displayed below the shortcode on the front-end.

Using Custom HTML

  • TinyMCE editor is used to add custom HTML here.
  • From the Visual tab, you can enter text and format it using tools given in toolbar.
  • You can switch to Text tab to see/change HTML code of the text you entered.

Screenshots

Custom fields added under Appearance -> Menus:

Custom fields added under Appearance -> Menus

Menu on frontend of your website:

Menu on frontend of your website

Hooks

wp_menu_custom_fields_image_html Filter

  • Allows to change HTML generated for image feature.
  • There are 3 parameters. $html (Generated HTML), $data (Custom fields data), $item_id (Menu item ID).
  • Sample $data
[selected-feature] => image
[image] => Array
    (
        [media-id] => 11
        [media-type] => image
        [media-link] => https://google.com/
        [media-caption] => This is image caption
        [media-url] => http://example.com/wp-content/uploads/2020/03/92d43b978cbcdc7b33e3596d131d5256.jpg
    )

wp_menu_custom_fields_shortcode_html Filter

  • Allows to change HTML generated for shortcode feature.
  • Parameters are same as wp_menu_custom_fields_image_html.
  • Sample $data
[selected-feature] => shortcode
[shortcode] => Array
    (
        [shortcode] => [video src="https://file-examples.com/wp-content/uploads/2017/04/file_example_MP4_480_1_5MG.mp4"]
        [shortcode-caption] => This is a shortcode caption
    )

wp_menu_custom_fields_custom_markup_html Filter

  • Allows to change HTML generated for custom HTML feature.
  • Parameters are same as wp_menu_custom_fields_image_html.
  • Sample $data
[selected-feature] => html
[html] => Array
    (
        [custom-html] => <em><strong>This is custom HTML</strong></em>
    )

wp_menu_custom_fields_custom_text_html Filter

  • Allows to change HTML generated for custom text field.
  • Parameters are same as wp_menu_custom_fields_image_html.
  • Sample $data
[custom-text] => This is a custom text

wp_menu_custom_fields_fields_html Filter

  • Allows to change the final custom field's HTML generated for a particular menu item.
  • Parameters are same as wp_menu_custom_fields_image_html.
  • Sample $data
Array
(
    [custom-text] => This is a custom text
    [selected-feature] => image
    [image] => Array
        (
            [media-id] => 11
            [media-type] => image
            [media-link] => https://google.com
            [media-caption] => This is image caption
            [media-url] => http://example.com/wp-content/uploads/2020/03/92d43b978cbcdc7b33e3596d131d5256.jpg
        )

)

Styling mega menu

A theme developer can add stylings for the custom fields added by this plugin by referring to the below sample HTML code.

  • Image & Custom text
    • Sample HTML code
    <div class="rt-wp-menu-custom-fields-wrapper" style="padding-top: 10px; padding-right: 20px; /* Dynamic stylings added via JavaScript. */">
        <div class="rt-wp-menu-custom-fields-image-wrapper">
            <a href="{ Image Link }">
                <img class="rt-wp-menu-custom-fields-image" src="{ Selected Image }">
            </a>
            <span class="rt-wp-menu-custom-fields-image-caption">{ Image Caption }</span>
        </div>
        <span class="rt-wp-menu-custom-fields-custom-text">{ Custom Text }</span>
    </div>
    
    • If Image Link is entered, then img tag will be wrapped inside a.
    • Custom text will be displayed below the feature's HTML.
  • Shortcode
    <div class="rt-wp-menu-custom-fields-shortcode-wrapper">
        <div class="rt-wp-menu-custom-fields-shortcode">
            { Shortcode }
        </div>
        <span class="rt-wp-menu-custom-fields-shortcode-caption">{ Shortcode Caption }</span>
    </div>
    
  • Custom HTML
    <div class="rt-wp-menu-custom-fields-custom-html">{ Custom HTML }</div>
    

Contribute

Reporting a bug ๐Ÿž

Before creating a new issue, do browse through the existing issues for resolution or upcoming fixes.

If you still need to log an issue, making sure to include as much detail as you can, including clear steps to reproduce your issue if possible.

Creating a pull request

Want to contribute a new feature? Start a conversation by logging an issue.

Once you're ready to send a pull request, please run through the following checklist:

  1. Browse through the existing issues for anything related to what you want to work on. If you don't find any related issues, open a new one.

  2. Fork this repository.

  3. Create a branch from develop for each issue you'd like to address and commit your changes.

  4. Push the code changes from your local clone to your fork.

  5. Open a pull request and that's it! We'll with feedback as soon as possible (Isn't collaboration a great thing? ๐Ÿ˜Œ)

  6. Once your pull request has passed final code review and tests, it will be merged into develop and be in the pipeline for the next release. Props to you! ๐ŸŽ‰

BTW, We're Hiring!

Join us at rtCamp, we specialize in providing high performance enterprise WordPress solutions

wp-menu-custom-fields's People

Contributors

alvitazwar avatar chandrapatel avatar deepaklalwani97 avatar dependabot[bot] avatar devikvekariya avatar gagan0123 avatar hrithikdalal avatar juhi123 avatar kiranpotphode avatar maitreyie-chavan avatar pooja-muchandikar avatar pradeep1308 avatar rahul286 avatar rtbot avatar shreyasikhar avatar sid177 avatar vaishaliagola27 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wp-menu-custom-fields's Issues

Test plugin with WordPress and PHP latest versions.

@alvitazwar Perform thorough testing of WP Menu Custom Fields v1.0.2 plugin with WordPress 6.0.2 and PHP 8.1 version and report issues for same.

Refer these test cases: https://docs.google.com/spreadsheets/d/1SUyVZsr0hsj9Wpt3pnYpPjgb68fMMj2sgA5MjTTGOw0/edit#gid=846109294

Create new test cases if required and add to same test cases.

Make sure you cover following points:

  • Test plugin on single and MU site
  • Test plugin with cross browser to check if everything works fine
  • Quick test in responsive mode
  • Add multiple menu items and check the behavior of plugin
  • Look out for console errors and notices/warnings in error log

Share updates in comments..

cc: @SonaliThakkar25

Validate Video design in menu - WP version - 6.0.2

Here are the steps to regenerate the issue:-

  1. Select Video Radio button
  2. Enter Shortcode text
  3. Add [video src= ""https://alvi-tazwar.rt.gw/wp-content/uploads/2022/09/https___handbook.rt_.gw_.mp4""]
  4. Enter Caption text

UI: Broken in both twenty twenty one and twenty twenty theme

When Any video, audio, or link is added to the menu then in both the themes Design seems to be broken in All the menus.
visit: https://alvi-tazwar.rt.gw/

add support for querying via wp-graphql

It would be great if this plugin was also able to expose the custom fields over the graphql schema of wp-graphql. This is a very common plugin for headless wordpress

UI: Audio shortcode not rendering correctly

In the twenty-twenty-one and twenty-twenty theme, the audio shortcode is not looking good. Need to fix the width of audio in both of the themes.

twenty-twenty theme :
Screenshot 2022-10-17 at 1 26 05 PM

twenty-twenty-one theme :
Screenshot 2022-10-17 at 1 25 07 PM

Final Round of Testing

@alvitazwar,

Let's perform the final round of testing by keeping in mind the following things:

  1. The issues we faced
  2. Responsive
  3. Cross Browser
  4. Cross Theme checks

Fatal error: Uncaught Error: Class 'WP_Menu_Custom_Fields\Inc\Plugin' not found

Issue reported via email


Hi ๐Ÿ‘‹๐Ÿผ I've discover a bug with your wordpress plugin "WP Menu Custom Fields"

The error :
Fatal error: Uncaught Error: Class 'WP_Menu_Custom_Fields\Inc\Plugin' not found in C:\Users\user\local-sites-beta\inoxpluschr\app\public\wp-content\plugins\wp-menu-custom-fields\wp-menu-custom-fields.php on line 29
( ! ) Error: Class 'WP_Menu_Custom_Fields\Inc\Plugin' not found in C:\Users\user\local-sites-beta\inoxpluschr\app\public\wp-content\plugins\wp-menu-custom-fields\wp-menu-custom-fields.php on line 29
Call Stack

Time Memory Function Location

1 0.0001 398632 {main}( ) ...\plugins.php:0
2 0.8459 18996072 plugin_sandbox_scrape( ) ...\plugins.php:177
3 0.8460 18996288 include( 'C:\Users\user\local-sites-beta\inoxpluschr\app\public\wp-content\plugins\wp-menu-custom-fields\wp-menu-custom-fields.php' ) ...\plugin.php:2255
4 0.8461 18996672 wp_menu_custom_fields_plugin_loader( ) ...\wp-menu-custom-fields.php:32

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.