Skip to content

Instantly share code, notes, and snippets.

View hissy's full-sized avatar
💭
😄

Takuro Hishikawa hissy

💭
😄
View GitHub Profile
@hissy
hissy / gist:5113780
Created March 8, 2013 02:30
[WordPress] include author's name in query search
<?php
function custom_search_join( $join ) {
global $wpdb;
if( is_search() ) {
$join .= " INNER JOIN $wpdb->users ON "
. "$wpdb->posts.post_author = $wpdb->users.ID ";
}
return $join;
}
function custom_search_where( $where, $query ) {
@hissy
hissy / fix-font-size.css
Created March 19, 2024 02:24
[Concrete CMS] バージョン9対応 html 要素に font-size: 0.625rem が入っている時の対応CSSスニペット
body .ccm-ui dl,
body .ccm-ui dt,
body .ccm-ui dd,
body .ccm-ui ol,
body .ccm-ui ul,
body .ccm-ui li,
body .ccm-ui p,
body .ccm-ui th,
body .ccm-ui td,
body .ccm-ui a,
@hissy
hissy / output.md
Last active March 7, 2024 21:53
#concrete5 Complete usage and output of Date Helper to localize date time format
$dh = Core::make('helper/date');
Code en_US ja_JP it_IT ru_RU zh_CN
echo $dh->formatDateTime($date); 10/31/19, 5:06 PM 2019/10/31 17:06 31/10/19, 17:06 31.10.2019, 17:06 2019/10/31 下午5:06
echo $dh->formatDateTime($date, true); Oct 31, 2019, 5:06 PM 2019/10/31 17:06 31 ott 2019, 17:06 31 окт. 2019 г., 17:06 2019年10月31日 下午5:06
echo $dh->formatDateTime($date, false, true); 10/31/19, 5:06:38 PM 2019/10/31 17:06:38 31/10/19, 17:06:38 31.10.2019, 17:06:38 2019/10/31 下午5:06:38
echo $dh->formatDateTime($date, true, true); Oct 31, 2019, 5:06:38 PM 2019/10/31 17:06:38 31 ott 2019, 17:06:38 31 окт. 2019 г., 17:06:38 2019年10月31日 下午5:06:38
@hissy
hissy / Updater.php
Last active January 6, 2024 14:00
Concrete CMS: A helper class to install CIF format xml files without duplicated run
<?php
namespace Acme\Updater;
use Concrete\Core\Entity\Package as PackageEntity;
use Concrete\Core\Package\Package;
use Symfony\Component\Finder\Finder;
class Updater
{
@hissy
hissy / app.php
Last active December 24, 2023 23:57
[Concrete CMS] Unapprove page versions when a page is duplicated
<?php
if ($app->isInstalled()) {
// Register Events
/** @var \Symfony\Component\EventDispatcher\EventDispatcherInterface $eventDispatcher */
$eventDispatcher = $app->make(\Symfony\Component\EventDispatcher\EventDispatcherInterface::class);
// Unapprove page versions when a page is duplicated
$eventDispatcher->addListener('on_page_duplicate', function ($event) {
/** @var \Concrete\Core\Page\DuplicatePageEvent $event */
@hissy
hissy / readme.md
Last active December 3, 2023 19:34
#ConcreteCMS Migrate legacy database connection to doctrine
@hissy
hissy / gist:7352933
Created November 7, 2013 11:07
[WordPress] Add file to media library programmatically
<?php
$file = '/path/to/file.png';
$filename = basename($file);
$upload_file = wp_upload_bits($filename, null, file_get_contents($file));
if (!$upload_file['error']) {
$wp_filetype = wp_check_filetype($filename, null );
$attachment = array(
'post_mime_type' => $wp_filetype['type'],
'post_parent' => $parent_post_id,
@hissy
hissy / nav-menu-exporter-importer.php
Last active August 13, 2023 17:06
[WordPress Plugin] Nav Menu Exporter and Importer / Export and Import nav menus. Requires WordPress Importer plugin.
<?php
/*
Plugin Name: Nav Menu Exporter and Importer
Description: Export and Import nav menus. Requires WordPress Importer plugin
Author: hissy, megumi themes
Version: 0.1
Text Domain: nav-menu-exporter-importer
License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
@hissy
hissy / gist:3613306
Last active June 26, 2023 22:56
[WordPress] change next / previous post link ordering
<?php
/**
* Customize Adjacent Post Link Order
*/
function my_custom_adjacent_post_where($sql) {
if ( !is_main_query() || !is_singular() )
return $sql;
$the_post = get_post( get_the_ID() );
$patterns = array();
@hissy
hissy / readme.md
Last active May 5, 2023 19:43
[concrete5] How to fix "failed to open stream" error when you delete doctrine proxies directory

How to fix "failed to open stream" error when you delete doctrine proxies directory

Whoops\Exception\ErrorException thrown with message "require(/path/to/concrete5/application/config/doctrine/proxies/__CG__ConcreteCoreEntityExpressEntity.php): failed to open stream: No such file or directory"

Enable "Doctrine Dev mode" manually

Add application/config/concrete.php file (or modify it) like below: