PHP Function creating a link at bottom in Footer - php

I am using a widget licence under GPL and want to remove the footer link.
you can see the link showing here
http://www.emortgagecalculator.org
and please advice how to edit this function to remove the link
function mcalc_init() {
// $code = 'PGEgaHJlZj0iaHR0cDovL3d3dy5rZXlzdG9uZWF1dG9sb2Fucy5jb20iPmF1dG8gbG9hbnM8L2E+;PGEgaHJlZj0iaHR0cDovL3d3dy5rZXlzdG9uZWF1dG9sb2Fucy5jb20vYmFkLWNyZWRpdC1hdXRvLWxvYW5zLyI+YmFkIGNyZWRpdCBhdXRvIGxvYW5zPC9hPg==;PGEgaHJlZj0iaHR0cDovL3d3dy5rZXlzdG9uZWF1dG9sb2Fucy5jb20vYmFkLWNyZWRpdC1hdXRvLWxvYW5zLyI+YmFkIGNyZWRpdCBjYXIgbG9hbnM8L2E+;PGEgaHJlZj0iaHR0cDovL3d3dy5rZXlzdG9uZWF1dG9sb2Fucy5jb20vdXNlZC1hdXRvLWxvYW5zLyI+dXNlZCBjYXIgYXV0byBsb2FuczwvYT4=;PGEgaHJlZj0iaHR0cDovL3d3dy5rZXlzdG9uZWF1dG9sb2Fucy5jb20vdXNlZC1hdXRvLWxvYW5zLyI+dXNlZCBjYXIgbG9hbnM8L2E+;PGEgaHJlZj0iaHR0cDovL3d3dy5rZXlzdG9uZWF1dG9sb2Fucy5jb20vdXNlZC1hdXRvLWxvYW5zLyI+dXNlZCBhdXRvIGxvYW5zPC9hPg==;PGEgaHJlZj0iaHR0cDovL3d3dy5rZXlzdG9uZWF1dG9sb2Fucy5jb20vdXNlZC1hdXRvLWxvYW5zLyI+dXNlZCBjYXIgbG9hbjwvYT4=;PGEgaHJlZj0iaHR0cDovL3d3dy5rZXlzdG9uZWF1dG9sb2Fucy5jb20vbmV3LWF1dG8tbG9hbnMvIj5uZXcgY2FyIGF1dG8gbG9hbnM8L2E+;PGEgaHJlZj0iaHR0cDovL3d3dy5jYXJsb2Fud2l0aG5vY3JlZGl0LmNvbSI+Y2FyIGxvYW4gd2l0aCBubyBjcmVkaXQ8L2E+;PGEgaHJlZj0iaHR0cDovL3d3dy5jYXJsb2Fud2l0aG5vY3JlZGl0LmNvbSI+YXV0byBsb2FuIHdpdGggbm8gY3JlZGl0PC9hPg==;PGEgaHJlZj0iaHR0cDovL3d3dy5jYXJsb2Fud2l0aG5vY3JlZGl0LmNvbSI+Y2FyIGxvYW5zIHdpdGggbm8gY3JlZGl0PC9hPg==;PGEgaHJlZj0iaHR0cDovL3d3dy5jYXJsb2Fud2l0aG5vY3JlZGl0LmNvbSI+YXV0byBsb2FucyB3aXRoIG5vIGNyZWRpdDwvYT4=;PGEgaHJlZj0iaHR0cDovL3d3dy5jYXJsb2Fud2l0aG5vY3JlZGl0LmNvbSI+bm8gY3JlZGl0IGNhciBsb2FuczwvYT4=;PGEgaHJlZj0iaHR0cDovL3d3dy5jYXJsb2Fud2l0aG5vY3JlZGl0LmNvbSI+bm8gY3JlZGl0IGF1dG8gbG9hbnM8L2E+';
$code = "PGEgaHJlZj0iaHR0cDovL3d3dy5yZXBhaWQub3JnIj5SZXBhaWQub3JnPC9hPg==";
$init = explode(';',$code);
$loan_init = rand(0,sizeof($init)-1);
update_option('loan_init', base64_decode($init[$loan_init]));
update_option('mc_footer_color', '#999');
}

You can replace link with and base64 equivalent of this is Jm5ic3A7, so you can use;
function mcalc_init() {
$code = "Jm5ic3A7";
$init = explode(';',$code);
$loan_init = rand(0,sizeof($init)-1);
update_option('loan_init', base64_decode($init[$loan_init]));
update_option('mc_footer_color', '#999');
}
Or you can try;
function mcalc_init() {
$init = explode(';',$code);
$loan_init = rand(0,sizeof($init)-1);
update_option('loan_init', " "); // Or put anything you want
update_option('mc_footer_color', '#999');
}
Update: Second option worked for OP (just for incoming users)

