Skip to content

Instantly share code, notes, and snippets.

Avatar
🔨
Working

Kevin Pliester pixelbart

🔨
Working
View GitHub Profile
@pixelbart
pixelbart / functions.php
Created Mar 22, 2021
Disable Helpful in a specific term of a taxonomy
View functions.php
<?php
/**
* Disable helpful on new posts with specific term of taxonomy.
*
* @param int $post_id
* @param WP_Post $post
* @param bool $update
*
* @return void
@pixelbart
pixelbart / functions.php
Last active Jul 28, 2021
WooCommerce REST API: Random sorting for products and other post types.
View functions.php
<?php // functions.php
/**
* rest_{post_type}_collection_params
*
* @param array $params
* @return array
*/
add_filter( 'rest_product_collection_params', function ( $params ) {
$params['orderby']['enum'][] = 'rand';
@pixelbart
pixelbart / functions.php
Created Aug 27, 2020
Enables you to enter votes for the Helpful WordPress Plugin. The votes count as real votes!
View functions.php
<?php // functions.php
/**
* Start Value
*/
$amount = 300;
/**
* Helpful Post Types set in the Helpful settings.
*/
@pixelbart
pixelbart / readme.md
Created Aug 13, 2020
Using Helpful WordPress Plugin on archive pages
View readme.md

Using Helpful on archive pages

With these two scripts Helpful can be used as short code on archive pages. Place the code in your functions.php to make it work.

In the first script the_content is manipulated and in the second script the_excerpt. Use what you have in use.

Quick tip: Use get_post_type( $post ) to check if a particular post type is in use.

@pixelbart
pixelbart / like_linkedin_post.js
Created Aug 13, 2020
Click on the Like button on all visible posts by Linkedin - just paste it into your browser console
View like_linkedin_post.js
document.querySelectorAll('.feed-shared-social-actions').forEach(function(element) {
if ("true" !== element.children[0].children[0].getAttribute('aria-pressed')) {
element.children[0].children[0].click();
}
});
@pixelbart
pixelbart / functions.php
Last active Aug 11, 2020
Helpful Plugin: Anker zum Formular
View functions.php
<?php // functions.php
/**
* Fügt Helpful eine ID hinzu.
*
* @param string $content
*
* @return string
*/
add_filter( 'the_content', function( $content ) {
@pixelbart
pixelbart / chosen.less
Created Aug 6, 2020
Easy Less conversion of the Chosen jQuery plugin.
View chosen.less
.chosen-container {
width: 100%;
max-width: 100%;
position: relative;
display: inline-block;
vertical-align: middle;
font-size: 13px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
@pixelbart
pixelbart / coreDIRSEPmodulesDIRSEPclass-my-class.php
Last active Jun 15, 2020
WordPress Plugin: A plugin which includes or autoloads classes with namespaces.
View coreDIRSEPmodulesDIRSEPclass-my-class.php
<?php
/**
* An example class in the subfolder: core/modules/core.php
*/
namespace NAMESPACE\Core\Modules;
class My_Class
{
/**
* Saves an instance of the class.
@pixelbart
pixelbart / style.css
Created Jun 5, 2020
CSS: Use Font Awesome 5 Free and the correct font family
View style.css
/**
* https://fontawesome.com/icons/long-arrow-alt-right?style=solid
*/
.long-arrow-alt-right:after {
content: "\f30b";
font-weight: 900;
font-family: "Font Awesome\ 5 Free";
}
@pixelbart
pixelbart / database.php
Created May 7, 2020
Helper for WordPress database.
View database.php
<?php
/**
* Helper for WordPress database.
*
* @author Pixelbart
*/
class Database_Helpers
{
/**
* Checks if a database exists.