PHP Notice: Use of undefined constant php - assumed 'php' - php

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 ?>

Related

How and where to put Jquery into a fully PHP page?

I have attempted to put my script into a page I have created but can't seem to get the script to work correctly. It is a paginate script which links to the "newsblocks" class. Where do I place the script to make it work?
<?php
/*
Template Name: [Newspage]
*/
get_header();?>
<div id="main" class="defaultContentWidth">
<div id="wrapper-row">
<div id="primary">
<div id="content">
<?php the_breadcrumb();?>
<h1 class="entry-title"><?php the_title();?></h1>
<?php if(have_posts()) :
while(have_posts()) : the_post();?>
<div class="newscont"><?php the_content();?></div>
<?php endwhile;
endif;?>
<script type="text/javascript" src="<?php bloginfo('template_directory');?>/javascript/jquery.pajinate.js"></script>
<div class="contnewslist">
<ul class="newsblocks">
<li>
<h2>NEWSLETTER 1</h2>
<i>November 01, 2014</i>
<p>This is the November edition of the newsletter for The Dry Cleaner App. Featuring in this newsletter is ...</p>
<input type="submit" value="Download" id="submit" class="newsdownload">
</li>
For Optimizing the performance of a webpage it's always recommended to put the Javascript file to your footer.
So load your script files in your footer file.
In wordpress you've a footer.php
Change
<script type="text/javascript" src="<?php bloginfo('template_directory');?>/javascript/jquery.pajinate.js"></script>
TO
<script type="text/javascript" src="<?php echo echo get_template_directory(); ?>/javascript/jquery.pajinate.js"></script>
try to add js with get_template_directory_uri()
<script type="text/javascript" src="<?php echo get_template_directory_uri(); ?>/javascript/jquery.pajinate.js"></script>
and add js to your theme footer.php or in same page footer or where you need
also i think typo here :- jquery.pajinate.js should be jquery.paginate.js
I'm thinking <?php bloginfo('template_directory');?> should be changed to <?php echo bloginfo('template_directory');?> but since you didn't gave us the definition of bloginfo() function we can't really do much..

Full Width colour sections but not full width page content

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>

add draggable sections in wordpress plugin page

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.

jQuery or markup?

I've successfully gotten my menu to be sticky using jQuery waypoints in this jsFiddle. It works fine in the fiddle, but when I implement on my test drupal site, it's no longer active.
Here's the markup:
<?php if ($page['main_menu']): ?>
<div id="stickywrapper">
<div class="main-menu-wrapper">
<div class="main-menu-wrapper-inner <?php echo $grid_size ?>">
<nav id="main-menu" class="<?php echo $grid_full_width ?> clearfix">
<?php print render($page['search_box']); ?>
<?php print render($page['main_menu']); ?>
</nav>
</div><!--end main-menu-wrapper-inner-->
</div><!--end main-menu-wrapper-->
</div><!--end stickywrapper-->
<?php endif; ?>
You've got a stray Unicode zero width space (U+200B) character at the end of the JavaScript code in stickymenu.js, causing a syntax error. Delete that and it all works out.

Wordpress php function get_header and get_footer issue on IIS7.5 & localhost

I have installed IIS7.5 on my box for development including php of course, and i have copied my wordpress site from my live server and changed the url settings in the db etc.
however when visiting the homepage none of the style or meta data associated in the header.php file is rendered. looking at the source code it changes the default php function
<?php get_header(); ?>
to include the header.php file and it gets rendered to the browser as
<? get_header(); ?>
i.e it is viewable as such in the view source.
other php functions and includes and php generally seems to be running ok in other files... i have mantisBT install running smoothly for example.
i have already tried copying the files from the server again and then using a fresh install of wordpress too.
accessing the wp-admin all seems to work ok
Does anyone have any ideas what might be causing this?
ta
EDIT: adding index.php file - very vanilla.
<?php get_header(); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<!-- Begin Post: <?php the_title(); ?> -->
<div class="post">
<h3 class="posttitle"><?php the_title(); ?></h3>
<div class="title"><div class="postmetadata"><?php the_time('F jS, Y'); ?> by <?php the_author(); ?> in <?php the_category(', '); ?></div></div>
<div class="entry">
<?php the_content(); ?>
</div>
<div class="tags"><div class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?></div></div><div class="comments"><div class="postmetadata"><?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?> <img src="<?php bloginfo('template_directory'); ?>/images/comment.png" alt="Comments" /></div></div>
</div><br /><br /><br />
<!-- End Post: <?php the_title(); ?> -->
<?php endwhile; ?>
<div class="navigation">
<div class="alignleft"><?php next_posts_link('« Older Entries') ?></div>
<div class="alignright"><?php previous_posts_link('Newer Entries »') ?></div>
</div>
<?php else: ?>
<p>Sorry, no posts matched your criteria.</p>
<?php endif; ?>
</div>
<!-- Include Sidebars -->
<?php include (TEMPLATEPATH . '/sidebarR.php'); ?>
<?php include (TEMPLATEPATH . '/sidebarL.php'); ?>
</div>
<?php get_footer(); ?>
EDIT: added header.php - also pretty vanilla
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
<link href="style.css" rel="stylesheet" type="text/css"/>
<link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" />
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
<?php wp_head(); ?>
<title><?php if (is_single() || is_page() || is_archive()) { ?><?php wp_title('',true); ?> | <?php } ?><?php bloginfo('name'); ?></title>
</head>
<body>
<div id="navwrap">
<div id="nav">
<div class="navpad">
<ul class="navi">
<li class="page_item"></li>
</div>
</div>
</div>
<div id="header">
<div class="headpad">
</div>
</div>
<div id="wrapper">
<div id="content">
UPDATE:
still getting the same issue, have reinstalled php 5.3.8, checked encoding, saved files as utf-8 without BOM. still no joy.
<? get_header(); ?>
<div class="post">
UPDATE 2:
Still not got this to work, the code is standard for a wordpress theme, i've installed another theme and it seems to work ok, so i doubt it is a IIS7 issue.
i've looked at the encoding of files and made sure everything is utf-8.
all my wordpress core files are intact and up to date.
This Row in the Wordpress Template File is a php code, which should be processed on server-side, it shouldn't be visible in the Source Code when you're calling the Page with IIS
<?php get_header(); ?>
Check your php installation and rewrite the PHP-Open Tag <?php and the PHP-Close Tag ?> manually. There can also be an encoding issue between the Tags. Also try do edit the document with another editor, or try to change the Encoding Type to UTF-8. If it still fails then attach your Template header.php here.
If you are not using any <?xml ?> in your code, then you might try adding short_open_tag 1 to your php.ini. It looks like you environment might be stripping the php from the tag <?php and if you are using PHP 5.3+ short_open_tag is disabled by default and won't render.
The preference is to have short_open_tag disabled, and it would be worth looking to find out what the php is bring removed from the <?php, but setting the configuration setting to 1 might at least get it working for now.
Instead of <?php get_header(); ?> try the direct include method <?php include_once("header.php"); ?> and let me know what happend.
Also <?php get_footer(); ?> works correctly or it is also displays in the source code. Thanks
it appears a number of issues helped fix it to a certain extent...
removed ~ from folder name in path.
added test.xyz.com addresses to host file
added these addresses to II7.5
updated wordpress db to reflect the new addresses.
rewritten index.php of theme file and rewritten the call to the get_header function.
wasted too much of my life on this...
result:
localhost/path/to/index.php now works and loads the header as expected. but not all the content (page not found on homepage).
test.xyz.com/index.php doesn't load header and still shows <? get_header(); ?> and the equivalent for the footer file.

Categories