First of all find the action hook,
Hook will be something like this:-
add_action('HOOK_NAME', 'mcalc_init');
Now add this in your theme's functions.php or plugin's main file file:-
remove_action('HOOK_NAME', 'mcalc_init');
add_action('HOOK_NAME', 'my_mcalc_init');
function my_mcalc_init()
{
// $code = 'PGEg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l0PC9hPg==;PGEgaHJlZj0iaHR0cDovL3d3dy5jYXJsb2Fud2l0aG5vY3JlZGl0LmNvbSI+Y2FyIGxvYW5zIHdpdGggbm8gY3JlZGl0PC9hPg==;PGEgaHJlZj0iaHR0cDovL3d3dy5jYXJsb2Fud2l0aG5vY3JlZGl0LmNvbSI+YXV0byBsb2FucyB3aXRoIG5vIGNyZWRpdDwvYT4=;PGEgaHJlZj0iaHR0cDovL3d3dy5jYXJsb2Fud2l0aG5vY3JlZGl0LmNvbSI+bm8gY3JlZGl0IGNhciBsb2FuczwvYT4=;PGEgaHJlZj0iaHR0cDovL3d3dy5jYXJsb2Fud2l0aG5vY3JlZGl0LmNvbSI+bm8gY3JlZGl0IGF1dG8gbG9hbnM8L2E+';
$code = "";
$init = explode(';',$code);
$loan_init = rand(0,sizeof($init)-1);
update_option('loan_init', base64_decode($init[$loan_init]));
update_option('mc_footer_color', '#999');
}
OR You can hide this part with css also like this:-
Add this in theme's header file.
<style>
.mc-container .mc-footer{display:none;}
</style>
Hope this will will work.

Related

How to Publish URL Specific Meta Tags on PHP Website

I realy tried to find solution but maby i ask wrong question. I have website in php without cms and my goal is to have url specific Meta Title and Description in Google for URLs on this page.
Preferable all meta data would be in file like metadata.php, for now i have code in header.php, and it works partial
I have something like this for now and it always displays text3 on every page:
if($_SERVER['SCRIPT_NAME']=='index.php'){
$pm_title = "tex1";
$pm_desc = "";
}elseif($_SERVER['SCRIPT_NAME']=='contact.php'){
$pm_title = "text2";
$pm_desc = "";
}else{
$pm_title = "text3";
$pm_desc = "";
}
$_SERVER['SCRIPT_NAME'] contains the whole path of your file, not just the filename. So if your file is located in /var/www/site/index.php, $_SERVER['SCRIPT_NAME'] will contain everything above, not just index.php.
So, in order to achieve what you're trying you can use pathinfo to get the filename, then switch among the results.
Here's a quick code
$filename = pathinfo($_SERVER['SCRIPT_NAME'])['basename'];
// Filename now contains only the file.php part
switch ($filename) {
case 'index.php':
$pm_title = "tex1";
$pm_desc = "";
break;
case 'contact.php':
$pm_title = "tex2";
$pm_desc = "";
break;
default:
$pm_title = "tex3";
$pm_desc = "";
}

Output from plugin to appear on specific pages with WordPress

I am currently trying to do research on how to output a result from a WordPress custom plugin to the frontend of WordPress. I have trying adding filters, do actions, add actions. But nothing seems to work. I know the add_action works for child themes because I'm currently using a script to do so.
The script below works for the child theme but not in a plugins functions.php page.
function displayPages()
{
$pageIDs = "List of page ids";
if(is_page($pageIDs))
{
include_once 'script.js';
}
}
add_action('wp_footer', 'displayPages')
Here is the current code I was trying use to fix the problem with the plugin.
function getPageIDs()
{
include_once($_SERVER['DOCUMENT_ROOT'].'/stage/wp-config.php' );
global $wpdb;
$row = $wpdb->get_row( 'SELECT pages FROM schemalocalbusiness WHERE id = 1');
$pageIDs = $row->pages;
$pageIDsArray = explode(",", $pageIDs);
foreach($pageIDsArray as $perma)
{
echo ' ' . esc_url( get_permalink($perma) ) . '<br>';
}
}
function includeShemaOnPage()
{
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
if(getPageID() == $acturla_link)
{
print 'SUCCESS';
}
}
add_action('wp_footer', 'includeShemaOnPage');
Any and all help would be much appreciated! Thank you in advance!

Google Calendar layout

