PHP code example of cuberis / wp-componify

1. Go to this page and download the library: Download cuberis/wp-componify library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

cuberis / wp-componify example snippets


 while (have_posts()) : the_post(); 

/**
 * Example for modifying component wrapper attributes.
 *
 * @param array $attrs
 * @param string $slug
 * @return $attrs
 */
function cuberis_filter_component_html_attributes($attrs, $slug) {
  // Add a class modifier to just the text component.
  if ($slug === 'text') {
    $attrs['class'] .= ' component--example-modifier';
  }

  // Add a new attribute to all components.
  $attrs['data-id'] = uniqid();

  return $attrs;
}
add_filter('cuberis_set_component_html_attributes', 'cuberis_filter_component_html_attributes', 10, 2);