Where to start in editing a wordpress plugin? - wordpress

I am a newbie in wordpress and I was given the opportunity to edit a certain plugin which is MarketPress, but then I had hard times dealing with it since I'm new to this thing and I don't know where exactly to go, I would want to edit an included dynamic_sidebar but I can't the file on where to edit this. Please help me. :(
Thanks.

Not sure of your level of understanding so forgive me if this is over-simplistic.
The sidebar content is driven by widgets, which is controlled from the Widgets admin panel. The only thing about a sidebar that you should be able to edit by messing with its definition are the wrapping markup for the whole widget and for the title, along with the sidebars name and description. The last two only effect text that shows up in the admin Widgets panel.
However what I describe above is not found with the dynamic_sidebar() method, rather with the register_sidebar() or register_sidebars() methods. These 'define' the name and settings for a sidebar. The dynamic_sidebar() method is the used to implement the sidebar by passing it that sidebars name.
The sidebar is then populated with widgets via the admin Widgets panel.
Typically sidebars are registered from within the functions.php file of a theme, but if a plugin contains templates there no reason why it couldn't also have its own sidebars. As for where the register_sidebar() function is being used in your plugin specifically, I couldn't say. Just search through it using whatever IDE you like, or grep if your comfortable with it.
Hope this helps.

Related

What is the difference between wordpress widgets and block

I have started learning wordpress recently. I have started from version 5 with this new Gutenberg editor which introduced Blocks. I am little confused regarding difference between this new Blocks concept and old Widgets.
Starting with a Blocks: they appear on page creation and can be added to page, there is nice documentation on wordpress webpage: https://developer.wordpress.org/block-editor/tutorials/block-tutorial/ a lot of stuff related to new blocks.
Everything is fine, but Blocks can be added only to page content and not into areas like: sidebar, footer etc.
For changing content of sidebar,footer areas we need to access Appearance->Widgets area where we can add multiple widgets to specific areas. Also for new Gutenberd Page Builder there is section called widgets available but with less number of widgets than under
Apperance->Widgets section.
Im totally confused. Could someone explain what is the difference betweemn Blocks and Widgets?
Why for areas like sidebar/footer we can add only widgets and editing footer is under Widgets menu?
Why only part of widgets are available for Gutenberg Page Editor
What should i do to create reusable code snippet(some html/css/js logic) to be reused on a page? Should i create a widget and somehow include it to widget section for Gutenberg or maybe i should create this new concept of Block? But i will not reuse my block in footer/sidebar section...
Are widgets something which will gonna die soon in wordpress world and will be totally replaced by Blocks? I remember that in previous version we were able to add widgets to page using some kind of shortcodes, so any widget we want? Is it still possible?.
I will appreciate any comments on that.
The Block Editor is so far being used only to generate "content". In the world of WordPress, that normally very generic word has a very specific meaning: whatever is returned by the function the_content(). Usually it's simply all the text and media input on the edit page of a post or page, though that can be modified by filters. This content is entered either in the classic editor's text box or (now) in one or more Gutenberg Blocks.
Widgets, on the other hand, display content outside the main content, in widget areas that your theme has located outside the main content in headers, sidebars, footers, etc.
I suspect you already know much of this. As to your question about code snippets, the simplest way to re-use code is through WordPress shortcodes. Register your shortcodes in functions.php or in a plugin; enable them in your theme; then use them anywhere. There is now a shortcode Block, by the way, for placing recurring content into main content.

Calling a Sidebar Created by WooSidebars within Timber

I've used WooSidebars in a lot of projects to allow for custom sidebars much like using ACF. This is the first time however I've decided to also use it within the Timber Framework. I have the sidebar registered within my functions.php and the sidebar itself works. Now if I create a sidebar from with WooSidebars and try to aside widgets to it, it seems that the overrides that WooSidebars is doing doesn't get picked up by Timber.
I'm calling:
$context['sidebar'] = Timber::get_widgets('page');
And within the plugin I'm creating a widget area to replace page on a contact us page with a different sidebar. Timber will only continue to pick up the page sidebar rather than the override. However if I call
$context['sidebar'] = Timber::get_widgets('contact-us-sidebar');
manually it'll work.
Is there a way to inform the Timber context that I need the WooSidebar supplied sidebar instead of the default, literal sidebar?
Over the years I've been able to solve this in two ways, though neither feels all that ideal for me, it's been getting the job done.
Don't use widgets to manage the sidebar content and instead manage it on-page within a custom field.
If you do want/need to use widgets I then create a dropdown custom field which has all the widgets in it, using their ID as the value. Then I grab this value and pass it into Timber::get_widgets to get the sidebar on I want for the page.

Wordpress - Only allow one Text Widget to be added

I'm in the process of trying to create a custom theme for Wordpress and managed to create a working widget area. But for the purpose of this theme, I would like to allow only one "Text-Widget" to be used. How would I go about limiting this?
Be specific about what you want to ask. Wordpress don't limit widgets you can use as much text widget.
Can you provide urls so we could advice a solution to you?
I'll update the code below to be compatible with your theme if you can give a url to your blog.
WordPress don't allow you to limit the number of widgets but you can use javascript to hide the next sidebar items.
$('.sidebar li:gt(0)').hide();
the 2nd list item onwards will be hidden.
and yeah, this is a bit of cheating though.
SEO wise the next widgets are still visible.

Is it possible to somehow add data specific to an individual page's widget in Wordpress?

I want to add a google maps widget to Pages on a Wordpress site. They all have the same Template with a Sidebar but the map will be unique for each. I feel like there should be a way to populate the widget from the edit page screen for that Page. Does each Page actually need it's own Template?
This seems limiting maybe I'm missing something. If the question is unclear I let me know but I think this should be something ppl have run up against before.
I would suggest the integration of a wordpress plugin to accomplish this. It will be fairly easy to do.
If you want to do this without purchasing any 'pro' versions of a plugin and don't mind writing some simple code, then I would suggest Simple Google Map. You will have to insert a shortcode into the widgetized sidebar area. Here is the plugin link - http://wordpress.org/extend/plugins/simple-google-map/
In order to customize each page's sidebar area, You need to write some code. Please refer to this article which will explain how http://www.wpbeginner.com/wp-themes/display-different-sidebar-for-each-post-and-page-for-wordpress/
It involves a simple alteration of your 'single.php' file and the usage of 'custom fields' so that you will be able to do this from the edit screen of the page, just like you wanted to do!
Use a plain text widget for each map and Widget Logic to select the page it appears on: WordPress › Widget Logic « WordPress Plugins

Wordpress - hardcoding subscribe2 (or any other plugin) widget into template

I know how to hardcode categories, archives, etc into theme but for one of my projects i would have to hardcode some plugins widgets (especially subscribe2) and i'm not sure how to do this. I know i can add widgets via widgets menu in wp admin, but that's not what i'm trying to achieve, i'm trying to set it up permamently in theme for later reuse. How to do this? Especially with subscribe2?
You can add the widget via the normal means, and check the code on the site using View->Source.
Then, you need to edit the html template for the theme (depending on where you want the widget to appear - main entry, sidebar.html, etc) and add the code there directly.

Resources