Skip to content

Instantly share code, notes, and snippets.

View victorknust's full-sized avatar
🏠
Working from home

Victor knust victorknust

🏠
Working from home
View GitHub Profile
@victorknust
victorknust / is_user_logged_in()
Created February 2, 2016 11:44 — forked from RafaelFunchal/is_user_logged_in()
Como usar a função is_user_logged_in() do WordPress.
<?php
// Caso o usuário esteja logado
if ( is_user_logged_in() ) :
?>
Aqui você coloca o seu conteúdo, normalmente é a função do WordPress
<?php the_content(); ?>
<?php
// Caso o usuário não esteja logado
else :
?>
@victorknust
victorknust / WP_Query()
Created February 2, 2016 11:44 — forked from RafaelFunchal/WP_Query()
Como exibir apens posts de uma determinada categoria na sua página WordPress
<?php
// Documentação completa em http://codex.wordpress.org/Class_Reference/WP_Query
$args = array(
'cat' => 1, //ID da sua categoria
'posts_per_page ' => 4, // Número de posts a exibir
);
$novo_loop = new WP_Query( $args );
if ( $novo_loop->have_posts() ) : while ( $novo_loop->have_posts() ) : $novo_loop->the_post();
# Sync fork with original repository
#
# Requires an "upstream" remote, pointing to original repo
# e.g. `git remote add upstream git@github.com:user/repo.git`
alias git-sync-fork="git fetch upstream; git checkout master; git merge upstream/master"
@victorknust
victorknust / Show attachments
Created February 2, 2016 11:43 — forked from RafaelFunchal/Show attachments
Show all post attachments
<?php
$attachment_args = array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => 'any',
'post_parent' => get_the_ID()
);
$attachments = get_posts( $attachment_args );
// SmoothScroll for websites v1.2.1
// Licensed under the terms of the MIT license.
// People involved
// - Balazs Galambosi (maintainer)
// - Michael Herf (Pulse Algorithm)
(function(){
// Scroll Variables (tweakable)
@victorknust
victorknust / .htaccess
Created February 2, 2016 11:42 — forked from RafaelFunchal/.htaccess
Exclude the files ajax, upload and WP CRON scripts from authentication
# Exclude the files ajax, upload and WP CRON scripts from authentication
<FilesMatch "(admin-ajax\.php|media-upload\.php|async-upload\.php|wp-cron\.php|xmlrpc\.php)$">
Order allow,deny
Allow from all
Satisfy any
</FilesMatch>
@victorknust
victorknust / Adapter.php
Created December 29, 2015 13:04 — forked from martinbean/Adapter.php
Basic ORM sketch that uses value objects, data mappers that persists data to a data source, and adapters for data sources.
<?php
abstract class Adapter
{
protected $config;
protected $connection;
public function __construct($config)
{
$this->config = $config;
<?php
/**
* Class Mapper
*/
abstract class Mapper
{
/**
* @var PDO
*/
<?php
require_once 'C:\xampp\htdocs\PainelOO\classes\DB\DB.php';
abstract class Crud extends DB{
protected $table;
abstract public function insert();
abstract public function update($id);
@victorknust
victorknust / PDO_workout.php
Created December 29, 2015 12:51 — forked from dara-tobi/PDO_workout.php
A PDO class extension with custom methods with which to manipulate a mysql database
<?php
namespace Dara\Db;
/**
* Class for Mysql database manipulation
*/
class MysqlPDO extends \PDO
{
/**
* Create a new database to work with