Custom admin plugin read CSV

$_SERVER[‘DOCUMENT_ROOT’] should get you taken care of. Check this out: <?php echo ‘Initializing Script…<br>’; $filepath = $_SERVER[‘DOCUMENT_ROOT’].”/data/clients.csv”; echo “the file we seek:”.$filepath.”<br>”; $handle = fopen($filepath, “r”) or die(“Error opening file”); $i = 0; while(($line = fgetcsv($handle)) !== FALSE) { if($i == 0) { $c = 0; foreach($line as $col) { $cols[$c] = $col; $c++; } … Read more

Make another copy of a plugin and install it

Most probably you haven’t changed all IDs inside that plugin. For example, when you register admin menu page, you have to pass its slug, which is unique identifier for that page. If you register two pages with the same slug, only one will be visible. It’s the same with registering options, custom post types, and … Read more

WordPress plugin how to run function when button is clicked

Create form or link with action=”my_media_update” <form action=”<?php echo admin_url(‘admin-post.php’); ?>” method=”post”> <input type=”hidden” name=”action” value=”my_media_update”> <input type=”submit” value=”Update Media Titles and ALT Text”> </form> Add this function and hook in your plugin file: public function kh_update_media_seo() { //update media files title and alt tags here // // at the end redirect to target page … Read more

Integrating colorpicker into array field

Real quick this should point you in the right direction, you need to define your colorpicker and then reference it, so like: switch( $arguments[‘type’] ){ case ‘text’: case ‘password’: case ‘number’: printf( ‘<input name=”%1$s” id=”%1$s” type=”%2$s” placeholder=”%3$s” value=”%4$s” />’, $arguments[‘uid’], $arguments[‘type’], $arguments[‘placeholder’], $value ); break; case ‘colorpicker’: printf( ‘<input name=”%1$s” id=”%1$s” type=”%2$s” placeholder=”%3$s” value=”%4$s” />’, … Read more

Custom plugin which downloads updates from custom endpoint, extracts new version zip into a new name

Thanks Tom J Nowell! That led me down the right direction and I’ve been able to update successfully. Here’s what I did: Re-structured my repo to match: |– .git |– .gitattributes |– .gitignore |– README.md |– package.json |– plugin-name |– plugin-name.php |– src |– … Code new version in a new branch, merge into master … Read more

The Events Calendar featured image as body background?

<?php $id = get_the_ID(); if (has_post_thumbnail( $id ) ): $thumb = get_the_post_thumbnail_url($id, ‘full’); elseif (tribe_event_featured_image( $id)): $thumb = tribe_event_featured_image( $event_id, ‘large’, false, false ); else: $thumb = get_template_directory_uri().’/images/background.jpg’; endif;?> <body <?php body_class(); ?> style=”background-image: url(‘<?php echo $thumb;?>’); background-size: cover;”> ?> Also you don’t actually need the elseif statement, tribe_event_featured_image is a wrapper for the post … Read more