want to make draggable and sortable sections in plugin page of wordpress, like we see on dashboard. i tried finding but dint get exactly what I want.
Here is the piece of code though it add two divs with interface similar to draggable interface in dashboard, but i am unable to drag.
<div class="wrap">
<h2>I like to move it, move it</h2>
<div class="meta-box-sortables ui-sortable">
<div class="postbox" id="p1">
<h3 class="hndle">Drag me around, babe</h3>
<div class="container">
<p>Your content goes here</p>
</div>
</div><!-- .postbox -->
<div class="postbox" id="p2">
<h3 class="hndle">Drag me, too</h3>
<div class="container">
<p>Your content goes here, again</p>
</div>
</div><!-- .postbox -->
</div><!-- .meta-box-sortables.ui-sortable-->
</div><!-- .wrap -->
<?php
function move_me_around_scripts() {
wp_enqueue_script('dashboard');
wp_enqueue_script( 'jquery-ui-sortable');
}
function admin_page_with_draggable_boxes(){
$my_page = add_dashboard_page( 'moveit', 'moveit', 'read',
'moveit' );
add_action('load-'.$my_page, 'move_me_around_scripts');
}
add_action('admin_menu', 'admin_page_with_draggable_boxes'); ?>
You have to enqueue the sorting script, and add jQuery and jQuery UI Sortable as dependencies. Your sample code has add_dashboard_page with wrong parameters, also, use admin_print_scripts instead of load-$page.
add_action('admin_menu', 'admin_page_with_draggable_boxes');
function admin_page_with_draggable_boxes()
{
$my_page = add_dashboard_page(
'Move it',
'Move it',
'add_users',
'moveit-page',
'moveit_callback'
);
add_action( "admin_print_scripts-$my_page", 'move_me_around_scripts' );
}
function move_me_around_scripts()
{
wp_enqueue_script(
'move-it',
plugins_url( '/moveit.js', __FILE__ ), // <----- get_stylesheet_directory_uri() if used in a theme
array( 'jquery-ui-sortable', 'jquery' ) // <---- Dependencies
);
}
function moveit_callback()
{
?>
<div class="wrap">
<h2>I like to move it, move it</h2>
<div class="meta-box-sortables ui-sortable">
<div class="postbox" id="p1">
<h3 class="hndle">Drag me around, babe</h3>
<div class="container">
<p>Your content goes here</p>
</div>
</div><!-- .postbox -->
<div class="postbox" id="p2">
<h3 class="hndle">Drag me, too</h3>
<div class="container">
<p>Your content goes here, again</p>
</div>
</div><!-- .postbox -->
</div><!-- .meta-box-sortables.ui-sortable-->
</div><!-- .wrap -->
<?php
}
And the moveit.js file:
jQuery(document).ready(function($)
{
$('.meta-box-sortables').sortable({
opacity: 0.6,
revert: true,
cursor: 'move',
handle: '.hndle'
});
});
From what i can see of your code you probably want to use sortable together with draggable ui
http://jqueryui.com/draggable/#sortable in someway or alone with snapping.
Related
I have a theme that displays a menu of products via widgets. We are able to show/hide these categories (sidebars) via the code below. Right now it will show/hide this carousel-item if one of the two product categories have widgets. We would like keep this functionality, but hide the category if it is empty. For example if there are products in category 1, but not in category 2 we want to hide an entire section (see notes in code of where we want this.
<?php if ( is_active_sidebar( 'widget-category-1' ) || is_active_sidebar('widget-category-2') ) { ?>
<div class="carousel-item active animated fadeIn">
<div class="d-block w-100">
//show or hide start here//
<div class="container-fluid px-5">
<div class="row">
<ul class="three-col">
<?php dynamic_sidebar( 'widget-category-1' ); ?>
</ul>
</div>
</div>
//show or hide end here//
//show or hide start here//
<div class="container-fluid">
<div class="row">
<ul class="three-col">
<?php dynamic_sidebar( 'widget-category-2' ); ?>
</ul>
</div>
</div>
//show or hide end here//
</div>
</div>
<?php } ?>`
You can use first-of-type or nth-of-type to reference the element you want to toggle. That or possibly a not() pseudo class should do the trick.
I added a CSS tag to your question. You would need to add the rest of the element that dynamic_sidebar is returning to be sure but typically there is a 'has-items' identifier you can reference.
We ended up wrapping each section in a <div class="phide"></div> and used javascript to hide the this div if no <li></li> is present
<script>
(function($) {
$( document ).ready(function() {
$('.phide:not(:has(li))').hide();
});
})(jQuery);
</script>
Was just editing a site I'm working on to include the subscription form in the footer.php rather than just the homepage. I made the changes on the local server then moved it to my live environment (dev sub-folder). I didn't see any errors on my localhost, but on the dev site it is showing the following error:
PHP Notice: Use of undefined constant php - assumed 'php' in /home/website-name/public_html/uk-en/dev/wp-content/themes/theme-name/footer.php on line 1
The only thing on line 1 is the opening php tag, see code below from the footer.php file
<?php?>
</div><!-- #main -->
<footer id="colophon" class="site-footer" role="contentinfo">
<div class="subscribe-form">
<p>SIGN UP TO OUR EMAIL NEWSLETTER FOR NEWS, OFFERS & EXCITING COMPETITIONS.<p>
<div class="contact-7-subscribe"> <?php echo do_shortcode( '[contact-form-7 id="4563" title="Newsletter"]' ); ?> </div>
</div>
<div class="site-info">
<div class="socialmedia">
</div>
<div class="payment_cards">
<img src="<?=site_url();?>/wp-content/uploads/2017/05/payment_cards.png" alt="payments cards"/>
</div>
<?php /* Widgetized sidebar */ if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('footerwidget') ) : ?><?php endif; ?>
</div><!-- .site-info -->
</footer><!-- #colophon -->
</div><!-- #page -->
<?php wp_footer(); ?>
<?php /* if(get_the_ID() == 5) { ?>
<script type="text/javascript"
src="//s3.amazonaws.com/downloads.mailchimp.com/js/signup-
forms/popup/embed.js" data-dojo-config="usePlainJson: true, isDebug: false">
</script><script type="text/javascript">require(["mojo/signup-
forms/Loader"], function(L) { L.start({"baseUrl":"mc.us10.list-
manage.com","uuid":"37710aefba71598269bda7def","lid":"4385b1c355"}) })
</script>
<?php } */ ?>
<!--Start of Zopim Live Chat Script-->
<script type="text/javascript">
window.$zopim||(function(d,s){var z=$zopim=function(c){z._.push(c)},$=z.s=
d.createElement(s),e=d.getElementsByTagName(s)[0];z.set=function(o){z.set.
_.push(o)};z._=[];z.set._=[];$.async=!0;$.setAttribute("charset","utf-8");
$.src="//v2.zopim.com/?34qd49wmFaK3NsxoUst4PCSk4gaXUQVe";z.t=+new Date;$.
type="text/javascript";e.parentNode.insertBefore($,e)})(document,"script");
</script>
<!--End of Zopim Live Chat Script-->
<?php /*?><script type="text/javascript"
src="//s3.amazonaws.com/downloads.mailchimp.com/js/signup-
forms/popup/embed.js" data-dojo-config="usePlainJson: true, isDebug: false">
</script><script type="text/javascript">require(["mojo/signup-
forms/Loader"], function(L) { L.start({"baseUrl":"mc.us10.list-
manage.com","uuid":"37710aefba71598269bda7def","lid":"4385b1c355"}) })
</script><?php */?>
</body>
</html>
I could turn off notice display however I would like to get the right solution rather than a cover up
Basic syntax of php opening tag is <?php[whitespace] not just <?php, see here http://php.net/manual/en/language.basic-syntax.phptags.php#118827.
So the right syntax would be adding a white space in between php opening and closing tag <?php ?>
I have made a static blank page that also shows my website's header/sidebar/footer in it. Now what i am trying to do is get rid of the 'style' that my wordpress template css is forcing me to have on the page i am trying to create.
Here is my code:
<?php
/*
* Template Name: My own page!
* Description: I made a page!
*/
require (dirname(dirname( __FILE__ )).'/wp-load.php');
get_header(); ?>
<div id="main-content" class="main-content">
<?php
if ( is_front_page() && twentyfourteen_has_featured_posts() ) {
// Include the featured content template.
get_template_part( 'featured-content' );
}
?>
<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<!-- MY CONTENT!!! -->
Hello2.
<h1> hello.</h1>
<p>hello</p>
<input type="submit" name="connect" value="CONNECT" style="height:52px ; width:136px"/>
<p>hi</p>
<!-- -->
</div><!-- #content -->
</div><!-- #primary -->
<?php get_sidebar( 'content' ); ?>
</div><!-- #main-content -->
<?php
get_sidebar();
get_footer();
Any help appreciated.
You will need to overwrite the styles which are already in the theme. For example, you can give an id to your submit button like <input type="submit" name="connect" value="CONNECT" id="submitbutton"> and then style it according to your needs using CSS, for example:
input#submitbutton {
height: 52px;
width: 136px;
background: blue;
color: white;
}
Same goes for the <h1> tags. Give an <id> to your <h1> tag like <h1 id="hello"> hello.</h1> and then style it according to your needs using CSS, for example:
h1#hello {
color: black;
font-weight: bold;
font-size: 20px;
}
Use of Developer Tools over here will help you quite a lot in order to see how an element would look with your desired styles before actually making any changes to its CSS.
you will need to use something like
get_header('custom-header');
And use a custom header file to only load the stuff you want. You may need to create a custom function to override the scripts included by the theme...
I am using Bootstrap but under the roots.io wordpress template using a 'wrapperless theme'
i am trying to achieve this http://roots.io/ - where there are sections of colour but the page content itself isn't full width.
the answer I have been given is to make the container class 100% - but this just makes all the content full width.
Im really stuck and ive been trying to figure this out for hours. - I know that sounds noobish and it is, but I can't get past this point.
all the page templates take their its style from base.php, code here
<?php get_template_part('templates/head'); ?>
<body <?php body_class(); ?>>
<!--[if lt IE 8]><div class="alert alert-warning"><?php _e('You are using an <strong>outdated</strong> browser. Please upgrade your browser to improve your experience.', 'roots'); ?></div><![endif]-->
<?php
do_action('get_header');
// Use Bootstrap's navbar if enabled in config.php
if (current_theme_supports('bootstrap-top-navbar')) {
get_template_part('templates/header-top-navbar');
} else {
get_template_part('templates/header');
}
?>
<div class="wrap container" role="document">
<div class="content row">
<div class="main <?php echo roots_main_class(); ?>" role="main">
<?php include roots_template_path(); ?>
</div><!-- /.main -->
<?php if (roots_display_sidebar()) : ?>
<aside class="sidebar <?php echo roots_sidebar_class(); ?>" role="complementary">
<?php include roots_sidebar_path(); ?>
</aside><!-- /.sidebar -->
<?php endif; ?>
</div><!-- /.content -->
</div><!-- /.wrap -->
<?php get_template_part('templates/footer'); ?>
</body>
</html>
so Im just not sure how to get past it in any of the page templates
About the first part of your question: "100% width colored parts".
Cause Bootstrap use the box-sizing: border-box model every html-element gets 100% width of its parent by default. So wrap your .container div's in other element (div, header, etc). This wrapper is a direct child of the body and gets 100% width. See: http://bootply.com/87196
<header role="banner" class="banner">
<div class="container" style="background-color:red;">
Header example
</div>
</header>
<div style="background-color:blue;">Elements get 100% width by default</div>
The second part about your page templates. The code you show use the get_template_part(). This function is a core function of WordPress. See http://codex.wordpress.org/Function_Reference/get_template_part#Using_loop.php_in_child_themes. You will find where your templates should be located.
But i think read http://roots.io/roots-101/#theme-templates first.
Thank you, I had a few solutions offered to me yesterday also, in case anyone else looks at this.
my own was simply to remove the .container class from the base.php file. - this just stopped the content of every page being constrained in a container by default. - this way I was able to add sections to the page at full browser width, and add .container inside them to constrain the actual content.
lines 16 and 17 of original base.php
<div class="wrap <?php if ( ! is_front_page() ): ?>container<?php endif; ?>" role="document">
<div class="content <?php if ( ! is_front_page() ): ?>row<?php endif; ?>">
In app.less
.home .main {
padding: 0;
}
Then add your sections like so:
<section class="semantic-section-class">
<div class="container">
<!-- your content -->
</div>
</section>
in the 404.php page my original message is showing correctly, but i also get a second message in the footer, I checked all files and googled a lot about this issue but got no results.
this is the live example: http://www.rapyemen.org/?page_id=181
can anyone help to to solve this issue of getting two 404 messages?
this is my 404.php code:
<div id="container">
<?php
// action hook for placing content above #content
nd_abovecontent();
// filter for manipulating the element that wraps the content
echo apply_filters( 'nd_open_id_content', '<div id="content">' . "\n\n" );
// action hook for placing content above #post
nd_abovepost();
?>
<div id="post-0" class="post error404">
<div class="entry-content">
<p><?php _e( 'Apologies, but we were unable to find what you were looking for. Perhaps searching will help.', 'thematic' ) ?></p>
</div><!-- .entry-content -->
<form id="error404-searchform" method="get" action="<?php echo home_url(); ?>/">
<div>
<input id="error404-s" name="s" type="text" value="<?php the_search_query(); ?>" size="40" />
<input id="error404-searchsubmit" name="searchsubmit" type="submit" value="<?php esc_attr_e( 'Find', 'thematic' ); ?>" />
</div>
</form>
</div><!-- .post -->
<?php
// action hook for placing content below #post
nd_belowpost();
?>
</div><!-- #content -->
<?php
// action hook for placing content below #content
nd_belowcontent();
?>
</div><!-- #container -->
<?php
// action hook for placing content below #container
nd_belowcontainer();
// calling the standard sidebar
nd_sidebar();
// calling footer.php
get_footer();
?>
Seems like there is no page id called 118.
For example your Contact Us page work fine with page id of208`.
Make sure you are passing correct page id.