Skip to content

Instantly share code, notes, and snippets.

View taotiwordpress's full-sized avatar

taotiwordpress

View GitHub Profile
@taotiwordpress
taotiwordpress / options.php
Last active March 4, 2022 21:49
[Add options page functionality (and for custom post types )] #php #acf #acf-options #options-page
if ( function_exists( 'acf_add_options_page' ) ) {
/**
* Example: Single 'Theme Settings' page, with children
*
* These only create the pages, which must be then populated via custom ACF fields.
* This setup creates a 'parent' ACF config page and sub-pages.
*/
acf_add_options_page(
array(
'page_title' => 'Theme General Settings',
@taotiwordpress
taotiwordpress / share.php
Created August 26, 2020 19:12
[share functionality] simple share functionality snippet #html #php
<a href="https://www.facebook.com/sharer.php?u=<?php the_permalink();?>">
<svg xmlns="http://www.w3.org/2000/svg" width="8" height="15" viewBox="0 0 8 15">
<path id="Color_Overlay" data-name="Color Overlay"
d="M2.357,15V8.166H0V5.493H2.363V3.525A3.255,3.255,0,0,1,5.885,0,19.38,19.38,0,0,1,8,.107V2.493H6.557c-1.141,0-1.361.525-1.361,1.3v1.7H7.92L7.566,8.166H5.2V15Z"
fill="#4a3b03" />
</svg>
</a>
<a href="https://twitter.com/share?url=<?php the_permalink();?>&text=<?php the_title();?>">
<svg xmlns="http://www.w3.org/2000/svg" width="17" height="15" viewBox="0 0 17 15">
<path id="Color_Overlay" data-name="Color Overlay"
@taotiwordpress
taotiwordpress / accordion.js
Last active August 26, 2020 19:15
[accordion block] accordion page builder #pagebuilder #php
var $toggle = jQuery('.accordion-toggle'),
$accordionText = jQuery('.accordion-descriptionText');
$toggle.on('change', function() {
jQuery(this).parent().find( $accordionText ).toggleClass('active');
});
@taotiwordpress
taotiwordpress / textBlock.php
Created August 26, 2020 19:02
[text-block] Page builder text block module #pagebuilder
<?php
namespace Modules;
use Timber;
### Example usage
// $args = [
// 'text_block' => get_sub_field('text_block'),
// ];
// $new_module = new TextBlock($args);
// $new_module->render();
@taotiwordpress
taotiwordpress / helper-functions.php
Last active August 26, 2020 17:31
[lorium ipson populate acf text field] function to populate acf fields #php #acf
function field_with_ipsum_fallback( $text ) {
if ( ! empty( $text ) ) {
echo $text;
} else {
echo 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque pellentesque risus vel venenatis faucibus. Nam id pharetra nisl. Nullam viverra eu nisi vel placerat. Donec faucibus blandit dictum';
}
}
function heading_with_ipsum_fallback( $heading ) {
if ( ! empty( $heading ) ) {
echo $heading;
@taotiwordpress
taotiwordpress / api.php
Created August 24, 2020 17:43
[apit insert posts] link to api and create posts in CPT #api #php
<?php
function insert_from_api() {
if(isset($_GET['input'])) {
// API URL
$url = '';
// Create a new cURL resource