This is the part of my functions.php that doesn't work (I get no PHP ERROR, and also nothing showing up):
function calmar_studio_customizer_register ($wp_customize) {
$wp_customize -> add_section('calmar_studio_colors', array (
'title' => __('Colors', 'calmar_studio'),
'description' => 'Modify the theme colors',
));
$wp_customize -> add_setting('background_color', array (
'default' => '#fff',
));
$wp_customize -> add_control( new WP_Customize_Color_Control($wp_customize, 'background_color', array(
'label' => __('Edit Background Color', 'calmar_studio'),
'section' => 'calmar_studio_colors',
'settings' => 'background_color',
) ));
}
add_action('cutomize_register', 'calmar_studio_customize_register');
While not exactly solving the issue, I grabbed the Sample from https://gist.github.com/Abban/2968549 and copied it into my functions.php file. Works perfectly. Now I have to make tweaks, and get the items to Display on the page.
This could be the plugin conflict issue. Please deactivate plugins and try.
Thanks.
Related
On my mediawiki site, you need to log in to view and edit pages. But the sidebar is displayed even when you are not logged in. Since there is some confidential information, I would like to show the sidebar only when you are logged in.
Does anyone have an idea? Thanks.
Left grey box should be hidden
Right now, I have these restrictions in LocalSettings.php:
$wgWhitelistRead = array( "Spezial:Userlogin", "MediaWiki:Monobook.css", "api.php");
$wgGroupPermissions['*']['read'] = false; $wgGroupPermissions['user']['protect'] = true;
$wgGroupPermissions['user']['edit'] = true; $wgGroupPermissions['*']['createaccount'] = false;
If you wants to remove the sidenavbar when you are not logged in there is two way.
Use a token for it and.
Use a state give it's initial value false, when the login api success then true the state with this condition also you need your user id to check if it's there then show the sidenavbar.
I did some research for you and I found this, it should be what you are looking for.
CREDIT: https://sangkrit.net/how-to-hide-mediawiki-sidebar-from-visitors/
You can suppress the display of the sidebar from anonymous and un-logged-in users on your MediaWiki website. This can be done by creating a new PHP file in extensions folder then including the code in LocalSettings.php file.
Login to your MediaWiki website’s file manager or FTP, navigate to /extensions directory located in your site’s root and create a new folder /HideSidebar.
Open the folder, create a new PHP file with name HideSidebar.php and paste the following code:
<?php
if ( !defined( 'MEDIAWIKI' ) ) {
echo "Not a valid entry point";
exit( 1 );
}
$wgExtensionCredits['other'][] = array(
'path' => __FILE__,
'name' => 'HideSidebar',
'version' => '1.0.1',
'author' => 'Jlerner',
'url' => 'https://www.mediawiki.org/wiki/Extension:HideSidebar',
'description' => 'Allows to hide the sidebar from anonymous users',
);
$wgHooks['SkinBuildSidebar'][] = 'efHideSidebar';
function efHideSidebar($skin, &$bar) {
global $wgUser;
// Hide sidebar for anonymous users
if (!$wgUser->isLoggedIn()) {
$url = Title::makeTitle(NS_SPECIAL, 'UserLogin')->getLocalUrl();
$bar = array(
'navigation' => array(
array('text' => 'Login',
'href' => $url,
'id' => 'n-login',
'active' => '')
)
);
}
return true;
}
Now open LocalSettings.php file and add this line of code:
require_once "$IP/extensions/HideSidebar/HideSidebar.php";
Save changes and you are done.
Based on Adam's answer and Robert's comment on the site referenced:
This can be done by creating a new PHP file in extensions folder then including the code in LocalSettings.php file.
Login to your MediaWiki website’s file manager or FTP, navigate to /extensions directory located in your site’s root and create a new folder /HideSidebar.
Open the folder, create a new PHP file with name HideSidebar.php and paste the following (Updated) code:
<?php
if ( !defined( 'MEDIAWIKI' ) ) {
echo "Not a valid entry point";
exit( 1 );
}
$wgExtensionCredits['other'][] = array(
'path' => __FILE__,
'name' => 'HideSidebar',
'version' => '1.0.1',
'author' => 'Jlerner',
'url' => 'https://www.mediawiki.org/wiki/Extension:HideSidebar',
'description' => 'Allows to hide the sidebar from anonymous users',
);
$wgHooks['SkinBuildSidebar'][] = 'efHideSidebar';
function efHideSidebar($skin, &$bar) {
$user = RequestContext::getMain()->getUser();
// Hide sidebar for anonymous users
if ($user->getId() == 0) {
$url = Title::makeTitle(NS_SPECIAL, 'UserLogin')->getLocalUrl();
$bar = array(
'navigation' => array(
array('text' => 'Login',
'href' => $url,
'id' => 'n-login',
'active' => '')
)
);
}
return true;
}
Now open LocalSettings.php file and add this line of code:
require_once "$IP/extensions/HideSidebar/HideSidebar.php";
Save changes and you are done.
You'd just need to look for the body's class when logged in, and if it's .logged-in, do something like this:
body:not(.logged-in) .sidebar{
display: none;
}
I have written a custom calendar module for use with Beaver Builder.
I want to fetch posts from a custom post_type of 'event' to populate the calendar.
In my beaver builder module I have the following:
wp_enqueue_script( 'axios', 'https://unpkg.com/axios/dist/axios.min.js');
wp_enqueue_script( 'qs', 'https://unpkg.com/qs/dist/qs.js');
function get_ajax_event_calendar_posts() {
// Query Arguments
$args = array(
'post_type' => array('event'),
'post_status' => array('publish'),
'posts_per_page' => 40,
'nopaging' => true,
'order' => 'DESC',
'orderby' => 'date',
'cat' => 1,
);
// The Query
$ajaxposts = get_posts( $args ); // changed to get_posts from wp_query, because `get_posts` returns an array
echo json_encode( $ajaxposts );
wp_die(); // this is required to terminate immediately and return a proper response
}
// Fire AJAX action for both logged in and non-logged in users
add_action('wp_ajax_get_ajax_event_calendar_posts','get_ajax_event_calendar_posts');
add_action('wp_ajax_nopriv_get_ajax_event_calendar_posts', 'get_ajax_event_calendar_posts');
and in my modules JavaScript (frontend.php) I have:
var data = { action: "get_ajax_event_calendar_posts" };
axios.post("<?php echo admin_url('admin-ajax.php');?>", Qs.stringify(data))
.then(function(response) {
console.log(JSON.stringify(response.data));
})
.catch(function(error) {
console.log(error);
});
I have one post in 'event'. In the browser, I test the endpoint by visiting xxx.flywheelsites.com/wp-admin/admin-ajax.php?action=get_ajax_event_calendar_posts and receive an empty array []. I expect to receive a single event. I've looked in the admin and can see the post.
When clicking on the button in my module to make the Ajax request, I receive a 400 error
Checking the logs, I receive the following error message:
(MISSING)127.0.0.1 - 04/Jan/2020:16:41:40 +0000 "POST /.wordpress/wp-admin/admin-ajax.php" 400 /www/.wordpress/wp-admin/admin-ajax.php 64263000 4103576 709.963 4096 35.21%!
This error message doesn't really tell me anything. I also altered my axios method to use a GET - however, I receive the same error.
Any advice on how I can debug this would be really helpful. Thanks!
Wordpress, Astra Theme, Beaver Builder, hosted on flywheel.
** Edit **
To test, in my get_ajax_event_calendar_posts method I am echo'ing out 'hello world'
function get_ajax_event_calendar_posts() {
// Query Arguments
$args = array(
'post_type' => array('event'),
'post_status' => array('publish'),
'posts_per_page' => 40,
'nopaging' => true,
'order' => 'DESC',
'orderby' => 'date',
'cat' => 1,
);
// The Query
$ajaxposts = get_posts( $args ); // changed to get_posts from wp_query, because `get_posts` returns an array
echo 'hello world'; //json_encode( $ajaxposts );
wp_die(); // this is required to terminate immediately and return a proper response
}
I visit the url in my browser and see 'hello world' - so it seems there might be a problem in querying the data? The logs don't contain anything useful. However, from this I can see I can hit the route and get a response from it.
** Edit **
I can now view the posts when hitting the url directly. Appears to be an issue of cacheing.... I have updated my JS - yet the old files persist. I'm hopeful this is just a cacheing issue...
Using Beaver Builder, I had to clear Beaver Builders cache. To clear it, go into settings -> beaver-builder -> tools and click the clear cache button.
I'm experiencing some unexpected behaviors when using wp_list_comments.
Generated link:
<a rel="nofollow" class="comment-reply-link" href="http://localhost/mypost/?replytocom=2#respond" onclick="return addComment.moveForm( "div-comment-2", "2", "respond", "9" )" aria-label="reply to NAME">Reply</a>
When I click the reply link the JavaScript console throws an error:
I was expecting that the textarea will show up under the current comment upon clicking the reply button.
Uncaught TypeError: Cannot read property 'getElementsByTagName' of null
at Object.moveForm (comment-reply.min.js?ver=4.9.4:1)
at HTMLAnchorElement.onclick (VM18269:489)
Now to the unexpected behaviours. Im using the Plugin AdvancedCustomFields. When I disable the plugin the following error is thrown:
Uncaught ReferenceError: addComment is not defined
at HTMLAnchorElement.onclick (VM18404:489)
To solve this particular problem i've tried to manually add the comment-reply.js
functions.php
// enable reply to comments
function theme_queue_js(){
if ( (!is_admin()) && is_singular() && comments_open() && get_option('thread_comments') )
wp_enqueue_script( 'comment-reply' );
}
add_action('wp_enqueue_scripts', 'theme_queue_js');
This however is not enqueing the script as expected. Still throwing Uncaught ReferenceError (note the ACF Plugin is still disabled).
comments.php
<ul id="comments">
<?php wp_list_comments(array(
'walker' => null,
'max_depth' => '',
'style' => 'ul',
'callback' => null,
'end-callback' => null,
'type' => 'comment',
'reply_text' => 'Reply',
'page' => '',
'per_page' => '',
'avatar_size' => 32,
'reverse_top_level' => null,
'reverse_children' => '',
'format' => 'html5', // or 'xhtml' if no 'HTML5' theme support
'short_ping' => false, // #since 3.6
'echo' => true // boolean, default is true
)); ?>
</ul>
Some more-or-less useful informations:
I am using the comment-list theme support
I've cleared the cache
I've used multiple other browsers (logged in & logged out)
There are no other javascript errors thrown
I did a fair amount of research already. I've also stumbled upon an situation where the LastPass Extension caused the errors above. But the given solutions (disabling and/or logout from the extension) for that, didn't work out me, unfortunately.
The solution (at least for me) was to add comment_form().
I managed to oversee this simple function for hours.
<div id="comments">
<ul>
<?php wp_list_comments(array(
'walker' => null,
'max_depth' => '',
'style' => 'ul',
'callback' => null,
'end-callback' => null,
'type' => 'comment',
'reply_text' => 'Reply',
'page' => '',
'per_page' => '',
'avatar_size' => 32,
'reverse_top_level' => null,
'reverse_children' => '',
'format' => 'html5', // or 'xhtml' if no 'HTML5' theme support
'short_ping' => false, // #since 3.6
'echo' => true // boolean, default is true
)); ?>
</ul>
<?php comment_form(); ?>
I'm trying to sort the records created through my TYPO3 extension in the list view. This is my TCA for that table:
$GLOBALS['TCA']['tx_trends_domain_model_gallery'] = array(
'ctrl' => array(
'title' => 'LLL:EXT:trends/Resources/Private/Language/locallang_db.xlf:tx_trends_domain_model_gallery',
'label' => 'description',
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'cruser_id' => 'cruser_id',
'dividers2tabs' => TRUE,
'sortby' => 'sorting',
'versioningWS' => 2,
'versioning_followPages' => TRUE,
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l10n_parent',
'transOrigDiffSourceField' => 'l10n_diffsource',
'delete' => 'deleted',
'enablecolumns' => array(
'disabled' => 'hidden',
'starttime' => 'starttime',
'endtime' => 'endtime',
),
'searchFields' => 'images,description,trends,',
'dynamicConfigFile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'Configuration/TCA/Gallery.php',
'iconfile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($_EXTKEY) . 'Resources/Public/Icons/tx_trends_domain_model_gallery.gif'
),
);
I added the sorting field in the table and I can see the two arrow buttons in the BE (move up/down). When I click that button however, I get the following JS error in my chrome devtools:
Uncaught SyntaxError: missing ) after argument list
I found the answer..
A colleague told me that we modified an extension called grid_elements, so that it works with TYPO3 7.4.0. This extension hooked in the backend with some inline javascripts. These scripts had some errors in it (double quotes, wrong escaping). This was causing the bug where I was unable to move records in the list view up and down. It's fixed now.
Well, I have a CakePHP 2.2.5 app which is basically management of users, and a user has a photo, and I create a PhotosController (as suggestion of this tutorial). I tested it and it works perfectly on Photos/View, including the ajax elements to be possible send a photo in a form without redirecting. And now I'm trying to connect all of this, but it ins't as easy as I think it should be.
My Photo add method:
public function add()
{
if ( $this->request->is( 'post' ) ) {
$this->Photo->create();
$json = array( 'result' => array( 'files' => array() ) );
if ( $this->Photo->save( $this->request->data ) ) {
$photo = $this->Photo->findById( $this->Photo->id );
$json['files'][0]['name'] = $photo['Photo']['basename'];
$json['files'][0]['size'] = $this->request->data['Photo']['file']['size'];
$json['files'][0]['url'] = $this->webroot . 'media/transfer/img/' . $photo['Photo']['basename'];
$json['files'][0]['thumbnail_url'] = $this->webroot . 'media/filter/thumbnail/img/' . $photo['Photo']['basename'];
}
else {
$json = 'Error';
$this->Session->setFlash( __( 'The photo could not be saved. Please, try again.' ) );
}
$this->RequestHandler->renderAs( $this , 'ajax' );
Configure::write( 'debug' , 0 );
$this->set( 'json' , json_encode( $json ) );
$this->render( '/Elements/ajax' );
}
My test View (on users controller):
<?php echo $this->Form->create(
'Photo' ,
array( 'url' => array( 'controller' => 'photos' ,
'action' => 'add'
) ,
'id' => 'fileupload' ,
'enctype' => 'multipart/form-data'
)
); ?>
<-- Some HTML HERE-->
<?php
echo $this->TB->input(
'Photo.file' ,
array(
'prepend' => 'Upload' ,
'type' => 'file' ,
'class' => 'fileUpload' ,
//'multiple' => 'multiple',
'div' => FALSE ,
'between' => FALSE ,
'after' => FALSE ,
'label' => FALSE ,
'help' => NULL ,
)
);
?>
</form>
<-- Some (already tested) Javascript to make this work HERE-->
The view renders without php errors, but when I upload a file I get an Javascript error, and the debug says:
GET http://<server>/<app>/users/add 404 (Not Found) jquery.min.js:1960
send jquery.min.js:1960
b.extend.ajax jquery.min.js:1840
(anonymous function) main.js:59
c jquery.min.js:215
p.fireWith jquery.min.js:249
b.extend.ready jquery.min.js:69
H jquery.min.js:10
Actually, I get this error on both, GET and POST methods (with some different line of jQuery of course).
Even the action is set to the PhotosController it is trying to access the Users. I think because of the view, as I din't specify users anywhere. I am trying to solve this problem for a week and I don't have more ideas.
Any help would be greatly appreciated.
Thanks in advance.