Skip to content

Instantly share code, notes, and snippets.

@cloudinstone
cloudinstone / WooCommerceProductUpdateHelper.php
Created February 28, 2025 15:37
WooCommerceProductUpdateHelper
<?php
namespace Semrock;
use WC_Product_Attribute;
class WooCommerceProductUpdateHelper
{
/**
* Update product attributes for a WooCommerce product
@cloudinstone
cloudinstone / Makefile
Last active March 5, 2025 12:16
wp plugin makefile
PLUGIN_NAME = $(word $(words $(subst /, ,$(CURDIR))),$(subst /, ,$(CURDIR)))
PLUGIN_DIR = $(CURDIR)
LANG_DIR = $(PLUGIN_DIR)/languages
# print variables to make sure they are correct
print:
@echo CURDIR: $(CURDIR)
@echo PLUGIN_NAME: $(PLUGIN_NAME)
@echo PLUGIN_DIR: $(PLUGIN_DIR)
@echo LANG_DIR: $(LANG_DIR)
@cloudinstone
cloudinstone / wp-theme-style.css
Last active February 12, 2025 07:37
wp theme style.css header
/*
Theme Name: Twenty Twenty
Theme URI: https://wordpress.org/themes/twentytwenty/
Author: the WordPress team
Author URI: https://wordpress.org/
Description: Our default theme for 2020 is designed to take full advantage of the flexibility of the block editor. Organizations and businesses have the ability to create dynamic landing pages with endless layouts using the group and column blocks. The centered content column and fine-tuned typography also makes it perfect for traditional blogs. Complete editor styles give you a good idea of what your content will look like, even before you publish. You can give your site a personal touch by changing the background colors and the accent color in the Customizer. The colors of all elements on your site are automatically calculated based on the colors you pick, ensuring a high, accessible color contrast for your visitors.
Tags: blog, one-column, custom-background, custom-colors, custom-logo, custom-menu, editor-style, featured-images, footer-widgets, full-width-template
@cloudinstone
cloudinstone / ExternalImageHelper.php
Last active February 16, 2025 09:06
ExternalImageHelper.php
<?php
namespace SC\IT205\ExternalImages;
use WP_Error;
use WP_Query;
if (!function_exists('download_url')) {
require_once ABSPATH . 'wp-admin/includes/file.php';
require_once ABSPATH . 'wp-admin/includes/image.php';
@cloudinstone
cloudinstone / cursor-rules.md
Last active March 14, 2025 07:03
cursor-rules.md

Always respond code in English.

我的知识是有限的,当我想实现的功能有更好的方案时,请向我建议更好的方案供我确认,而不是单纯按照我的指示去完成任务

  • 文件的组织要清晰

所有代码:

  • 只使用英文写代码。解释和沟通可以用中文。
  • 遵循每种语言的官方代码规范,和社区的最佳实践
@cloudinstone
cloudinstone / wp-plugin-header.php
Last active February 23, 2025 16:48
WordPress Plugin Header
<?php
/**
* (dp) PLUGIN_NAME
*
* @package DressPress\PLUGIN_NAME
* @author DressPress
* @copyright DressPress
* @license GPL-2.0-or-later
*
@cloudinstone
cloudinstone / Autoloader.php
Last active July 12, 2024 23:51
PHP Autoloader Class.
<?php
namespace DressPress;
final class Autoloader
{
private $namespace;
private $filepath;
public function __construct(string $namespace, string|null $filepath = null, bool $throw = true, bool $prepend = false)