Forum Replies Created

Viewing 15 replies - 1 through 15 (of 114 total)
  • latro666

    (@latro666)

    Here is my reply to another thread on this for future searchers

    Hit this problem we need to keep the old url running though but all front facing needs the new url (convoluted intranet deployment)

    Anyway I came up with this using Yoast’s published filters. Stick this in your theme’s functions.php file and it will compare the domain of each breadcrumb to that of your WP Site url and replace if needed.

    Its not been tested massively and isn’t super efficient but it seems to do the job.

    //yoast breadcrumbs replace with site url filter
    function filter_wpseo_breadcrumb_links( $this_crumbs ) { 
    	if($this_crumbs){    
    		$liveURL = parse_url(get_option('siteurl'))['host'];		
    
    	    foreach($this_crumbs as $key => $crumb){
    	    	$url = parse_url($crumb['url']);
    			
    			if($url['host'] && $url['host'] != $liveURL){
    				$this_crumbs[$key]['url'] = str_replace($url['host'], $liveURL, $this_crumbs[$key]['url']);
    			}
    	    }    	
    	}
    	
        return $this_crumbs; 
    }
    
    add_filter( 'wpseo_breadcrumb_links', 'filter_wpseo_breadcrumb_links', 10, 1 );
    • This reply was modified 4 years ago by latro666.
    • This reply was modified 4 years ago by latro666.
    latro666

    (@latro666)

    Hit this problem we need to keep the old url running though but all front facing needs the new url (convoluted intranet deployment)

    Anyway I came up with this using Yoast’s published filters. Stick this in your theme’s functions.php file and it will compare the domain of each breadcrumb to that of your WP Site url and replace if needed.

    Its not been tested massively and isn’t super efficient but it seems to do the job.

     //yoast breadcrumbs replace with site url filter
    function filter_wpseo_breadcrumb_links( $this_crumbs ) { 
    	if($this_crumbs){    
    		$liveURL = parse_url(get_option('siteurl'))['host'];		
    
    	    foreach($this_crumbs as $key => $crumb){
    	    	$url = parse_url($crumb['url']);
    			
    		if($url['host'] && $url['host'] != $liveURL){
    		    $this_crumbs[$key]['url'] = str_replace($url['host'], $liveURL, $this_crumbs[$key]['url']);
    		}
    	    }    	
    	}
    	
        return $this_crumbs; 
    }
    
    add_filter( 'wpseo_breadcrumb_links', 'filter_wpseo_breadcrumb_links', 10, 1 );

    apologies for the indenting this editor borks all my code

    • This reply was modified 4 years ago by latro666. Reason: tried to get this to format the code better
    • This reply was modified 4 years ago by latro666.

    Confirmed, brought an entire website down. How’d this get past QA!?

    You can actually do this pretty easily with a few lines of code in pasted into your theme’s functions.php

    function my_admin_menu() {
    add_submenu_page('edit.php?post_type=page', 'My Pages', 'My Pages', 'edit_posts', 'edit.php?post_type=page&author=' . get_current_user_id(), ''); 
    }
    add_action( 'admin_menu', 'my_admin_menu' );
    • This reply was modified 7 years, 1 month ago by latro666.

    This should work in theory.

    The issue you might have is if the infection has modifed any of these posts to have dodgy JavaScript in them.

    You have to consider your theme files to be compromised too. If you are using one of the stock WP themes thats fine but if not you need to be careful.

    You have to also consider before the hacking that your theme was the route in. Especially if its a 3rd party one with complex functionality.

    The most common plugs to fill:
    – insecure plugins
    – insecure theme
    – FTP hacked
    – WP login hacked and DISALLOW_FILE_EDIT not in place

    Using something like WordFence to do a scan will help and as always the standard:
    https://codex.www.ads-software.com/FAQ_My_site_was_hacked

    • This reply was modified 7 years, 1 month ago by latro666.
    • This reply was modified 7 years, 1 month ago by latro666.
    Forum: Fixing WordPress
    In reply to: Real Time Feeds

    What is it you are trying to do integrate the java application into WordPress? or replicate what it is doing in WordPress?

    Thread Starter latro666

    (@latro666)

    okie think i have a hack with with do_action and referer but this feels more like a hack.

    function my_wp_ajax_query_attachments($pf_mime_filter) {
    	if(!isset($_REQUEST['query']['post_mime_type'])){
    		$_REQUEST['query']['post_mime_type'] = $pf_mime_filter;		
    	}	
    }
    add_action('wp_ajax_query-attachments', 'my_wp_ajax_query_attachments', 1, 1);
    
    if(strpos($_SERVER['HTTP_REFERER'], 'pf_pifs') !== false || strpos($_SERVER['HTTP_REFERER'], 'pf_documents') !== false){
    	$pf_mime_filter = 'application';
    }else{
    	$pf_mime_filter = 'image';
    }
    do_action( 'wp_ajax_query-attachments', $pf_mime_filter);
    RewriteCond %{HTTP_HOST} ^mydomain.com$
    RewriteRule ^(.*)$ https://www.mydomain.com/$1 [R=301,L]

    My htaccess is a bit shaky this might not forfil the www bit.

    Well the code above will show all before it not just those directly before so in theory you’ll always have results with the above code unless you are on your very first post.

    Oh so you want to show all previous posts to the post you are on by published date.

    $args = array(
    'post_type' => 'post',
    'posts_per_page' => -1,
    'date_query' => array(
    		array(
    			'before' => array(
    				'year'  => 2013,
    				'month' => 2,
    				'day'   => 28,
    			),
    		),
    );
    
    $the_query = new WP_Query( $args );
    if ( $the_query->have_posts() ) {
    	echo '<ul>';
    	while ( $the_query->have_posts() ) {
    		$the_query->the_post();
    		echo '<li>' . get_the_title() . '</li>';
    	}
    	echo '</ul>';
    }

    Something like that where you need to put the before and after dates in from the post you are on.

    This this will prob be:

    the_date('Y')
     the_date('m')
     the_date('d')

    https://codex.www.ads-software.com/Class_Reference/WP_Query#Date_Parameters

    Very simple normal PHP way to go about it

    define('dbhost','YOUR HOST e.g. localhost');
    define('dbname','YOUR DB NAME');
    define('dbuser','YOUR DB USERNAME');
    define('dbpass','YOUR DB PASS');
    
    $dbconn = new mysqli(dbhost, dbuser, dbpass, dbname);
    
    $mid = get_the_author_meta('ID', ID OF USER);
    $pid = get_post_field('ID', ID OF POST);
    
    $dbconn->query("INSERT INTO YOUR TABLE (YOUR FIELD FOR META ID,YOUR FIELD FOR POST ID) VALUES ('.$mid.','.$pid.';");

    You need a while loop to go over each and a way to get the user and post id you want.

    Not used a prepared query as your php version might not support it, might wanna do some int validation to avoid the very unlikely sql injection.

    Do you just need those fields in another database or are you trying to replicate a WP table entirely?

    You tried DB repair?
    wp config:
    define(‘WP_ALLOW_REPAIR’, true);

    Then
    https://www.yoursite.com/wp-admin/maint/repair.php

    Make sure its all backed up etc.

    Do you have any .htaccess redirects in place that force http to be https?

    Forum: Fixing WordPress
    In reply to: Can't login

    no worries ??

Viewing 15 replies - 1 through 15 (of 114 total)