Skip to content

Instantly share code, notes, and snippets.

View dexit's full-sized avatar
🎯
Focusing

Rihards Mantejs dexit

🎯
Focusing
View GitHub Profile
function chapel_project_metaboxes(array $meta_boxes)
{
// underscore hides meta box from custom field list
$prefix = '_chapel_';
$meta_boxes ['project_metabox'] = array(
'id' => 'project_metabox',
'title' => __('Project Overview', 'cmb2'),
'object_types' => array( 'project'),
@dexit
dexit / custom-feed-reader.php
Created December 3, 2024 16:17 — forked from panoslyrakis/custom-feed-reader.php
It will try fetch feeds with file_get_contents() instead of using simplepie
<?php
/*
Plugin Name: Custom Feed Importer
Plugin URI: https://premium.wpmudev.org/
Description: It will try fetch feeds with file_get_contents
Author: Panos Lyrakis @ WPMUDEV
Author URI: https://premium.wpmudev.org/
License: GPLv2 or later
*/
@dexit
dexit / functions.php
Created December 3, 2024 16:13 — forked from tripflex/functions.php
Customize WP Job Manager wp_editor arguments
<?php
add_filter( 'submit_job_form_wp_editor_args', 'smyles_submit_job_form_wp_editor_args' );
function smyles_submit_job_form_wp_editor_args( $args ){
// @see https://github.com/Automattic/WP-Job-Manager/blob/master/templates/form-fields/wp-editor-field.php#L2
// change quicktags to true
$args['quicktags'] = true;
// change rows to 10 (default is 8)
@dexit
dexit / index.php
Created December 3, 2024 16:13 — forked from PeterUtekal/index.php
OpenAI Functions
$response = $client->chat()->create([
'model' => 'gpt-3.5-turbo-16k-0613',
'messages' => $messages,
'functions' => [
[
'name' => 'search_job_post',
'description' => 'Search for a job based on a search query.',
'parameters' => [
'type' => 'object',
'properties' => [
@dexit
dexit / functions.php
Created November 25, 2024 17:39 — forked from coulterpeterson/functions.php
Creating custom REST endpoints in #WordPress (Custom API)
<?php
add_action('rest_api_init', 'register_rest_routes' );
function register_rest_routes(){
// URL will be /wp-json/custom-route/v1/add-list
register_rest_route( 'custom-route/v1', 'add-list',array(
'methods' => 'POST',
'callback' => array('Custom_InfusionWP', 'add_list'),
'permission_callback' => function() {
@dexit
dexit / Custom-api-route.php
Created November 25, 2024 17:39 — forked from atomjoy/Custom-api-route.php
Wordpress custom rest api routes.
<?php
/**
* Subscribe user
*/
function subscribe_user(WP_REST_Request $request) {
// $params = $request->get_params();
// $email = $params['email'];
$email = $request->get_param('email');
return [
@dexit
dexit / WP RESTAPI controller
Created November 25, 2024 17:39 — forked from ijakparov/WP RESTAPI controller
WP RESTAPI controller
class My_REST_Posts_Controller {
// Here initialize our namespace and resource name.
public function __construct() {
$this->namespace = '/my-namespace/v1';
$this->resource_name = 'posts';
}
// Register our routes.
public function register_routes() {
@dexit
dexit / wp_rest_api_endpoint_example.php
Created November 25, 2024 17:17 — forked from anthonycoffey/wp_rest_api_endpoint_example.php
WordPress REST API Custom Endpoint Example
<?php
/* 1. add function to rest_api_init hook, */
/* 2. then, call register_rest_route() function */
add_action( 'rest_api_init', 'define_endpoint');
function define_endpoint(){
register_rest_route( 'namespace', '/new/route', array(
'methods' => array('POST','GET','UPDATE','DELETE'),
'callback' => 'my_awesome_func'
) );
}
@dexit
dexit / functions.php
Created November 15, 2024 15:20 — forked from finalwebsites/functions.php
WordPress afbeeldingen: ALT tags automatisch aanmaken tijdens uploaden
<?php
// Plaats deze code in het functions.php bestand van je WordPress Child Theme
add_action( 'add_attachment', 'fws_set_image_alt_after_upload' );
function fws_set_image_alt_after_upload( $post_ID ) {
if ( wp_attachment_is_image( $post_ID ) ) {
$post = get_post( $post_ID );
update_post_meta( $post_ID, '_wp_attachment_image_alt', $post->post_title );
}
}
@dexit
dexit / functions.php
Created November 15, 2024 15:20 — forked from finalwebsites/functions.php
WordPress afbeeldingen: ALT tags automatisch aanmaken tijdens uploaden
<?php
// Plaats deze code in het functions.php bestand van je WordPress Child Theme
add_action( 'add_attachment', 'fws_set_image_alt_after_upload' );
function fws_set_image_alt_after_upload( $post_ID ) {
if ( wp_attachment_is_image( $post_ID ) ) {
$post = get_post( $post_ID );
update_post_meta( $post_ID, '_wp_attachment_image_alt', $post->post_title );
}
}