Kev Posted December 31, 2020 Report Posted December 31, 2020 Salut, recent am instalat un plug-in pe o platforma Wordpress, primesc urmatoarea eroare: Warning: Use of undefined constant wp_head - assumed 'wp_head' (this will throw an Error in a future version of PHP) in /srv/disk15/3697334/www/.../.../wp-content/.../happynewyear.php on line 65 full code: <?php /* Plugin Name: Happy New Year Plugin URI: https://www.melihguney.com/wordpress-happy-new-year-plugin.html Description: This plugin will create a good skin in your wordpress blog. Version: 5.0 Author: Melih Guney Author URI: https://www.melihguney.com/ License: GPLv2 (or later) */ function happynewyear() { /* Path for snow */ $snowPath = get_option('siteurl').'/wp-content/plugins/happy-new-year/'; $snowJS = "\n".'<script type="text/javascript"> sitePath = "'.$snowPath.'"; </script>'."\n"; $snowJS .= '<script type="text/javascript" src="'.$snowPath.'jquery.js"></script>'."\n"; $snowJS .= '<script type="text/javascript" src="'.$snowPath.'newyear.js"></script>'."\n"; $snowJS .= '<script type="text/javascript" src="'.$snowPath.'snow.js"></script>'."\n"; print($snowJS); ?> <!-- Happy New Year Plugin Start --> <style type="text/css"> <!-- .govde { width:100%;} .solust { width:272px; height:283px; position:fixed; top:0; left:0; background:url('<?php echo plugins_url('leftimg.png', __FILE__); ?>') no-repeat top left; z-index:1; } .sagust { width:281px; height:268px; position:fixed; top:0; right:0; background:url('<?php echo plugins_url('rightimg.png', __FILE__); ?>') no-repeat top left; z-index:1; } .orta { display:block; width:500px; height:201px; position:fixed; top:0px; left:50%; margin-left:-250px; background:url('<?php echo plugins_url('centerimg.png', __FILE__); ?>') no-repeat top left; z-index:70; overflow:hidden; cursor:pointer; } .orta span { display:block; width:100%; font-family:'Lobster Two'; text-align:center; } .orta .day { font-size:26px; font-weight:bold; color:#383131; padding-top:10px; } .orta .time { font-size:37px; font-weight:400; color:#d21027; padding-top:15px; } .red { color:#c43042; font-weight:bold; text-decoration:none; } --> </style> <div class="govde"> <div onmouseover="document.getElementById('beep-one').play()" onMouseOut="document.getElementById('beep-one').pause()" alt="Happy New Year" border="0" usemap="#happynewyear" class="solust"></div> <div onmouseover="document.getElementById('beep-one').play()" onMouseOut="document.getElementById('beep-one').pause()" alt="Happy New Year" border="0" usemap="#happynewyear" class="sagust"></div> <div onmouseover="document.getElementById('beep-one').play()" onMouseOut="document.getElementById('beep-one').pause()" alt="Happy New Year" border="0" usemap="#happynewyear" id="cntdwn" class="orta"></div> </div> <script type="text/javascript" language="javascript"> // <![CDATA[ TargetDate = "01/01/2017 00:00 AM"; BackColor = "transparent"; ForeColor = "navy"; CountActive = true; CountStepper = -1; LeadingZero = true; DisplayFormat = '<span class="day">Last %%D%% Days</span> <span class="time">%%H%%:%%M%%:%%S%%</span>'; FinishMessage = '<span class="red">Happy New Year!</span> <span class="red">Welcome to 2021</span>'; // ]]> </script> <script type="text/javascript" src="<?php echo plugins_url('time.js', __FILE__); ?>"></script> <audio style="display:none;" id="beep-one" controls="controls" preload="auto"> <source src="<?php echo plugins_url('happynewyear.mp3', __FILE__); ?>"></source> </audio> <!-- Happy New Year Plugin End --> <?php } add_action(wp_head, "happynewyear"); ?> Lines: 64, 65, 66 <?php } add_action(wp_head, "happynewyear"); ?> Versiune PHP7.3.25 Versiune MySQL5.7 Unde este incorect? Multumesc anticipat Quote
Moderators Dragos Posted December 31, 2020 Moderators Report Posted December 31, 2020 wp_head e o functie https://developer.wordpress.org/reference/functions/wp_head/. Incearca wp_head() pe linia 65 in loc de wp_head. 1 1 Quote
Wav3 Posted December 31, 2020 Report Posted December 31, 2020 (edited) add_action( string $tag, callable $function_to_add, int $priority = 10, int $accepted_args = 1 ) Deci probabil trebuie pus intre ghilimele, nu callable (adica nu cu ()). Give it a try, dar n-o lua de buna ca nu stiu WP. Edited December 31, 2020 by Wav3 3 Quote