Skip to content

Instantly share code, notes, and snippets.

💭
😄

Takuro Hishikawa hissy

💭
😄
Block or report user

Report or block hissy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@hissy
hissy / valet.app.php
Last active Jan 16, 2020
#concrete5 config file for local environment
View valet.app.php
<?php
/**
* Set default value for curl option
*/
return [
'http_client' => [
'connecttimeout' => 30,
],
];
@hissy
hissy / gist:7352933
Created Nov 7, 2013
[WordPress] Add file to media library programmatically
View gist:7352933
<?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 / gist:6103177
Last active Nov 15, 2019
[WordPress] どうしても固定ページテンプレートでページ送り付きのアーカイブが作りたいのよと言う場合
View gist:6103177
<?php
/**
* Template Name: Archive Page */
?>
<?php
$paged = (int) get_query_var('paged');
$args = array(
'posts_per_page' => 3,
'paged' => $paged,
@hissy
hissy / really-simple-csv-importer-addon.php
Created Feb 25, 2015
[Really Simple CSV Importer] Example: import image from url to custom field
View really-simple-csv-importer-addon.php
<?php
/*
Plugin Name: Get Remote Image to Custom Field
*/
add_filter('really_simple_csv_importer_post_saved', function($post)
{
if (is_object($post)) {
// Get the meta data of which key is "image"
$image = $post->image;
@hissy
hissy / output.md
Last active Oct 31, 2019
#concrete5 Complete usage and output of Date Helper to localize date time format
View output.md
$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 / bulk_clear_page_paths.php
Last active Oct 23, 2019
#concrete5 c5:exec command to bulk clear page paths for all pages
View bulk_clear_page_paths.php
<?php
$list = new \Concrete\Core\Page\PageList();
$list->ignorePermissions();
$pages = $list->getResults();
$count = 0;
/** @var \Concrete\Core\Page\Page $page */
foreach ($pages as $page) {
@hissy
hissy / rscsvimporter-debug.php
Last active Oct 19, 2019
Really Simple CSV Importer Debugger add-on
View rscsvimporter-debug.php
<?php
/*
Plugin Name: Really Simple CSV Importer Debugger add-on
Description: Enables to dry-run-testing with Really Simple CSV Importer. When this add-on plugin activated, csv data will not imported, just displayed on dashboard.
Author: Takuro Hishikawa
Version: 0.2
*/
class rscsvimporter_debug {
// singleton instance
View empty_trash.php
<?php
use Concrete\Core\Page\Page;
use Concrete\Core\Page\PageList;
use Concrete\Core\Support\Facade\Facade;
$app = Facade::getFacadeApplication();
$app->make('cache/request')->disable();
$app->make('cache/expensive')->disable();
$app->make('cache')->disable();
@hissy
hissy / bulk_change_page_template.php
Last active Oct 1, 2019
#concrete5 c5:exec command to bulk change page type & template
View bulk_change_page_template.php
<?php
/**
* Usage:
* concrete/bin/concrete5 c5:exec bulk_change_page_template.php old_page_template_handle /parent-page-path new_page_template_handle
*/
$filterPageTemplateHandle = $args[0];
$filterPagePath = $args[1];
$changePageTemplateHandle = $args[2];
@hissy
hissy / bulk_change_storage_location.php
Last active Sep 30, 2019
#concrete5 Bulk change storage location for entire file manager
View bulk_change_storage_location.php
<?php
use Concrete\Core\Entity\File\File;
use Concrete\Core\File\FileList;
use Concrete\Core\File\StorageLocation\StorageLocationFactory;
use Concrete\Core\Support\Facade\Facade;
$app = Facade::getFacadeApplication();
/** @var StorageLocationFactory $factory */
$factory = $app->make(StorageLocationFactory::class);
You can’t perform that action at this time.