GithubHelp home page GithubHelp logo

alefalefalef / fontimator Goto Github PK

View Code? Open in Web Editor NEW
3.0 5.0 0.0 14.93 MB

The famous Fontimator, which automates everything for us. Developed by Reuven Karasik for AlefAlefAlef & Fontimonim

License: Other

PHP 99.85% CSS 0.05% JavaScript 0.10%

fontimator's Introduction

The AlefAlefAlef Fontimator

The famous Fontimator (FKA 'Zipomator'), which automates everything for us. Developed for AlefAlefAlef and Fontimonim.

Features

A full feature list and a blog post describing our use are soon to come.

Open Source

This plugin is here on GitHub, to give inspiration and examples of what a font foundry can achieve. The license for this plugin is distributed under CC-NC-ND which does not allow commercial use and/or redistribution of the code (or parts of it). Sorry guys, we worked hard on this for over half a year.

Let us know if you have any uses you want to get an exclusion for.

fontimator's People

Contributors

avrahamcornfeld avatar kinging123 avatar nikolay484 avatar

Stargazers

Hagar Dolev avatar  avatar  avatar

Watchers

James Cloos avatar  avatar  avatar  avatar  avatar

fontimator's Issues

Build a framework for displaying long lists of users

To avoid messy code like in

public function maybe_generate_complete_family_eligible_emails_list ( $screen ) {
if ( ! strpos($screen->id, "fontimator-config") == true || ! isset( $_GET['generate_complete_family_eligible_list'] ) ) {
return;
}
global $mc4wp_aaa;
// Settings for long requests
ini_set('max_execution_time', 6000); // 6000 seconds = 100 minutes
ob_end_flush();
ob_implicit_flush( true );
ob_end_flush();
// Use file
$time = date('d-m-Y_His');
$emails_file = fopen("/var/www/output/family_eligible_emails_$time.txt", 'a') or die("Unable to open file!");;//opens file in append mode
$acf = Fontimator::get_instance()->get_acf();
$limited_to_fonts = $acf->get_acf_field( 'complete_family_limit_fonts', 'options' );
$limit_days = $acf->get_acf_field( 'complete_family_limit_days_from_purchase', 'options' );
$all_users = get_users( array(
'fields' => array( 'ID' ),
// 'number' => 500,
// 'offset' => 500 * ( $_GET['half_thousand'] ?: 0 )
) );
foreach ( $all_users as $user ) {
$customer_id = $user->ID;
// Skip if has subscription
$subscription = wcs_user_has_subscription( $customer_id, '', 'active' );
if ( $subscription ) {
continue;
}
// Skip if not subscribed
$userdata = get_userdata($customer_id);
$user_email = $userdata->user_email;
if ( $mc4wp_aaa ) {
if ( ! $mc4wp_aaa->is_user_subscribed( $user_email ) ) {
continue;
}
}
$downloads = wc_get_customer_available_downloads( $customer_id );
$fonts = [];
foreach ( $downloads as $download ) {
$variation = new Fontimator_Font_Variation( $download['product_id'] );
if ( ! $variation
|| $variation->get_license_type() !== 'otf'
|| strpos( $variation->get_family(), 'membership') !== false
|| $variation->get_family() === 'membership-reseller' ) {
continue;
}
$family_name = $variation->get_family();
// Check if font is in banner whitelist
if ( $limited_to_fonts && ! in_array( $variation->get_parent_id(), $limited_to_fonts ) ) {
continue;
}
if ( ! isset( $fonts[$family_name] ) ) {
// Check if font was purchased long enough ago, if this is first weight of font
if ( $limit_days ) {
$first_order = wc_get_order( $download['order_id'] );
$date_created = $first_order->get_date_created();
$timestamp_created = $date_created->getTimestamp();
$datetime_now = new WC_DateTime(); // Get now datetime (from Woocommerce datetime object)
$timestamp_now = $datetime_now->getTimestamp(); // Get now timestamp
$time_delta = $timestamp_now - $timestamp_created; // Difference in seconds
$days_in_seconds = $limit_days * 24 * 60 * 60; // x days in seconds
if ( $time_delta < $days_in_seconds ) {
continue; // Skip fonts purchased too recently.
}
}
$fonts[$family_name] = [];
}
$fonts[$family_name][] = $variation->get_weight();
if ( $variation->get_weight() === '000-familybasic' ) {
$font = new Fontimator_Font( $variation->get_parent_id() );
$fonts[$family_name] = array_unique( array_merge( $fonts[$family_name], $font->get_familybasic_weights( 'slug' ) ) );
}
} // Downloads loop
// Now, after we went over all the downloads, let's check every font for missing weights
foreach ( $fonts as $font_name => $purchased_weights ) {
if ( ! $font_id = get_page_by_path( $family_name, OBJECT, 'product' )->ID ) {
continue;
}
$font = new Fontimator_Font( $font_id );
$visible_weights = $font->get_visible_weights( 'slug' );
if ( ! $visible_weights ) {
continue;
}
$not_purchased_weights = array_diff( $visible_weights, $purchased_weights, [ '000-variable', '000-familybasic' ] );
if ( count( $purchased_weights ) // There are desktop weights, not just web/app
&& count( $not_purchased_weights ) // There are weights not yet purchased
&& ! in_array( '000-family', $purchased_weights ) // Person doesn't have both the entire family...
&& ! in_array( '000-variable', $purchased_weights ) // and the variable font.
) {
fwrite($emails_file, $user_email . ",\n");
break;
}
}
} // Customers loop
fwrite($emails_file, "#### DONE ####\n");
fclose($emails_file);
die();
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.