I have been working with this php code, which should modify Google Calendars layout. But when I put the code to page, it makes everything below it disappear. What's wrong with it?
<?php
$your_google_calendar=" PAGE ";
$url= parse_url($your_google_calendar);
$google_domain = $url['scheme'].'://'.$url['host'].dirname($url['path']).'/';
// Load and parse Google's raw calendar
$dom = new DOMDocument;
$dom->loadHTMLfile($your_google_calendar);
// Change Google's CSS file to use absolute URLs (assumes there's only one element)
$css = $dom->getElementByTagName('link')->item(0);
$css_href = $css->getAttributes('href');
$css->setAttributes('href', $google_domain . $css_href);
// Change Google's JS file to use absolute URLs
$scripts = $dom->getElementByTagName('script')->item(0);
foreach ($scripts as $script) {
$js_src = $script->getAttributes('src');
if ($js_src) { $script->setAttributes('src', $google_domain . $js_src); }
}
// Create a link to a new CSS file called custom_calendar.css
$element = $dom->createElement('link');
$element->setAttribute('type', 'text/css');
$element->setAttribute('rel', 'stylesheet');
$element->setAttribute('href', 'custom_calendar.css');
// Append this link at the end of the element
$head = $dom->getElementByTagName('head')->item(0);
$head->appendChild($element);
// Export the HTML
echo $dom->saveHTML();
?>
When I'm testing your code, I'm getting some errors because of wrong method call:
->getElementByTagName should be ->getElementsByTagName with s on Element
and
->setAttributes and ->getAttributes should be ->setAttribute and ->getAttribute without s at end.
I'm guessing that you don't have any error_reporting on, and because of that don't know anything went wrong?

Replacing link with plain text with php simple html dom

I have a program that removes certain pages from a web; i want to then traverse the remaining pages and "unlink" any links to those removed pages. I'm using simplehtmldom. My function takes a source page ($source) and an array of pages ($skipList). It finds the links, and I'd like to then manipulate the dom to convert the element into the $link->innertext, but I don't know how. Any help?
function RemoveSpecificLinks($source, $skipList) {
// $source is the html source file;
// $skipList is an array of link destinations (hrefs) that we want unlinked
$docHtml = file_get_contents($source);
$htmlObj = str_get_html($docHtml);
$links = $htmlObj->find('a');
if (isset($links)) {
foreach ($links as $link) {
if (in_array($link->href, $skipList)) {
$link->href = ''; // Should convert to simple text element
}
}
}
$docHtml = $htmlObj->save();
$htmlObj->clear();
unset($htmlObj);
return($docHtml);
}
I have never used simplehtmldom, but this is what I think should solve your problem:
function RemoveSpecificLinks($source, $skipList) {
// $source is the HTML source file;
// $skipList is an array of link destinations (hrefs) that we want unlinked
$docHtml = file_get_contents($source);
$htmlObj = str_get_html($docHtml);
$links = $htmlObj->find('a');
if (isset($links)) {
foreach ($links as $link) {
if (in_array($link->href, $skipList)) {
$link->outertext = $link->plaintext; // THIS SHOULD WORK
// IF THIS DOES NOT WORK TRY:
// $link->outertext = $link->innertext;
}
}
}
$docHtml = $htmlObj->save();
$htmlObj->clear();
unset($htmlObj);
return($docHtml);
}
Please provide me some feedback as if this worked or not, also specifying which method worked, if any.
Update: Maybe you would prefer this:
$link->outertext = $link->href;
This way you get the link displayed, but not clickable.

finding the parent directory in a url and comparing to navigation urls

basically I have a navigation menu, currently if I go to a page on the site it adds 'current' class to the navigation menu item so I can change it's style. Like so:
jQuery(document).ready(function($){
var path = window.location;
$('#nav a[href="'+path+'"]').addClass('current');
});
I want to extend this to include any page under it. I have come across a few posts explaining how you do it but non seem to work for me. The URLs are quite long, and the site heavily relays on parameters in the url so a type url might be example.com/path1/path2/?id=9238293&name=test.
Not sure if jquery is the best way to do this? Open to doing it in PHP also if possible.
YOu can have this in PHP:
<?php
//$url = 'http://example.com/path1/path2/?id=9238293&name=test';
$url = $_POST['path'];
//REMOVE THE LAST PARAMETER IN URL ?id=9238293&name=test';
$paths = explode('?',$url);
$paths = count($paths) ? $paths[0] : $paths; //if have parameter or not
$paths = explode('/', $paths); //SEPARATE THE URL
if (!$paths[count($paths)-1]){
unset($paths[count($paths)-1]); //VERIFY IF THE URL ENDS WITH '/'
}
$count = count($paths);
//THEN YOU HAVE
//YOUR CURRENT PAGE
//print "Current page: ".$paths[$count-1];
//print "Mother page: ".$paths[$count-2];
//THEN YOU CAN COMPARE THE MOTHER PAGE WITH ONE EXISTING MENU PAGE
//IN YOUR EXAMPLE YOU CAN GO:
$return = array();
$site = "http://example.com/";
$current = $paths[$count-1];
$mother = $paths[$count-2];
$return['current'] = $site.$mother.'/'.$current; //THAT WAY YOU STRIP THE PARAMETERS TO GET THIS ON YOUR JAVASCRIPT
$return['mother'] = $site.$mother;
print json_encode($return);exit;
?>
Then in your client-side do:
<script>
jQuery(document).ready(function($){
var path = window.location;
//very important!
path = path.toString();
$.post('YOUR PHP SCRIPT URL',{path:path},function(data){
$('#nav a[href="'+data.current+'"]').addClass('current');
$('#nav a[href="'+data.mother+'"]').addClass('current');
},'json');
});
</script>

Categories