Forum Replies Created

Viewing 15 replies - 1 through 15 (of 38 total)
  • Plugin Contributor Erin Bell

    (@ebellempire)

    Looks like you got this sorted out. From what I see, everything is working. Let me know if there’s something I’m missing.

    Thread Starter Erin Bell

    (@ebellempire)

    Here’s a screenshot of the JSON output depicting the error: https://ibb.co/R3MNdCj (auto-expiring link)

    • This reply was modified 9 months, 4 weeks ago by Erin Bell. Reason: auto-expiring link
    Thread Starter Erin Bell

    (@ebellempire)

    Answering my own question. Since register_meta() actually appends to meta, not blocks, in the JSON output, I just added a new (redundant) attribute to my block using source:meta where I can manually manage outside the attributes I use to display the block.

    
    attributes: {
      api_coordinates: {
        type: 'string',
        source: 'meta',
        meta: 'api_coordinates',
      }, //...
    }
    
    Thread Starter Erin Bell

    (@ebellempire)

    Thanks!

    
    wp.domReady( function() {
      let postType=document.querySelector('form.metabox-base-form input#post_type').value;
      if(postType=='some-type'){
        // ...
      }
    } );
    
    Thread Starter Erin Bell

    (@ebellempire)

    Awesome, cheers!

    Thread Starter Erin Bell

    (@ebellempire)

    Here’s the image: https://cl.ly/image/1k3Z0m443n3w

    Thread Starter Erin Bell

    (@ebellempire)

    Hi, the email is below. I’m using the free version of Wordfence 5.3.8 (I let my subscription lapse a couple months ago and am waiting for my department to approve a renewal).

    I ended up querying through all the database tables one at a time as suggested but a more detailed message including the name/url of the sub-site or post would be appreciated in the future if possible.

    Thanks — E

    This email was sent from your website [network site name] by the Wordfence plugin.

    Wordfence found the following new issues on [network site name].

    Alert generated at Tuesday 24th of March 2015 at 04:46:26 AM

    Critical Problems:

    * Comment with author Amir wright contains a suspected malware URL.

    [image of suspect URL]

    NOTE: You are using the free version of Wordfence. Upgrading to the paid version of Wordfence gives you two factor authentication (sign-in via cellphone) and country blocking which are both effective methods to block attacks. A Premium Wordfence license also includes remote scanning with each scan of your site which can detect several additional website infections. Premium members can also schedule when website scans occur and can scan more than once per day.

    As a Premium member you also get access to our priority support system located at https://support.wordfence.com/ and can file priority support tickets using our ticketing system.

    Click here to sign-up for the Premium version of Wordfence now.
    https://www.wordfence.com/wordfence-signup/

    The following code should work. I just tested it using one of my own custom taxonomies. Make sure that regionen (see the lowercase one used in the first line as the second parameter of the_terms() function) is actually the name of your taxonomy. If your taxonomy name is something different, you’ll need to change that.

    $regionen=the_terms( $post->ID, 'regionen', 'Regionen: ', ', ', ' ' );
     if( $regionen ) {
          $metadata .= sprintf( '<span class="meta-tags">%s %s</span><span class="sep">|</span>', __( 'Regionen:', 'Avada' ), $regionen );
     }

    Space is pretty tight in that area when the search form is expanded but you should be able to use something like:

    img.yourIconClass{
        float:right;
        display:inline-block;
    }

    You’ll need to add a class to the HTML and place the img tags right next to the div with the id of header-search (or wherever you see the get_search_form() function), for example…

    <img class="yourIconClass" src="https://bostonamigos.com/wp-content/uploads/2015/02/facebook.png" alt="facebook" width="24" height="24" />

    <img class="yourIconClass" src="https://bostonamigos.com/wp-content/uploads/2015/02/twitter.png" alt="twitter" width="24" height="24" />

    By the way, the best practice is to put those images in your theme’s images/img directory, rather than in the media manager/database.

    Thread Starter Erin Bell

    (@ebellempire)

    FYI, I did some tooling around and found that this is what worked best. For what it’s worth, I think it was only saving when an auto-save has been instantiated first. Not sure what that’s about.

    <?php
    // Helpers
    function as_nonce($str){
    	return $str.'_nonce';
    }
    
    function as_fieldname($str){
    	return $str.'_meta';
    }
    
    /* Fire our meta box setup function on the post editor screen. */
    add_action( 'load-post.php', 'eb_post_meta_boxes_setup' );
    add_action( 'load-post-new.php', 'eb_post_meta_boxes_setup' );
    
    /* Meta box setup function. */
    function eb_post_meta_boxes_setup() {
    
      /* Add meta boxes on the 'add_meta_boxes' hook. */
      add_action( 'add_meta_boxes', 'custom_metaboxes' );
    
      /* Save post meta on the 'save_post' hook. */
      add_action( 'save_post', 'custom_metaboxes_save', 10, 2 );
    
    }
    
    // Register the Metaboxes
    function custom_metaboxes() {
    
    	$metaboxes=custom_metaboxes_array();
    	foreach($metaboxes as $m){
    		$context= ($m['type']=='checkbox') ? 'side' : 'normal';
    		$priority= ($m['type']=='checkbox') ? 'default' : 'high';
    		add_meta_box(
    			as_fieldname($m['name']),
    			__( $m['label'], 'ccms_plugin_textdomain' ),
    			'custom_metaboxes_callback',
    			$m['post_type'],
    			$context,
    			$priority,
    			array('metadata'=>$m)
    		);
    	}
    
    }
    
    // Build the Metabox Forms
    function custom_metaboxes_callback( $post, $metabox ) {
    
    	$m=$metabox['args']['metadata'];
    	$nonce_name=as_nonce($m['name']);
    	$fieldname=as_fieldname($m['name']);
    	$description=$m['description'];
    	$label=$m['label'];
    	$box_type=$m['type'];
    
    	$post_id=$post->ID;
    
    	wp_nonce_field( basename( __FILE__ ), $nonce_name );
    
    	$value = get_post_custom( $post->ID );
    
        // Text
        if($box_type=='text'){
    	    ?>
    	    <div class="custom-metabox">
    	        <label for="<?php echo $fieldname;?>" class="hidden">
    	        	<?php echo $label; ?>
    	        </label>
    
    	        <input style="min-width:20em;" type="text" name="<?php echo $fieldname;?>" id="<?php echo $fieldname;?>" value="<?php echo isset($value[$fieldname][0]) ? esc_attr($value[$fieldname][0]) : '';?>" />
    
    	        <div class="description <?php echo $fieldname;?>">
    		        <em><?php echo $description?></em>
    		    </div>
    	    </div>
    	    <?php
    	// Textarea
    	}elseif($box_type=='textarea'){
    		?>
    		<div class="custom-metabox">
    		    <label for="<?php echo $fieldname;?>" class="hidden">
    		    	<?php echo $label; ?>
    		    </label>
    
    		    <textarea style="width:98%;min-height:4em;" name="<?php echo $fieldname;?>" id="<?php echo $fieldname;?>">
    		    	<?php echo isset($value[$fieldname][0]) ? esc_attr($value[$fieldname][0]) : '';?>
    		    </textarea>
    
    		    <div class="description <?php echo $fieldname;?>">
    			    <em><?php echo $description;?></em>
    			</div>
    		</div>
    		<?php
    	}else{
    		echo 'Oops! Something went wrong. Make sure the type listed in custom_metaboxes_array() is valid (currently only text and textarea are supported).';
    	}
    }
    
    function custom_metaboxes_save( $post_id ) {
    
    	$metaboxes=custom_metaboxes_array();
    	foreach($metaboxes as $m){	
    
    		$nonce_name=as_nonce($m['name']);
    		$fieldname=as_fieldname($m['name']);
    
    	    // Checks save status
    	    $is_autosave = wp_is_post_autosave( $post_id );
    	    $is_revision = wp_is_post_revision( $post_id );
    	    $is_valid_nonce = ( isset( $_POST[ $nonce_name ] ) && wp_verify_nonce( $_POST[ $nonce_name ], basename( __FILE__ ) ) ) ? 'true' : 'false';
    
    	    // Exits script depending on save status
    	    if ( $is_autosave || $is_revision || !$is_valid_nonce ) {
    	        return;
    	    }
    
    	    // Checks for input and sanitizes/saves if needed
    	    if( isset( $_POST[ $fieldname ] ) ) {
    	        update_post_meta( $post_id, $fieldname, sanitize_text_field( $_POST[ $fieldname ] ) );
    	    }
    
    	}
    
    }

    Ah, ok. You could try using the_terms rather than get_the_terms.

    $regionen=the_terms( $post->ID, 'regionen', 'Regionen: ', ', ', ' ' );
         if( $regionen ) {
              $metadata .= sprintf( '<span class="meta-tags">%s %s</span><span class="sep">|</span>', __( 'Regionen:', 'Avada' ), $regionen );
         }

    Otherwise, I think you’d need to just implode that array.

    $regionen=get_the_terms( $post->ID, 'regionen');
         if( $regionen ) {
              $r=implode(", ", $regionen)
              $metadata .= sprintf( '<span class="meta-tags">%s %s</span><span class="sep">|</span>', __( 'Regionen:', 'Avada' ), $r );
         }

    See: https://us3.php.net/manual/en/function.implode.php

    So in the avada_render_post_metadata() function, this is where the tags are added (around line 1183):

    if( ! $smof_data['post_meta_tags'] ) {
         ob_start();
         the_tags( '' );
         $tags = ob_get_clean();
         if( $tags ) {
              $metadata .= sprintf( '<span class="meta-tags">%s %s</span><span class="sep">|</span>', __( 'Tags:', 'Avada' ), $tags );
         }
    }

    You’d want to add your custom taxonomy right before that if statement, which would put it between the categories and tags on your page.

    Maybe try something like this (untested):

    $regionen=get_the_terms( $post->ID, 'regionen', 'Regionen: ', ', ', ' ' );
         if( $regionen ) {
              $metadata .= sprintf( '<span class="meta-tags">%s %s</span><span class="sep">|</span>', __( 'Regionen:', 'Avada' ), $regionen );
         }

    See: https://codex.www.ads-software.com/Taxonomies#Using_that_taxonomy

    Thread Starter Erin Bell

    (@ebellempire)

    UPDATE: I notice that my custom meta does save for default post types, just not the custom ones.

    You may have two potential issues. The first is that you probably just need to wait for the DNS changes to propagate through your local ISP (which can take a while, especially if you’re on a campus or have a small service provider). If it works properly over 3G, though, it should eventually work everywhere.

    The second issue, if I’m understanding correctly, could be related to the above or you might simply need to update your site location in MySQL using PHPMyAdmin (e.g. see in wp_options table: site_url and home).

    Thread Starter Erin Bell

    (@ebellempire)

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